Starsector API
Loading...
Searching...
No Matches
SharedUnlockData.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl;
2
3import java.util.HashMap;
4import java.util.Map;
5
6import com.fs.starfarer.api.Global;
7import com.fs.starfarer.api.impl.codex.CodexDataV2;
8import com.fs.starfarer.api.impl.codex.CodexEntryPlugin;
9import com.fs.starfarer.api.impl.codex.CodexIntelAdder;
10
18
19 public static String SHARED_UNLOCKS_DATA_FILE = "core_shared_unlocks.json";
20
21 public static String ITEMS = "items";
22 public static String ILLUSTRATIONS = "illustrations";
23 public static String SHIPS = "ships";
24 public static String FIGHTERS = "fighters";
25 public static String WEAPONS = "weapons";
26
27 public static String SHIP_SYSTEMS = "ship_systems";
28 public static String HULLMODS = "hullmods";
29 public static String COMMODITIES = "commodities";
30 public static String INDUSTRIES = "industries";
31 public static String PLANETS = "planets";
32 public static String CONDITIONS = "conditions";
33 public static String SKILLS = "skills";
34 public static String ABILITIES = "abilities";
35
36 protected static SharedUnlockData instance;
37
38 public static SharedUnlockData get() {
39 if (instance == null) {
42 }
43 return instance;
44 }
45
46 @Override
47 protected String getFilename() {
49 }
50
51 public boolean isPlayerAwareOfSpecialItem(String itemId) {
52 return getSet(ITEMS).contains(itemId);
53 }
54
55 public boolean reportPlayerAwareOfSpecialItem(String itemId, boolean withSave) {
56 return reportPlayerAwareOfThing(itemId, ITEMS, CodexDataV2.getItemEntryId(itemId), withSave);
57 }
58
59 public boolean isPlayerAwareOfIllustration(String key) {
60 return getSet(ILLUSTRATIONS).contains(key);
61 }
62
63 public boolean reportPlayerAwareOfIllustration(String key, boolean withSave) {
65 }
66
67 public boolean isPlayerAwareOfShip(String hullId) {
68 return getSet(SHIPS).contains(hullId);
69 }
70
71 public boolean reportPlayerAwareOfShip(String hullId, boolean withSave) {
72 return reportPlayerAwareOfThing(hullId, SHIPS, CodexDataV2.getShipEntryId(hullId), withSave);
73 }
74
75 public boolean isPlayerAwareOfFighter(String fighterId) {
76 return getSet(FIGHTERS).contains(fighterId);
77 }
78
79 public boolean reportPlayerAwareOfFighter(String fighterId, boolean withSave) {
80 return reportPlayerAwareOfThing(fighterId, FIGHTERS, CodexDataV2.getFighterEntryId(fighterId), withSave);
81 }
82
83 public boolean isPlayerAwareOfWeapon(String weaponId) {
84 return getSet(WEAPONS).contains(weaponId);
85 }
86
87 public boolean reportPlayerAwareOfWeapon(String weaponId, boolean withSave) {
88 return reportPlayerAwareOfThing(weaponId, WEAPONS, CodexDataV2.getWeaponEntryId(weaponId), withSave);
89 }
90
91
92 public boolean isPlayerAwareOfShipSystem(String sysId) {
93 return getSet(SHIP_SYSTEMS).contains(sysId);
94 }
95
96 public boolean reportPlayerAwareOfShipSystem(String sysId, boolean withSave) {
98 }
99
100 public boolean isPlayerAwareOfHullmod(String hullmodId) {
101 return getSet(HULLMODS).contains(hullmodId);
102 }
103
104 public boolean reportPlayerAwareOfHullmod(String hullmodId, boolean withSave) {
105 return reportPlayerAwareOfThing(hullmodId, HULLMODS, CodexDataV2.getHullmodEntryId(hullmodId), withSave);
106 }
107
108 public boolean isPlayerAwareOfCommodity(String commodityId) {
109 return getSet(COMMODITIES).contains(commodityId);
110 }
111
112 public boolean reportPlayerAwareOfCommodity(String commodityId, boolean withSave) {
113 return reportPlayerAwareOfThing(commodityId, COMMODITIES, CodexDataV2.getCommodityEntryId(commodityId), withSave);
114 }
115
116 public boolean isPlayerAwareOfIndustry(String industryId) {
117 return getSet(INDUSTRIES).contains(industryId);
118 }
119
120 public boolean reportPlayerAwareOfIndustry(String industryId, boolean withSave) {
121 return reportPlayerAwareOfThing(industryId, INDUSTRIES, CodexDataV2.getIndustryEntryId(industryId), withSave);
122 }
123
124 public boolean isPlayerAwareOfPlanet(String planetId) {
125 return getSet(PLANETS).contains(planetId);
126 }
127
128 public boolean reportPlayerAwareOfPlanet(String planetId, boolean withSave) {
129 return reportPlayerAwareOfThing(planetId, PLANETS, CodexDataV2.getPlanetEntryId(planetId), withSave);
130 }
131
132 public boolean isPlayerAwareOfCondition(String conditionId) {
133 return getSet(CONDITIONS).contains(conditionId);
134 }
135
136 public boolean reportPlayerAwareOfCondition(String conditionId, boolean withSave) {
137 return reportPlayerAwareOfThing(conditionId, CONDITIONS, CodexDataV2.getConditionEntryId(conditionId), withSave);
138 }
139
140 public boolean isPlayerAwareOfSkill(String skillId) {
141 return getSet(SKILLS).contains(skillId);
142 }
143
144 public boolean reportPlayerAwareOfSkill(String skillId, boolean withSave) {
145 return reportPlayerAwareOfThing(skillId, SKILLS, CodexDataV2.getSkillEntryId(skillId), withSave);
146 }
147
148 public boolean isPlayerAwareOfAbility(String abilityId) {
149 return getSet(ABILITIES).contains(abilityId);
150 }
151
152 public boolean reportPlayerAwareOfAbility(String abilityId, boolean withSave) {
153 return reportPlayerAwareOfThing(abilityId, ABILITIES, CodexDataV2.getAbilityEntryId(abilityId), withSave);
154 }
155
156 public static Map<String, String> ILLUSTRATION_KEY_LOOKUP = null;
157
158 public void checkIfImageIsIllustrationAndMakeAware(String spriteName) {
159 if (spriteName == null) return;
160 if (ILLUSTRATION_KEY_LOOKUP == null) {
161 ILLUSTRATION_KEY_LOOKUP = new HashMap<>();
162 for (String key : Global.getSettings().getSpriteKeys("illustrations")) {
163 String sprite = Global.getSettings().getSpriteName("illustrations", key);
164 ILLUSTRATION_KEY_LOOKUP.put(sprite, key);
165 }
166 }
167
168 String key = ILLUSTRATION_KEY_LOOKUP.get(spriteName);
169 if (key != null) {
171 }
172 }
173
174
175 protected boolean reportPlayerAwareOfThing(String thingId, String setId, String codexEntryId, boolean withSave) {
176 boolean wasLocked = isEntryLocked(codexEntryId);
177 if (addToSet(setId, thingId)) {
178 if (wasLocked && !isEntryLocked(codexEntryId)) CodexIntelAdder.get().addEntry(codexEntryId);
179 if (withSave) saveIfNeeded();
180 return true;
181 }
182 return false;
183 }
184
185 public boolean isEntryLocked(String entryId) {
186 CodexEntryPlugin entry = CodexDataV2.getEntry(entryId);
187 return entry != null && entry.isLocked();
188 }
189}
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
static SettingsAPI getSettings()
Definition Global.java:57
boolean addToSet(String key, String value)
boolean reportPlayerAwareOfShipSystem(String sysId, boolean withSave)
boolean reportPlayerAwareOfPlanet(String planetId, boolean withSave)
static Map< String, String > ILLUSTRATION_KEY_LOOKUP
boolean reportPlayerAwareOfCondition(String conditionId, boolean withSave)
boolean reportPlayerAwareOfShip(String hullId, boolean withSave)
boolean reportPlayerAwareOfHullmod(String hullmodId, boolean withSave)
boolean reportPlayerAwareOfIllustration(String key, boolean withSave)
boolean reportPlayerAwareOfWeapon(String weaponId, boolean withSave)
boolean reportPlayerAwareOfThing(String thingId, String setId, String codexEntryId, boolean withSave)
boolean isPlayerAwareOfCommodity(String commodityId)
boolean reportPlayerAwareOfSpecialItem(String itemId, boolean withSave)
boolean reportPlayerAwareOfFighter(String fighterId, boolean withSave)
boolean isPlayerAwareOfIndustry(String industryId)
boolean reportPlayerAwareOfIndustry(String industryId, boolean withSave)
boolean reportPlayerAwareOfSkill(String skillId, boolean withSave)
boolean reportPlayerAwareOfAbility(String abilityId, boolean withSave)
boolean isPlayerAwareOfCondition(String conditionId)
boolean reportPlayerAwareOfCommodity(String commodityId, boolean withSave)
void checkIfImageIsIllustrationAndMakeAware(String spriteName)
static String getIndustryEntryId(String industryId)
static String getGalleryEntryId(String galleryId)
static String getFighterEntryId(String wingId)
static String getCommodityEntryId(String commodityId)
static String getShipSystemEntryId(String shipSystemId)
static String getPlanetEntryId(String planetId)
static String getHullmodEntryId(String hullModId)
static String getWeaponEntryId(String weaponId)
static String getConditionEntryId(String conditionId)
static String getAbilityEntryId(String abilityId)
static String getShipEntryId(String shipId)
static String getItemEntryId(String itemId)
static String getSkillEntryId(String skillId)
static CodexEntryPlugin getEntry(String id)
String getSpriteName(String category, String id)
List< String > getSpriteKeys(String category)