Refactor map info handler

This commit is contained in:
Melledy
2024-02-06 17:08:53 -08:00
parent 0058166aa8
commit 52610ff0ef
2 changed files with 217 additions and 42 deletions

View File

@@ -23,43 +23,56 @@ public class PacketGetSceneMapInfoScRsp extends BasePacket {
var data = GetSceneMapInfoScRsp.newInstance();
for (int entryId : list) {
// Create maze map
var mazeMap = MazeMapData.newInstance()
.addUnlockedChestList(MazeChest.newInstance().setMapInfoChestType(MapInfoChestType.MAP_INFO_CHEST_TYPE_NORMAL))
.addUnlockedChestList(MazeChest.newInstance().setMapInfoChestType(MapInfoChestType.MAP_INFO_CHEST_TYPE_PUZZLE))
.addUnlockedChestList(MazeChest.newInstance().setMapInfoChestType(MapInfoChestType.MAP_INFO_CHEST_TYPE_CHALLENGE))
.setEntryId(entryId);
// Map sections. TODO un hardcode
// Get map entrance excel
MapEntranceExcel excel = GameData.getMapEntranceExcelMap().get(entryId);
if (excel == null) {
data.addMapList(mazeMap);
continue;
}
// Get floor info
FloorInfo floorInfo = GameData.getFloorInfo(excel.getPlaneID(), excel.getFloorID());
if (floorInfo == null) {
data.addMapList(mazeMap);
continue;
}
// Chest counts
mazeMap.addUnlockedChestList(MazeChest.newInstance().setMapInfoChestType(MapInfoChestType.MAP_INFO_CHEST_TYPE_NORMAL).setTotalAmountList(1));
mazeMap.addUnlockedChestList(MazeChest.newInstance().setMapInfoChestType(MapInfoChestType.MAP_INFO_CHEST_TYPE_PUZZLE).setTotalAmountList(1));
mazeMap.addUnlockedChestList(MazeChest.newInstance().setMapInfoChestType(MapInfoChestType.MAP_INFO_CHEST_TYPE_CHALLENGE).setTotalAmountList(1));
// Add groups (Npc icons on the map, etc)
for (GroupInfo groupInfo : floorInfo.getGroups().values()) {
var mazeGroup = MazeGroup.newInstance().setGroupId(groupInfo.getId());
mazeMap.addMazeGroupList(mazeGroup);
}
// Map unlocked teleports
for (var teleport : floorInfo.getCachedTeleports().values()) {
mazeMap.addAllUnlockedTeleportList(teleport.getMappingInfoID());
}
// Map unlocked checkpoints that are not unlocked normally
for (var prop : floorInfo.getUnlockedCheckpoints()) {
var mazeProp = MazeProp.newInstance()
.setGroupId(prop.getAnchorGroupID())
.setConfigId(prop.getID())
.setState(PropState.CheckPointEnable.getVal());
mazeMap.addMazePropList(mazeProp);
}
// Lighten sections
for (int i = 0; i < 100; i++) {
mazeMap.addAllLightenSectionList(i);
}
// Maze groups (Npc icons on the map, etc)
MapEntranceExcel excel = GameData.getMapEntranceExcelMap().get(entryId);
if (excel != null) {
FloorInfo floorInfo = GameData.getFloorInfo(excel.getPlaneID(), excel.getFloorID());
if (floorInfo != null) {
// Add groups
for (GroupInfo groupInfo : floorInfo.getGroups().values()) {
var mazeGroup = MazeGroup.newInstance().setGroupId(groupInfo.getId());
mazeMap.addMazeGroupList(mazeGroup);
}
// Map unlocked teleports
for (var teleport : floorInfo.getCachedTeleports().values()) {
mazeMap.addAllUnlockedTeleportList(teleport.getMappingInfoID());
}
// Map unlocked checkpoints that are not unlocked normally
for (var prop : floorInfo.getUnlockedCheckpoints()) {
var mazeProp = MazeProp.newInstance()
.setGroupId(prop.getAnchorGroupID())
.setConfigId(prop.getID())
.setState(PropState.CheckPointEnable.getVal());
mazeMap.addMazePropList(mazeProp);
}
}
}
// Add to proto
data.addMapList(mazeMap);
}