package emu.grasscutter.data; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import emu.grasscutter.Grasscutter; import emu.grasscutter.data.binout.*; import emu.grasscutter.utils.Utils; import emu.grasscutter.data.excels.*; 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; import lombok.Getter; public class GameData { // BinOutputs private static final Int2ObjectMap abilityHashes = new Int2ObjectOpenHashMap<>(); private static final Map abilityEmbryos = new HashMap<>(); private static final Map abilityModifiers = new HashMap<>(); private static final Map openConfigEntries = new HashMap<>(); private static final Map scenePointEntries = new HashMap<>(); private static final Int2ObjectMap mainQuestData = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap homeworldDefaultSaveData = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap npcBornData = new Int2ObjectOpenHashMap<>(); // ExcelConfigs private static final Int2ObjectMap playerLevelDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap avatarDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap avatarLevelDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap avatarSkillDepotDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap avatarSkillDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap avatarCurveDataMap = new Int2ObjectLinkedOpenHashMap<>(); private static final Int2ObjectMap avatarFetterLevelDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap avatarPromoteDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap avatarTalentDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap proudSkillDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap itemDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap reliquaryLevelDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap reliquaryAffixDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap reliquaryMainPropDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap reliquarySetDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap weaponLevelDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap weaponPromoteDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap weaponCurveDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap equipAffixDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap envAnimalGatherConfigDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap monsterDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap npcDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap gadgetDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap monsterCurveDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap monsterDescribeDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap avatarFlycloakDataMap = new Int2ObjectLinkedOpenHashMap<>(); private static final Int2ObjectMap avatarCostumeDataMap = new Int2ObjectLinkedOpenHashMap<>(); private static final Int2ObjectMap avatarCostumeDataItemIdMap = new Int2ObjectLinkedOpenHashMap<>(); private static final Int2ObjectMap sceneDataMap = new Int2ObjectLinkedOpenHashMap<>(); private static final Int2ObjectMap fetterDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap codexQuestDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap codexQuestDataIdMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap codexAnimalDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap codexWeaponDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap codexWeaponDataIdMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap codexMaterialDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap codexMaterialDataIdMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap codexReliquaryDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap codexReliquaryDataIdMap = new Int2ObjectOpenHashMap<>(); private static final ArrayList codexReliquaryArrayList = new ArrayList<>(); private static final Int2ObjectMap fetterCharacterCardDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap rewardDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap worldAreaDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap worldLevelDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap dailyDungeonDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap dungeonEntryDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap dungeonDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap questDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap shopGoodsDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap combineDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap rewardPreviewDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap gatherDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap towerFloorDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap towerLevelDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap towerScheduleDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap buffDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap forgeDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap homeWorldLevelDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap furnitureMakeConfigDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap investigationMonsterDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap cityDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap weatherDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap battlePassMissionDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap battlePassRewardDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap cookRecipeDataMap = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap cookBonusDataMap = new Int2ObjectOpenHashMap<>(); @Getter private static final Int2ObjectMap activityDataMap = new Int2ObjectOpenHashMap<>(); @Getter private static final Int2ObjectMap activityWatcherDataMap = new Int2ObjectOpenHashMap<>(); @Getter private static final Int2ObjectMap musicGameBasicDataMap = new Int2ObjectOpenHashMap<>(); @Getter private static final Int2ObjectMap personalLineDataMap = new Int2ObjectOpenHashMap<>(); @Getter private static final Int2ObjectMap chapterDataMap = new Int2ObjectOpenHashMap<>(); @Getter private static final Int2ObjectMap openStateDataMap = new Int2ObjectOpenHashMap<>(); // Cache private static Map> fetters = new HashMap<>(); private static Map> shopGoods = new HashMap<>(); private static final IntList scenePointIdList = new IntArrayList(); @Getter private static final List openStateList = new ArrayList<>(); public static Int2ObjectMap getMapByResourceDef(Class resourceDefinition) { Int2ObjectMap map = null; try { Field field = GameData.class.getDeclaredField(Utils.lowerCaseFirstChar(resourceDefinition.getSimpleName()) + "Map"); field.setAccessible(true); map = (Int2ObjectMap) field.get(null); field.setAccessible(false); } catch (Exception e) { Grasscutter.getLogger().error("Error fetching resource map for " + resourceDefinition.getSimpleName(), e); } return map; } public static Int2ObjectMap getAbilityHashes() { return abilityHashes; } public static Map getAbilityEmbryoInfo() { return abilityEmbryos; } public static Map getAbilityModifiers() { return abilityModifiers; } public static Map getOpenConfigEntries() { return openConfigEntries; } public static Map getScenePointEntries() { return scenePointEntries; } // TODO optimize public static ScenePointEntry getScenePointEntryById(int sceneId, int pointId) { return getScenePointEntries().get(sceneId + "_" + pointId); } public static Int2ObjectMap getMainQuestDataMap() { return mainQuestData; } public static Int2ObjectMap getHomeworldDefaultSaveData() { return homeworldDefaultSaveData; } public static Int2ObjectMap getSceneNpcBornData() { return npcBornData; } public static Int2ObjectMap getAvatarDataMap() { return avatarDataMap; } public static Int2ObjectMap getItemDataMap() { return itemDataMap; } public static Int2ObjectMap getAvatarSkillDepotDataMap() { return avatarSkillDepotDataMap; } public static Int2ObjectMap getAvatarSkillDataMap() { return avatarSkillDataMap; } public static Int2ObjectMap getPlayerLevelDataMap() { return playerLevelDataMap; } public static Int2ObjectMap getAvatarFetterLevelDataMap() { return avatarFetterLevelDataMap; } public static Int2ObjectMap getFetterCharacterCardDataMap() { return fetterCharacterCardDataMap; } public static Int2ObjectMap getAvatarLevelDataMap() { return avatarLevelDataMap; } public static Int2ObjectMap getWeaponLevelDataMap() { return weaponLevelDataMap; } public static Int2ObjectMap getReliquaryAffixDataMap() { return reliquaryAffixDataMap; } public static Int2ObjectMap getReliquaryMainPropDataMap() { return reliquaryMainPropDataMap; } public static Int2ObjectMap getWeaponPromoteDataMap() { return weaponPromoteDataMap; } public static Int2ObjectMap getWeaponCurveDataMap() { return weaponCurveDataMap; } public static Int2ObjectMap getAvatarCurveDataMap() { return avatarCurveDataMap; } public static int getRelicExpRequired(int rankLevel, int level) { ReliquaryLevelData levelData = reliquaryLevelDataMap.get((rankLevel << 8) + level); return levelData != null ? levelData.getExp() : 0; } public static ReliquaryLevelData getRelicLevelData(int rankLevel, int level) { return reliquaryLevelDataMap.get((rankLevel << 8) + level); } public static WeaponPromoteData getWeaponPromoteData(int promoteId, int promoteLevel) { return weaponPromoteDataMap.get((promoteId << 8) + promoteLevel); } public static int getWeaponExpRequired(int rankLevel, int level) { WeaponLevelData levelData = weaponLevelDataMap.get(level); if (levelData == null) { return 0; } try { return levelData.getRequiredExps()[rankLevel - 1]; } catch (Exception e) { return 0; } } public static AvatarPromoteData getAvatarPromoteData(int promoteId, int promoteLevel) { return avatarPromoteDataMap.get((promoteId << 8) + promoteLevel); } public static int getAvatarLevelExpRequired(int level) { AvatarLevelData levelData = avatarLevelDataMap.get(level); return levelData != null ? levelData.getExp() : 0; } public static int getAvatarFetterLevelExpRequired(int level) { AvatarFetterLevelData levelData = avatarFetterLevelDataMap.get(level); return levelData != null ? levelData.getExp() : 0; } public static Int2ObjectMap getProudSkillDataMap() { return proudSkillDataMap; } public static Int2ObjectMap getMonsterDataMap() { return monsterDataMap; } public static Int2ObjectMap getEnvAnimalGatherConfigDataMap() { return envAnimalGatherConfigDataMap; } public static Int2ObjectMap getNpcDataMap() { return npcDataMap; } public static Int2ObjectMap getGadgetDataMap() { return gadgetDataMap; } public static Int2ObjectMap getReliquarySetDataMap() { return reliquarySetDataMap; } public static Int2ObjectMap getEquipAffixDataMap() { return equipAffixDataMap; } public static Int2ObjectMap getMonsterCurveDataMap() { return monsterCurveDataMap; } public static Int2ObjectMap getMonsterDescribeDataMap() { return monsterDescribeDataMap; } public static Int2ObjectMap getAvatarTalentDataMap() { return avatarTalentDataMap; } public static Int2ObjectMap getAvatarFlycloakDataMap() { return avatarFlycloakDataMap; } public static Int2ObjectMap getAvatarCostumeDataMap() { return avatarCostumeDataMap; } public static Int2ObjectMap getAvatarCostumeDataItemIdMap() { return avatarCostumeDataItemIdMap; } public static Int2ObjectMap getSceneDataMap() { return sceneDataMap; } public static Int2ObjectMap getRewardDataMap() { return rewardDataMap; } public static Map> getFetterDataEntries() { if (fetters.isEmpty()) { fetterDataMap.forEach((k, v) -> { if (!fetters.containsKey(v.getAvatarId())) { fetters.put(v.getAvatarId(), new ArrayList<>()); } fetters.get(v.getAvatarId()).add(k); }); } return fetters; } public static Int2ObjectMap getCodexQuestDataIdMap(){return codexQuestDataIdMap;} public static Int2ObjectMap getCodexAnimalDataMap(){return codexAnimalDataMap;} public static Int2ObjectMap getCodexWeaponDataIdMap(){return codexWeaponDataIdMap;} public static Int2ObjectMap getCodexMaterialDataIdMap(){return codexMaterialDataIdMap;} public static Int2ObjectMap getcodexReliquaryIdMap(){return codexReliquaryDataIdMap;} public static ArrayList getcodexReliquaryArrayList(){return codexReliquaryArrayList;} public static Int2ObjectMap getWorldAreaDataMap() { return worldAreaDataMap; } public static Int2ObjectMap getWorldLevelDataMap() { return worldLevelDataMap; } public static Int2ObjectMap getDungeonDataMap() { return dungeonDataMap; } public static Int2ObjectMap getDailyDungeonDataMap() { return dailyDungeonDataMap; } public static Int2ObjectMap getDungeonEntryDatatMap(){ return dungeonEntryDataMap; } public static Map> getShopGoodsDataEntries() { if (shopGoods.isEmpty()) { shopGoodsDataMap.forEach((k, v) -> { if (!shopGoods.containsKey(v.getShopType())) shopGoods.put(v.getShopType(), new ArrayList<>()); shopGoods.get(v.getShopType()).add(v); }); } return shopGoods; } public static Int2ObjectMap getRewardPreviewDataMap() { return rewardPreviewDataMap; } public static IntList getScenePointIdList() { return scenePointIdList; } public static Int2ObjectMap getCombineDataMap() { return combineDataMap; } public static Int2ObjectMap getTowerFloorDataMap(){ return towerFloorDataMap; } public static Int2ObjectMap getTowerLevelDataMap(){ return towerLevelDataMap; } public static Int2ObjectMap getTowerScheduleDataMap(){ return towerScheduleDataMap; } public static Int2ObjectMap getQuestDataMap() { return questDataMap; } public static Int2ObjectMap getForgeDataMap() { return forgeDataMap; } public static Int2ObjectMap getHomeWorldLevelDataMap() { return homeWorldLevelDataMap; } public static Int2ObjectMap getFurnitureMakeConfigDataMap() { return furnitureMakeConfigDataMap; } public static Int2ObjectMap getGatherDataMap() { return gatherDataMap; } public static Int2ObjectMap getInvestigationMonsterDataMap() { return investigationMonsterDataMap; } public static Int2ObjectMap getCityDataMap() { return cityDataMap; } public static Int2ObjectMap getWeatherDataMap() { return weatherDataMap; } public static Int2ObjectMap getBattlePassMissionDataMap() { return battlePassMissionDataMap; } public static Int2ObjectMap getBattlePassRewardDataMap() { return battlePassRewardDataMap; } public static Int2ObjectMap getCookRecipeDataMap() { return cookRecipeDataMap; } public static Int2ObjectMap getCookBonusDataMap() { return cookBonusDataMap; } public static Int2ObjectMap getBuffDataMap() { return buffDataMap; } }