Starsector API
Loading...
Searching...
No Matches
ItemEffectsRepo.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.econ.impl;
2
3import java.util.ArrayList;
4import java.util.HashMap;
5import java.util.LinkedHashSet;
6import java.util.List;
7import java.util.Map;
8import java.util.Set;
9
10import com.fs.starfarer.api.Global;
11import com.fs.starfarer.api.campaign.SpecialItemData;
12import com.fs.starfarer.api.campaign.econ.CommoditySpecAPI;
13import com.fs.starfarer.api.campaign.econ.Industry;
14import com.fs.starfarer.api.campaign.econ.InstallableIndustryItemPlugin.InstallableItemDescriptionMode;
15import com.fs.starfarer.api.campaign.econ.MarketAPI;
16import com.fs.starfarer.api.campaign.econ.MarketConditionAPI;
17import com.fs.starfarer.api.campaign.rules.MemoryAPI;
18import com.fs.starfarer.api.characters.MarketConditionSpecAPI;
19import com.fs.starfarer.api.impl.campaign.FusionLampEntityPlugin;
20import com.fs.starfarer.api.impl.campaign.econ.ResourceDepositsCondition;
21import com.fs.starfarer.api.impl.campaign.ids.Commodities;
22import com.fs.starfarer.api.impl.campaign.ids.Conditions;
23import com.fs.starfarer.api.impl.campaign.ids.Industries;
24import com.fs.starfarer.api.impl.campaign.ids.Items;
25import com.fs.starfarer.api.impl.campaign.ids.Stats;
26import com.fs.starfarer.api.impl.campaign.ids.Strings;
27import com.fs.starfarer.api.ui.TooltipMakerAPI;
28import com.fs.starfarer.api.util.Misc;
29
30@SuppressWarnings("serial")
31public class ItemEffectsRepo {
32
33 public static String NOT_A_GAS_GIANT = "not a gas giant";
34 public static String NOT_HABITABLE = "not habitable";
35 public static String HABITABLE = "habitable";
36 public static String GAS_GIANT = "gas giant";
37 public static String NO_ATMOSPHERE = "no atmosphere";
38 public static String NOT_EXTREME_WEATHER = "not extreme weather";
39 public static String NOT_EXTREME_TECTONIC_ACTIVITY = "not extreme tectonic activity";
40 public static String NO_TRANSPLUTONIC_ORE_DEPOSITS = "no transplutonic ore deposits";
41 public static String NO_VOLATILES_DEPOSITS = "no volatiles deposits";
42 public static String HOT_OR_EXTREME_HEAT = "hot or extreme heat";
43 public static String COLD_OR_EXTREME_COLD = "cold or extreme cold";
44
45 public static int CORONAL_TAP_LIGHT_YEARS = 10;
46 public static String CORONAL_TAP_RANGE = "coronal hypershunt within " + CORONAL_TAP_LIGHT_YEARS + " light-years";
47
48 public static int CORONAL_TAP_TRANSPLUTONICS = 10;
49 public static int CORONAL_TAP_INDUSTRIES = 1;
50
51 public static int FUSION_LAMP_FARMING_BONUS = 0;
52 public static int FUSION_LAMP_VOLATILES = 10;
53 public static float FUSION_LAMP_SHORTAGE_HAZARD = 0.5f;
54 public static List<String> FUSION_LAMP_CONDITIONS = new ArrayList<String>();
55 static {
56 FUSION_LAMP_CONDITIONS.add(Conditions.COLD);
57 FUSION_LAMP_CONDITIONS.add(Conditions.VERY_COLD);
58 FUSION_LAMP_CONDITIONS.add(Conditions.POOR_LIGHT);
59 FUSION_LAMP_CONDITIONS.add(Conditions.DARK);
60 }
61
62 public static float CORRUPTED_NANOFORGE_QUALITY_BONUS = 0.2f;
63 public static float PRISTINE_NANOFORGE_QUALITY_BONUS = 0.5f;
64
65 public static int CORRUPTED_NANOFORGE_PROD = 1;
66 public static int PRISTINE_NANOFORGE_PROD = 3;
67
68 public static int SYNCHROTRON_FUEL_BONUS = 3;
69
70 public static int MANTLE_BORE_MINING_BONUS = 3;
71 public static List<String> MANTLE_BORE_COMMODITIES = new ArrayList<String>();
72 static {
73 MANTLE_BORE_COMMODITIES.add(Commodities.ORE);
74 MANTLE_BORE_COMMODITIES.add(Commodities.RARE_ORE);
75 MANTLE_BORE_COMMODITIES.add(Commodities.ORGANICS);
76 }
77
78 public static int PLASMA_DYNAMO_MINING_BONUS = 3;
79 public static List<String> PLASMA_DYNAMO_COMMODITIES = new ArrayList<String>();
80 static {
81 PLASMA_DYNAMO_COMMODITIES.add(Commodities.VOLATILES);
82 }
83
84 public static int BIOFACTORY_PROD_BONUS = 2;
85
86 public static int CATALYTIC_CORE_BONUS = 3;
87
88 public static float FULLERENE_SPOOL_ACCESS_BONUS = 0.3f;
89
90 public static int SOIL_NANITES_BONUS = 2;
91
92 public static float CRYOARITHMETIC_FLEET_SIZE_BONUS_HOT = 0.25f;
93 public static float CRYOARITHMETIC_FLEET_SIZE_BONUS_VERY_HOT = 1f;
94
95 public static float DRONE_REPLICATOR_BONUS_MULT = 1.5f;
96
97 public static int DEALMAKER_INCOME_PERCENT_BONUS = 50;
98
99
100 public static Map<String, InstallableItemEffect> ITEM_EFFECTS = new HashMap<String, InstallableItemEffect>() {{
101 put(Items.ORBITAL_FUSION_LAMP, new BaseInstallableItemEffect(Items.ORBITAL_FUSION_LAMP) {
102 public void apply(Industry industry) {
103 Industry farming = getFarming(industry);
104 if (farming != null && FUSION_LAMP_FARMING_BONUS > 0) {
105 if (farming.isFunctional()) {
106 farming.getSupplyBonusFromOther().modifyFlat(spec.getId(), FUSION_LAMP_FARMING_BONUS,
107 Misc.ucFirst(spec.getName().toLowerCase()) + " (" + industry.getCurrentName() + ")");
108 } else {
109 farming.getSupplyBonusFromOther().unmodifyFlat(spec.getId());
110 }
111 }
112 if (industry instanceof BaseIndustry) {
113 BaseIndustry b = (BaseIndustry) industry;
114 b.demand(9, Commodities.VOLATILES, FUSION_LAMP_VOLATILES, Misc.ucFirst(spec.getName().toLowerCase()));
115
116 MemoryAPI memory = getLampMemory(industry);
117 float h = getShortageHazard(industry);
118 if (h > 0) {
119 industry.getMarket().getHazard().modifyFlat(spec.getId(), h,
120 Misc.ucFirst(spec.getName().toLowerCase()) + " volatiles shortage");
121 if (memory != null) {
122 // so that FusionLampEntityPlugin knows to flicker during a shortage
123 memory.set(FusionLampEntityPlugin.VOLATILES_SHORTAGE_KEY, h / FUSION_LAMP_SHORTAGE_HAZARD);
124 }
125 }
126 }
127 for (String id : FUSION_LAMP_CONDITIONS) {
128 industry.getMarket().suppressCondition(id);
129 }
130 }
131 public void unapply(Industry industry) {
132 Industry farming = getFarming(industry);
133 if (farming != null && FUSION_LAMP_FARMING_BONUS > 0) {
134 farming.getSupplyBonusFromOther().unmodifyFlat(spec.getId());
135 }
136 if (industry instanceof BaseIndustry) {
137 BaseIndustry b = (BaseIndustry) industry;
138 b.demand(9, Commodities.VOLATILES, 0, null);
139 industry.getMarket().getHazard().unmodifyFlat(spec.getId());
140 MemoryAPI memory = getLampMemory(industry);
141 if (memory != null) {
143 }
144 }
145 for (String id : FUSION_LAMP_CONDITIONS) {
146 industry.getMarket().unsuppressCondition(id);
147 }
148 }
149 protected MemoryAPI getLampMemory(Industry industry) {
150 if (industry instanceof PopulationAndInfrastructure) {
152 if (b.lamp != null) {
153 return b.lamp.getMemoryWithoutUpdate();
154 }
155 }
156 return null;
157 }
158 protected float getShortageHazard(Industry industry) {
159 int volatilesDemand = industry.getDemand(Commodities.VOLATILES).getQuantity().getModifiedInt();
160 if (volatilesDemand <= 0 || FUSION_LAMP_SHORTAGE_HAZARD <= 0) return 0f;
161 float v = industry.getMarket().getCommodityData(Commodities.VOLATILES).getAvailable();
162 float f = 1f - v / (float) volatilesDemand;
163 float h = Math.round(f * FUSION_LAMP_SHORTAGE_HAZARD * 100f) / 100f;
164 if (h > 0) {
165 industry.getMarket().getHazard().modifyFlat(spec.getId(), h,
166 Misc.ucFirst(spec.getName().toLowerCase()) + " volatiles shortage");
167 }
168 return h;
169 }
170 protected Industry getFarming(Industry industry) {
171 String farmingId = Industries.FARMING;
172 Industry farming = industry.getMarket().getIndustry(farmingId);
173 if (farming == null) {
174 farmingId = Industries.AQUACULTURE;
175 farming = industry.getMarket().getIndustry(farmingId);
176 }
177 return farming;
178 }
179 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
180 InstallableItemDescriptionMode mode, String pre, float pad) {
181 List<String> conds = new ArrayList<String>();
182 for (String id : FUSION_LAMP_CONDITIONS) {
183 MarketConditionSpecAPI mc = Global.getSettings().getMarketConditionSpec(id);
184 conds.add(mc.getName());
185 }
186 text.addPara(pre + "Counters the effects of " + Misc.getAndJoined(conds) + ". Increases heat on non-cold planets. " +
187 "Adds demand for %s units of volatiles.",
188 pad, Misc.getHighlightColor(),
189 "" + FUSION_LAMP_VOLATILES);
190 }
191 });
192 put(Items.CORRUPTED_NANOFORGE, new BoostIndustryInstallableItemEffect(
193 Items.CORRUPTED_NANOFORGE, CORRUPTED_NANOFORGE_PROD, 0) {
194 public void apply(Industry industry) {
195 super.apply(industry);
196 industry.getMarket().getStats().getDynamic().getMod(Stats.PRODUCTION_QUALITY_MOD)
197 .modifyFlat("nanoforge", CORRUPTED_NANOFORGE_QUALITY_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
198 }
199 public void unapply(Industry industry) {
200 super.unapply(industry);
201 industry.getMarket().getStats().getDynamic().getMod(Stats.PRODUCTION_QUALITY_MOD).unmodifyFlat("nanoforge");
202 }
203 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
204 InstallableItemDescriptionMode mode, String pre, float pad) {
205 String heavyIndustry = "heavy industry ";
206 if (mode == InstallableItemDescriptionMode.MANAGE_ITEM_DIALOG_LIST) {
207 heavyIndustry = "";
208 }
209 text.addPara(pre + "Increases ship and weapon production quality by %s. " +
210 "Increases " + heavyIndustry + "production by %s unit." +
211 " On habitable worlds, causes pollution which becomes permanent.",
212 pad, Misc.getHighlightColor(),
213 "" + (int) Math.round(CORRUPTED_NANOFORGE_QUALITY_BONUS * 100f) + "%",
214 "" + (int) CORRUPTED_NANOFORGE_PROD);
215 }
216 });
217 put(Items.PRISTINE_NANOFORGE, new BoostIndustryInstallableItemEffect(
218 Items.PRISTINE_NANOFORGE, PRISTINE_NANOFORGE_PROD, 0) {
219 public void apply(Industry industry) {
220 super.apply(industry);
221 industry.getMarket().getStats().getDynamic().getMod(Stats.PRODUCTION_QUALITY_MOD)
222 .modifyFlat("nanoforge", PRISTINE_NANOFORGE_QUALITY_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
223 }
224 public void unapply(Industry industry) {
225 super.unapply(industry);
226 industry.getMarket().getStats().getDynamic().getMod(Stats.PRODUCTION_QUALITY_MOD).unmodifyFlat("nanoforge");
227 }
228 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
229 InstallableItemDescriptionMode mode, String pre, float pad) {
230 String heavyIndustry = "heavy industry ";
231 if (mode == InstallableItemDescriptionMode.MANAGE_ITEM_DIALOG_LIST) {
232 heavyIndustry = "";
233 }
234 text.addPara(pre + "Increases ship and weapon production quality by %s. " +
235 "Increases " + heavyIndustry + "production by %s units." +
236 " On habitable worlds, causes pollution which becomes permanent.",
237 pad, Misc.getHighlightColor(),
238 "" + (int) Math.round(PRISTINE_NANOFORGE_QUALITY_BONUS * 100f) + "%",
239 "" + (int) PRISTINE_NANOFORGE_PROD);
240 }
241 });
242 put(Items.SYNCHROTRON, new BoostIndustryInstallableItemEffect(
243 Items.SYNCHROTRON, SYNCHROTRON_FUEL_BONUS, 0) {
244 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
245 InstallableItemDescriptionMode mode, String pre, float pad) {
246 //text.addPara(pre + "Increases fuel production and demand for volatiles by %s.",
247 text.addPara(pre + "Increases fuel production output by %s units.",
248 pad, Misc.getHighlightColor(), "" + SYNCHROTRON_FUEL_BONUS);
249 }
250 @Override
251 public String[] getSimpleReqs(Industry industry) {
252 return new String [] {NO_ATMOSPHERE};
253 }
254 });
255 put(Items.MANTLE_BORE, new BaseInstallableItemEffect(Items.MANTLE_BORE) {
256 protected Set<String> getAffectedCommodities(Industry industry) {
257 MarketAPI market = industry.getMarket();
258
259 Set<String> result = new LinkedHashSet<String>();
260 for (MarketConditionAPI mc : market.getConditions()) {
261 String cid = mc.getId();
262 String commodity = ResourceDepositsCondition.COMMODITY.get(cid);
263 for (String curr : MANTLE_BORE_COMMODITIES) {
264 if (curr.equals(commodity)) {
265 result.add(curr);
266 }
267 }
268 }
269 return result;
270 }
271 public void apply(Industry industry) {
272 if (industry instanceof BaseIndustry) {
273 BaseIndustry b = (BaseIndustry) industry;
274 Set<String> list = getAffectedCommodities(industry);
275
276 if (!list.isEmpty()) {
277 //b.demand(spec.getId(), Commodities.HEAVY_MACHINERY, MANTLE_BORE_MINING_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
278 for (String curr : list) {
279 b.supply(spec.getId(), curr, MANTLE_BORE_MINING_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
280 }
281 }
282 }
283 }
284 public void unapply(Industry industry) {
285 if (industry instanceof BaseIndustry) {
286 BaseIndustry b = (BaseIndustry) industry;
287
288 //b.demand(spec.getId(), Commodities.HEAVY_MACHINERY, 0, null);
289 for (String curr : MANTLE_BORE_COMMODITIES) {
290 b.supply(spec.getId(), curr, 0, null);
291 }
292 }
293 }
294 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
295 InstallableItemDescriptionMode mode, String pre, float pad) {
296 List<String> commodities = new ArrayList<String>();
297 for (String curr : MANTLE_BORE_COMMODITIES) {
298 CommoditySpecAPI c = Global.getSettings().getCommoditySpec(curr);
299 commodities.add(c.getName().toLowerCase());
300 }
301 text.addPara(pre + "Increases " + Misc.getAndJoined(commodities) + " production by %s units.",
302 pad, Misc.getHighlightColor(),
303 "" + MANTLE_BORE_MINING_BONUS);
304// text.addPara(pre + "Increases " + Misc.getAndJoined(commodities) + " production by %s units. " +
305// "Increases demand for heavy machinery by %s units.",
306// pad, Misc.getHighlightColor(),
307// "" + MANTLE_BORE_MINING_BONUS,
308// "" + MANTLE_BORE_MINING_BONUS);
309 }
310 @Override
311 public String[] getSimpleReqs(Industry industry) {
312 return new String [] {NOT_A_GAS_GIANT, NOT_HABITABLE};
313 }
314 });
315 put(Items.PLASMA_DYNAMO, new BaseInstallableItemEffect(Items.PLASMA_DYNAMO) {
316 protected Set<String> getAffectedCommodities(Industry industry) {
317 MarketAPI market = industry.getMarket();
318
319 Set<String> result = new LinkedHashSet<String>();
320 for (MarketConditionAPI mc : market.getConditions()) {
321 String cid = mc.getId();
322 String commodity = ResourceDepositsCondition.COMMODITY.get(cid);
323 for (String curr : PLASMA_DYNAMO_COMMODITIES) {
324 if (curr.equals(commodity)) {
325 result.add(curr);
326 }
327 }
328 }
329 return result;
330 }
331 public void apply(Industry industry) {
332 if (industry instanceof BaseIndustry) {
333 BaseIndustry b = (BaseIndustry) industry;
334 Set<String> list = getAffectedCommodities(industry);
335
336 if (!list.isEmpty()) {
337 //b.demand(spec.getId(), Commodities.HEAVY_MACHINERY, PLASMA_DYNAMO_MINING_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
338 for (String curr : list) {
339 b.supply(spec.getId(), curr, PLASMA_DYNAMO_MINING_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
340 }
341 }
342 }
343 }
344 public void unapply(Industry industry) {
345 if (industry instanceof BaseIndustry) {
346 BaseIndustry b = (BaseIndustry) industry;
347
348 //b.demand(spec.getId(), Commodities.HEAVY_MACHINERY, 0, null);
349 for (String curr : PLASMA_DYNAMO_COMMODITIES) {
350 b.supply(spec.getId(), curr, 0, null);
351 }
352 }
353 }
354 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
355 InstallableItemDescriptionMode mode, String pre, float pad) {
356 List<String> commodities = new ArrayList<String>();
357 for (String curr : PLASMA_DYNAMO_COMMODITIES) {
358 CommoditySpecAPI c = Global.getSettings().getCommoditySpec(curr);
359 commodities.add(c.getName().toLowerCase());
360 }
361 text.addPara(pre + "Increases " + Misc.getAndJoined(commodities) + " production by %s units.",
362 pad, Misc.getHighlightColor(),
363 "" + PLASMA_DYNAMO_MINING_BONUS);
364// text.addPara(pre + "Increases " + Misc.getAndJoined(commodities) + " production by %s units. " +
365// "Increases demand for heavy machinery by %s units.",
366// pad, Misc.getHighlightColor(),
367// "" + PLASMA_DYNAMO_MINING_BONUS,
368// "" + PLASMA_DYNAMO_MINING_BONUS);
369 }
370 @Override
371 public String[] getSimpleReqs(Industry industry) {
372 return new String [] {GAS_GIANT};
373 }
374 });
375 put(Items.BIOFACTORY_EMBRYO, new BoostIndustryInstallableItemEffect(
376 Items.BIOFACTORY_EMBRYO, BIOFACTORY_PROD_BONUS, 0) {
377 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
378 InstallableItemDescriptionMode mode, String pre, float pad) {
379 text.addPara(pre + "Increases light industry production by %s units.",
380 pad, Misc.getHighlightColor(),
381 "" + (int) BIOFACTORY_PROD_BONUS);
382 }
383 @Override
384 public String[] getSimpleReqs(Industry industry) {
385 return new String [] {HABITABLE};
386 }
387 });
388 put(Items.CATALYTIC_CORE, new BoostIndustryInstallableItemEffect(
389 Items.CATALYTIC_CORE, CATALYTIC_CORE_BONUS, 0) {
390 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
391 InstallableItemDescriptionMode mode, String pre, float pad) {
392 text.addPara(pre + "Increases refining production by %s units.",
393 pad, Misc.getHighlightColor(),
394 "" + (int) CATALYTIC_CORE_BONUS);
395 }
396 @Override
397 public String[] getSimpleReqs(Industry industry) {
398 return new String [] {NO_ATMOSPHERE};
399 }
400 });
401 put(Items.FULLERENE_SPOOL, new BaseInstallableItemEffect(Items.FULLERENE_SPOOL) {
402 public void apply(Industry industry) {
403 industry.getMarket().getAccessibilityMod().modifyFlat(spec.getId(),
404 FULLERENE_SPOOL_ACCESS_BONUS, Misc.ucFirst(spec.getName().toLowerCase()));
405 }
406 public void unapply(Industry industry) {
407 industry.getMarket().getAccessibilityMod().unmodifyFlat(spec.getId());
408 }
409 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
410 InstallableItemDescriptionMode mode, String pre, float pad) {
411 text.addPara(pre + "Increases colony accessibility by %s.",
412 pad, Misc.getHighlightColor(),
413 "" + (int) Math.round(FULLERENE_SPOOL_ACCESS_BONUS * 100f) + "%");
414 }
415 @Override
416 public String[] getSimpleReqs(Industry industry) {
417 return new String [] {NOT_A_GAS_GIANT, NOT_EXTREME_WEATHER, NOT_EXTREME_TECTONIC_ACTIVITY};
418 }
419 });
420 put(Items.SOIL_NANITES, new BoostIndustryInstallableItemEffect(
421 Items.SOIL_NANITES, SOIL_NANITES_BONUS, 0) {
422 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
423 InstallableItemDescriptionMode mode, String pre, float pad) {
424 text.addPara(pre + "Increases farming production by %s units.",
425 pad, Misc.getHighlightColor(),
426 "" + (int) SOIL_NANITES_BONUS);
427 }
428 @Override
429 public String[] getSimpleReqs(Industry industry) {
430 return new String [] {NO_TRANSPLUTONIC_ORE_DEPOSITS, NO_VOLATILES_DEPOSITS};
431 }
432 });
433 put(Items.CRYOARITHMETIC_ENGINE, new BaseInstallableItemEffect(Items.CRYOARITHMETIC_ENGINE) {
434 public void apply(Industry industry) {
435 float bonus = 0f;
436 if (industry.getMarket().hasCondition(Conditions.HOT)) {
437 bonus = CRYOARITHMETIC_FLEET_SIZE_BONUS_HOT;
438 } else if (industry.getMarket().hasCondition(Conditions.VERY_HOT)) {
439 bonus = CRYOARITHMETIC_FLEET_SIZE_BONUS_VERY_HOT;
440 }
441 industry.getMarket().getStats().getDynamic().getMod(Stats.COMBAT_FLEET_SIZE_MULT)
442 .modifyFlat(spec.getId(), bonus, Misc.ucFirst(spec.getName().toLowerCase()));
443 }
444 public void unapply(Industry industry) {
445 industry.getMarket().getStats().getDynamic().getMod(Stats.COMBAT_FLEET_SIZE_MULT).unmodifyFlat(spec.getId());
446 }
447 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
448 InstallableItemDescriptionMode mode, String pre, float pad) {
449 text.addPara(pre + "Increases size of fleets launched by colony by %s for hot worlds, and " +
450 "by %s for worlds with extreme heat.",
451 pad, Misc.getHighlightColor(),
452 "" + (int) Math.round(CRYOARITHMETIC_FLEET_SIZE_BONUS_HOT * 100f) + "%",
453 "" + (int) Math.round(CRYOARITHMETIC_FLEET_SIZE_BONUS_VERY_HOT * 100f) + "%");
454 }
455 @Override
456 public String[] getSimpleReqs(Industry industry) {
457 return new String [] {HOT_OR_EXTREME_HEAT};
458 }
459 });
460 put(Items.DRONE_REPLICATOR, new BaseInstallableItemEffect(Items.DRONE_REPLICATOR) {
461 public void apply(Industry industry) {
462 industry.getMarket().getStats().getDynamic().getMod(Stats.GROUND_DEFENSES_MOD)
463 .modifyMult(spec.getId(), DRONE_REPLICATOR_BONUS_MULT, Misc.ucFirst(spec.getName().toLowerCase()));
464 }
465 public void unapply(Industry industry) {
466 industry.getMarket().getStats().getDynamic().getMod(Stats.GROUND_DEFENSES_MOD).unmodifyMult(spec.getId());
467 }
468 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
469 InstallableItemDescriptionMode mode, String pre, float pad) {
470 text.addPara(pre + "Colony's ground defenses increased by %s.",
471 pad, Misc.getHighlightColor(),
472 Strings.X + DRONE_REPLICATOR_BONUS_MULT);
473 }
474 });
475 put(Items.DEALMAKER_HOLOSUITE, new BaseInstallableItemEffect(Items.DEALMAKER_HOLOSUITE) {
476 public void apply(Industry industry) {
477 industry.getMarket().getIncomeMult().modifyPercent(spec.getId(), DEALMAKER_INCOME_PERCENT_BONUS,
478 Misc.ucFirst(spec.getName().toLowerCase()));
479 }
480 public void unapply(Industry industry) {
481 industry.getMarket().getIncomeMult().unmodifyPercent(spec.getId());
482 }
483 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
484 InstallableItemDescriptionMode mode, String pre, float pad) {
485 text.addPara(pre + "Colony's income increased by %s.",
486 pad, Misc.getHighlightColor(),
487 "" + (int)DEALMAKER_INCOME_PERCENT_BONUS + "%");
488 }
489 });
490 put(Items.CORONAL_PORTAL, new BaseInstallableItemEffect(Items.CORONAL_PORTAL) {
491 public void apply(Industry industry) {
492 if (industry instanceof BaseIndustry) {
493 BaseIndustry b = (BaseIndustry) industry;
494 b.demand(8, Commodities.RARE_METALS, CORONAL_TAP_TRANSPLUTONICS, Misc.ucFirst(spec.getName().toLowerCase()));
495
496 if (!hasShortage(industry)) {
497 industry.getMarket().getStats().getDynamic().getMod(Stats.MAX_INDUSTRIES).modifyFlat(
498 spec.getId(), CORONAL_TAP_INDUSTRIES);
499 } else {
500 industry.getMarket().getStats().getDynamic().getMod(Stats.MAX_INDUSTRIES).unmodifyFlat(spec.getId());
501 }
502 }
503 }
504 public void unapply(Industry industry) {
505 if (industry instanceof BaseIndustry) {
506 BaseIndustry b = (BaseIndustry) industry;
507 b.demand(8, Commodities.RARE_METALS, 0, null);
508 industry.getMarket().getStats().getDynamic().getMod(Stats.MAX_INDUSTRIES).unmodifyFlat(spec.getId());
509 }
510 }
511 protected boolean hasShortage(Industry industry) {
512 //if (true) return false;
513 int transplutonicsDemand = industry.getDemand(Commodities.RARE_METALS).getQuantity().getModifiedInt();
514 float v = industry.getMarket().getCommodityData(Commodities.RARE_METALS).getAvailable();
515 float f = 1f - v / (float) transplutonicsDemand;
516 return f > 0;
517 }
518 protected void addItemDescriptionImpl(Industry industry, TooltipMakerAPI text, SpecialItemData data,
519 InstallableItemDescriptionMode mode, String pre, float pad) {
520 text.addPara(pre + "Increases the maximum number of industries at a colony by %s when demand for " +
521 "%s units of transplutonics is fully met.",
522 pad, Misc.getHighlightColor(),
523 "" + (int)CORONAL_TAP_INDUSTRIES,
524 "" + (int)CORONAL_TAP_TRANSPLUTONICS);
525 }
526 @Override
527 public String[] getSimpleReqs(Industry industry) {
528 return new String [] {CORONAL_TAP_RANGE};
529 }
530 });
531 }};
532
533
534
535
536
537}
538
539
540
541
542
543
544
static SettingsAPI getSettings()
Definition Global.java:51
Map< String, MutableCommodityQuantity > demand
MarketConditionSpecAPI getMarketConditionSpec(String conditionId)