mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 19:05:09 +00:00
Update how scene/dungeon map points are handled
This commit is contained in:
parent
c2b45a7a0d
commit
d64c26d4f5
@ -6,6 +6,7 @@ import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Calendar;
|
||||
|
||||
import emu.grasscutter.command.CommandMap;
|
||||
import emu.grasscutter.plugin.PluginManager;
|
||||
@ -32,6 +33,8 @@ public final class Grasscutter {
|
||||
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
private static final File configFile = new File("./config.json");
|
||||
|
||||
private static int day; // Current day of week
|
||||
|
||||
public static RunMode MODE = RunMode.BOTH;
|
||||
private static DispatchServer dispatchServer;
|
||||
private static GameServer gameServer;
|
||||
@ -67,8 +70,10 @@ public final class Grasscutter {
|
||||
Grasscutter.getLogger().info("Starting Grasscutter...");
|
||||
|
||||
// Load all resources.
|
||||
Grasscutter.updateDayOfWeek();
|
||||
ResourceLoader.loadAll();
|
||||
ScriptLoader.init();
|
||||
|
||||
// Database
|
||||
DatabaseManager.initialize();
|
||||
|
||||
@ -179,4 +184,13 @@ public final class Grasscutter {
|
||||
public static PluginManager getPluginManager() {
|
||||
return pluginManager;
|
||||
}
|
||||
|
||||
public static void updateDayOfWeek() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
day = calendar.get(Calendar.DAY_OF_WEEK);
|
||||
}
|
||||
|
||||
public static int getCurrentDayOfWeek() {
|
||||
return day;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ import emu.grasscutter.data.def.*;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
|
||||
public class GameData {
|
||||
// BinOutputs
|
||||
@ -61,12 +63,14 @@ public class GameData {
|
||||
private static final Int2ObjectMap<FetterCharacterCardData> fetterCharacterCardDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<RewardData> rewardDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<WorldLevelData> worldLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<DailyDungeonData> dailyDungeonDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<DungeonData> dungeonDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ShopGoodsData> shopGoodsDataMap = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
// Cache
|
||||
private static Map<Integer, List<Integer>> fetters = new HashMap<>();
|
||||
private static Map<Integer, List<ShopGoodsData>> shopGoods = new HashMap<>();
|
||||
private static final IntList scenePointIdList = new IntArrayList();
|
||||
|
||||
public static char EJWOA = 's';
|
||||
|
||||
@ -280,6 +284,10 @@ public class GameData {
|
||||
return dungeonDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<DailyDungeonData> getDailyDungeonDataMap() {
|
||||
return dailyDungeonDataMap;
|
||||
}
|
||||
|
||||
public static Map<Integer, List<ShopGoodsData>> getShopGoodsDataEntries() {
|
||||
if (shopGoods.isEmpty()) {
|
||||
shopGoodsDataMap.forEach((k, v) -> {
|
||||
@ -291,4 +299,8 @@ public class GameData {
|
||||
|
||||
return shopGoods;
|
||||
}
|
||||
|
||||
public static IntList getScenePointIdList() {
|
||||
return scenePointIdList;
|
||||
}
|
||||
}
|
||||
|
@ -48,11 +48,12 @@ public class ResourceLoader {
|
||||
loadOpenConfig();
|
||||
// Load resources
|
||||
loadResources();
|
||||
loadScenePoints();
|
||||
// Process into depots
|
||||
GameDepot.load();
|
||||
// Load spawn data
|
||||
loadSpawnData();
|
||||
// Load scene points - must be done AFTER resources are loaded
|
||||
loadScenePoints();
|
||||
// Custom - TODO move this somewhere else
|
||||
try {
|
||||
GameData.getAvatarSkillDepotDataMap().get(504).setAbilities(
|
||||
@ -168,6 +169,9 @@ public class ResourceLoader {
|
||||
|
||||
ScenePointEntry sl = new ScenePointEntry(sceneId + "_" + entry.getKey(), pointData);
|
||||
scenePointList.add(sl);
|
||||
GameData.getScenePointIdList().add(pointData.getId());
|
||||
|
||||
pointData.updateDailyDungeon();
|
||||
}
|
||||
|
||||
for (ScenePointEntry entry : scenePointList) {
|
||||
|
@ -1,12 +1,18 @@
|
||||
package emu.grasscutter.data.common;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.def.DailyDungeonData;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
|
||||
public class PointData {
|
||||
private int id;
|
||||
private String $type;
|
||||
private Position tranPos;
|
||||
private int[] dungeonIds;
|
||||
private int[] dungeonRandomList;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
@ -27,4 +33,31 @@ public class PointData {
|
||||
public int[] getDungeonIds() {
|
||||
return dungeonIds;
|
||||
}
|
||||
|
||||
public int[] getDungeonRandomList() {
|
||||
return dungeonRandomList;
|
||||
}
|
||||
|
||||
public void updateDailyDungeon() {
|
||||
if (getDungeonRandomList() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IntList newDungeons = new IntArrayList();
|
||||
int day = Grasscutter.getCurrentDayOfWeek();
|
||||
|
||||
for (int randomId : getDungeonRandomList()) {
|
||||
DailyDungeonData data = GameData.getDailyDungeonDataMap().get(randomId);
|
||||
|
||||
if (data != null) {
|
||||
int[] addDungeons = data.getDungeonsByDay(day);
|
||||
|
||||
for (int d : addDungeons) {
|
||||
newDungeons.add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.dungeonIds = newDungeons.toIntArray();
|
||||
}
|
||||
}
|
||||
|
50
src/main/java/emu/grasscutter/data/def/DailyDungeonData.java
Normal file
50
src/main/java/emu/grasscutter/data/def/DailyDungeonData.java
Normal file
@ -0,0 +1,50 @@
|
||||
package emu.grasscutter.data.def;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.GameResource;
|
||||
import emu.grasscutter.data.ResourceType;
|
||||
|
||||
import emu.grasscutter.game.props.SceneType;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
@ResourceType(name = "DailyDungeonConfigData.json")
|
||||
public class DailyDungeonData extends GameResource {
|
||||
private int Id;
|
||||
private int[] Monday;
|
||||
private int[] Tuesday;
|
||||
private int[] Wednesday;
|
||||
private int[] Thursday;
|
||||
private int[] Friday;
|
||||
private int[] Saturday;
|
||||
private int[] Sunday;
|
||||
|
||||
private static final int[] empty = new int[0];
|
||||
private final Int2ObjectMap<int[]> map;
|
||||
|
||||
public DailyDungeonData() {
|
||||
this.map = new Int2ObjectOpenHashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.Id;
|
||||
}
|
||||
|
||||
public int[] getDungeonsByDay(int day) {
|
||||
return map.getOrDefault(day, empty);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
map.put(Calendar.MONDAY, Monday);
|
||||
map.put(Calendar.TUESDAY, Tuesday);
|
||||
map.put(Calendar.WEDNESDAY, Wednesday);
|
||||
map.put(Calendar.THURSDAY, Thursday);
|
||||
map.put(Calendar.FRIDAY, Friday);
|
||||
map.put(Calendar.SATURDAY, Saturday);
|
||||
map.put(Calendar.SUNDAY, Sunday);
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ public class DungeonManager {
|
||||
public void getEntryInfo(Player player, int pointId) {
|
||||
ScenePointEntry entry = GameData.getScenePointEntryById(player.getScene().getId(), pointId);
|
||||
|
||||
if (entry == null || entry.getPointData().getDungeonIds() == null) {
|
||||
if (entry == null) {
|
||||
// Error
|
||||
player.sendPacket(new PacketDungeonEntryInfoRsp());
|
||||
return;
|
||||
@ -79,4 +79,10 @@ public class DungeonManager {
|
||||
player.getWorld().transferPlayerToScene(player, prevScene, prevPos);
|
||||
player.sendPacket(new BasePacket(PacketOpcodes.PlayerQuitDungeonRsp));
|
||||
}
|
||||
|
||||
public void updateDailyDungeons() {
|
||||
for (ScenePointEntry entry : GameData.getScenePointEntries().values()) {
|
||||
entry.getPointData().updateDailyDungeon();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,11 @@ public class PacketDungeonEntryInfoRsp extends BasePacket {
|
||||
DungeonEntryInfoRsp.Builder proto = DungeonEntryInfoRsp.newBuilder()
|
||||
.setPointId(pointData.getId());
|
||||
|
||||
for (int dungeonId : pointData.getDungeonIds()) {
|
||||
DungeonEntryInfo info = DungeonEntryInfo.newBuilder().setDungeonId(dungeonId).build();
|
||||
proto.addDungeonEntryList(info);
|
||||
if (pointData.getDungeonIds() != null) {
|
||||
for (int dungeonId : pointData.getDungeonIds()) {
|
||||
DungeonEntryInfo info = DungeonEntryInfo.newBuilder().setDungeonId(dungeonId).build();
|
||||
proto.addDungeonEntryList(info);
|
||||
}
|
||||
}
|
||||
|
||||
this.setData(proto);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.GetScenePointRspOuterClass.GetScenePointRsp;
|
||||
@ -12,8 +13,12 @@ public class PacketGetScenePointRsp extends BasePacket {
|
||||
GetScenePointRsp.Builder p = GetScenePointRsp.newBuilder()
|
||||
.setSceneId(sceneId);
|
||||
|
||||
for (int i = 1; i < 1000; i++) {
|
||||
p.addUnlockedPointList(i);
|
||||
if (GameData.getScenePointIdList().size() == 0) {
|
||||
for (int i = 1; i < 1000; i++) {
|
||||
p.addUnlockedPointList(i);
|
||||
}
|
||||
} else {
|
||||
p.addAllUnlockedPointList(GameData.getScenePointIdList());
|
||||
}
|
||||
|
||||
for (int i = 1; i < 9; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user