Starsector API
Loading...
Searching...
No Matches
BaseIndustry.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.HashSet;
5import java.util.Iterator;
6import java.util.LinkedHashMap;
7import java.util.List;
8import java.util.Map;
9import java.util.Random;
10import java.util.Set;
11
12import java.awt.Color;
13
14import com.fs.starfarer.api.Global;
15import com.fs.starfarer.api.campaign.CargoAPI;
16import com.fs.starfarer.api.campaign.FactionAPI;
17import com.fs.starfarer.api.campaign.SpecialItemData;
18import com.fs.starfarer.api.campaign.SpecialItemSpecAPI;
19import com.fs.starfarer.api.campaign.comm.CommMessageAPI.MessageClickAction;
20import com.fs.starfarer.api.campaign.econ.CommodityOnMarketAPI;
21import com.fs.starfarer.api.campaign.econ.CommoditySpecAPI;
22import com.fs.starfarer.api.campaign.econ.Industry;
23import com.fs.starfarer.api.campaign.econ.InstallableIndustryItemPlugin;
24import com.fs.starfarer.api.campaign.econ.InstallableIndustryItemPlugin.InstallableItemDescriptionMode;
25import com.fs.starfarer.api.campaign.econ.MarketAPI;
26import com.fs.starfarer.api.campaign.econ.MarketAPI.MarketInteractionMode;
27import com.fs.starfarer.api.campaign.econ.MarketImmigrationModifier;
28import com.fs.starfarer.api.campaign.econ.MutableCommodityQuantity;
29import com.fs.starfarer.api.campaign.impl.items.GenericSpecialItemPlugin;
30import com.fs.starfarer.api.campaign.listeners.ListenerUtil;
31import com.fs.starfarer.api.campaign.rules.MemoryAPI;
32import com.fs.starfarer.api.combat.MutableStat;
33import com.fs.starfarer.api.combat.MutableStat.StatMod;
34import com.fs.starfarer.api.impl.SharedUnlockData;
35import com.fs.starfarer.api.impl.campaign.DebugFlags;
36import com.fs.starfarer.api.impl.campaign.econ.impl.ConstructionQueue.ConstructionQueueItem;
37import com.fs.starfarer.api.impl.campaign.ids.Commodities;
38import com.fs.starfarer.api.impl.campaign.ids.Industries;
39import com.fs.starfarer.api.impl.campaign.ids.Items;
40import com.fs.starfarer.api.impl.campaign.ids.Sounds;
41import com.fs.starfarer.api.impl.campaign.ids.Stats;
42import com.fs.starfarer.api.impl.campaign.ids.Strings;
43import com.fs.starfarer.api.impl.campaign.ids.Tags;
44import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin;
45import com.fs.starfarer.api.impl.campaign.intel.MessageIntel;
46import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.MarketCMD.RaidDangerLevel;
47import com.fs.starfarer.api.impl.codex.CodexDataV2;
48import com.fs.starfarer.api.loading.IndustrySpecAPI;
49import com.fs.starfarer.api.ui.Alignment;
50import com.fs.starfarer.api.ui.IconRenderMode;
51import com.fs.starfarer.api.ui.LabelAPI;
52import com.fs.starfarer.api.ui.TooltipMakerAPI;
53import com.fs.starfarer.api.ui.TooltipMakerAPI.StatModValueGetter;
54import com.fs.starfarer.api.util.Misc;
55import com.fs.starfarer.api.util.Pair;
56
57public abstract class BaseIndustry implements Industry, Cloneable {
58
59 public static int SIZE_FOR_SMALL_IMAGE = 3;
60 public static int SIZE_FOR_LARGE_IMAGE = 6;
61
62 public static float UPKEEP_MULT = 0.75f;
63 public static int DEMAND_REDUCTION = 1;
64 public static int SUPPLY_BONUS = 1;
65
66 public static int DEFAULT_IMPROVE_SUPPLY_BONUS = 1;
67
68 @Override
69 protected BaseIndustry clone() {
70 BaseIndustry copy = null;
71 try {
72 copy = (BaseIndustry) super.clone();
73 } catch (CloneNotSupportedException e) {
74 e.printStackTrace();
75 }
76 return copy;
77 }
78
79 //public static final float ORBITAL_HAZARD = 1f;
80
81 public static final String BASE_VALUE_TEXT = "Base value for colony size";
82
83 public static String getDeficitText(String commodityId) {
84 if (commodityId == null) {
85 return "Various shortages";
86 }
88 return Misc.ucFirst(spec.getName().toLowerCase() + " shortage");
89 }
90
91 // want to have some ability to add random supply/demand to industries
92 // e.g. market condition adding Volturnian Lobster supply to Volturn's Farming/Aquaculture
93 protected Map<String, MutableCommodityQuantity> supply = new LinkedHashMap<String, MutableCommodityQuantity>();
94 protected Map<String, MutableCommodityQuantity> demand = new LinkedHashMap<String, MutableCommodityQuantity>();
95
96 protected MutableStat income = new MutableStat(0f);
97 protected MutableStat upkeep = new MutableStat(0f);
98 protected MarketAPI market;
99
100 protected String id;
101
102 protected float buildProgress = 0f;
103 protected float buildTime = 1f;
104 protected boolean building = false;
105 protected Boolean improved = null;
106 protected String upgradeId = null;
107
108 protected transient IndustrySpecAPI spec = null;
109
110 protected String aiCoreId = null;
111// protected int demandReduction = 0;
112// protected int supplyBonus = 0;
113
116
118 protected transient MutableStat supplyBonusFromOther = new MutableStat(0);
119
120
121 public BaseIndustry() {
122 //setAICoreId(Commodities.BETA_CORE);
123 }
124
126 return demandReduction;
127 }
128
130 return supplyBonus;
131 }
132
139
141 if (supplyBonusFromOther == null) {
143 }
145 }
146
148 this.market = market;
149 }
150
151 public void init(String id, MarketAPI market) {
152 this.id = id;
153 this.market = market;
154 readResolve();
155 }
156
157 private transient String modId;
158 private transient String [] modIds;
159 protected Object readResolve() {
161
162 if (buildTime < 1f) buildTime = 1f;
163
164 modId = "ind_" + id;
165 modIds = new String[10];
166 for (int i = 0; i < modIds.length; i++) {
167 modIds[i] = modId + "_" + i;
168 }
169
170 if (demandReduction == null) demandReduction = new MutableStat(0);
171 if (supplyBonus == null) supplyBonus = new MutableStat(0);
172
173 if (supply != null) {
174 for (String id : new ArrayList<String>(supply.keySet())) {
175 MutableCommodityQuantity stat = supply.get(id);
176 stat.getQuantity().unmodifyFlat("ind_sb");
177 }
178 }
179 if (demand != null) {
180 for (String id : new ArrayList<String>(demand.keySet())) {
181 MutableCommodityQuantity stat = demand.get(id);
182 stat.getQuantity().unmodifyFlat("ind_dr");
183 }
184 }
185
186 return this;
187 }
188
189 protected Object writeReplace() {
190// BaseIndustry copy = clone();
191// copy.supply = null;
192// copy.demand = null;
193// return copy;
195 return this;
196 }
197
198
199 public void apply(boolean withIncomeUpdate) {
201
202 if (withIncomeUpdate) {
204 }
205
208
209 if (this instanceof MarketImmigrationModifier) {
211 }
212
213 if (special != null) {
215 if (effect != null) {
216 List<String> unmet = effect.getUnmetRequirements(this);
217 if (unmet == null || unmet.isEmpty()) {
218 effect.apply(this);
219 } else {
220 effect.unapply(this);
221 }
222 }
223 }
224 }
225
226 public void unapply() {
228
229 Boolean wasImproved = improved;
230 improved = null;
231 applyImproveModifiers(); // to unapply them
232 improved = wasImproved;
233
234 if (this instanceof MarketImmigrationModifier) {
236 }
237
238 if (special != null) {
240 if (effect != null) {
241 effect.unapply(this);
242 }
243 }
244 }
245
246 protected void applyAICoreModifiers() {
247 if (aiCoreId == null) {
249 return;
250 }
251 boolean alpha = aiCoreId.equals(Commodities.ALPHA_CORE);
252 boolean beta = aiCoreId.equals(Commodities.BETA_CORE);
253 boolean gamma = aiCoreId.equals(Commodities.GAMMA_CORE);
254 if (alpha) applyAlphaCoreModifiers();
255 else if (beta) applyBetaCoreModifiers();
256 else if (gamma) applyGammaCoreModifiers();
257 }
258
259 protected void applyAlphaCoreModifiers() {}
260 protected void applyBetaCoreModifiers() {}
261 protected void applyGammaCoreModifiers() {}
262 protected void applyNoAICoreModifiers() {}
263
264
265
266 protected String getModId() {
267 //return "ind_" + id;
268 return modId;
269 }
270
271 protected String getModId(int index) {
272 //return "ind_" + id + "_" + index;
273 return modIds[index];
274 }
275
276 public void demand(String commodityId, int quantity) {
277 demand(0, commodityId, quantity, BASE_VALUE_TEXT);
278 }
279
280 public void demand(String commodityId, int quantity, String desc) {
281 demand(0, commodityId, quantity, desc);
282 }
283 public void demand(int index, String commodityId, int quantity, String desc) {
284 demand(getModId(index), commodityId, quantity, desc);
285 }
286 public void demand(String modId, String commodityId, int quantity, String desc) {
287// if (commodityId != null && commodityId.equals("organics") && getId().contains("military")) {
288// System.out.println("wefwefwe");
289// }
290 //quantity -= demandReduction;
291 // want to apply negative numbers here so they add up with anything coming in from market conditions
292 if (quantity == 0) {
293 getDemand(commodityId).getQuantity().unmodifyFlat(modId);
294 } else {
295 getDemand(commodityId).getQuantity().modifyFlat(modId, quantity, desc);
296 }
297
298 if (quantity > 0) {
301 } else {
302 getDemand(commodityId).getQuantity().unmodifyFlat("ind_dr");
303 }
304 }
305 }
306
307 public void supply(String commodityId, int quantity) {
308 supply(0, commodityId, quantity, BASE_VALUE_TEXT);
309 }
310
311 public void supply(String commodityId, int quantity, String desc) {
312 supply(0, commodityId, quantity, desc);
313 }
314
315 public void supply(int index, String commodityId, int quantity, String desc) {
316 supply(getModId(index), commodityId, quantity, desc);
317 }
318 public void supply(String modId, String commodityId, int quantity, String desc) {
319// if (this instanceof Mining && market.getName().equals("Medea") &&
320// Commodities.VOLATILES.equals(commodityId)) {
321// System.out.println("efwefwe");
322// }
323
324 //quantity += supplyBonus; doesn't work gets applied multiple times potentially
325 // want to apply negative numbers here so they add up with anything coming in from market conditions
326 if (quantity == 0) {
327 getSupply(commodityId).getQuantity().unmodifyFlat(modId);
328 } else {
329 getSupply(commodityId).getQuantity().modifyFlat(modId, quantity, desc);
330 }
331
332 if (quantity > 0) {
333 //if (!getSupply(commodityId).getQuantity().isUnmodified()) {
334 if (!supplyBonus.isUnmodified()) {
335 getSupply(commodityId).getQuantity().modifyFlat("ind_sb", supplyBonus.getModifiedInt());
336 } else {
337 getSupply(commodityId).getQuantity().unmodifyFlat("ind_sb");
338 }
339 }
340 //getSupply(commodityId).getQuantity().unmodifyFlat("ind_sb");
341 }
342
343 protected void applyDeficitToProduction(int index, Pair<String, Integer> deficit, String ... commodities) {
344 for (String commodity : commodities) {
345// if (this instanceof Mining && market.getName().equals("Louise")) {
346// System.out.println("efwefwe");
347// }
348 if (getSupply(commodity).getQuantity().isUnmodified()) continue;
349 supply(index, commodity, -deficit.two, getDeficitText(deficit.one));
350 }
351 }
352
353// public static float getIncomeStabilityMult(float stability) {
354// if (stability <= 5) {
355// return Math.max(0, stability / 5f);
356// }
357// return 1f + (stability - 5f) * .1f;
358// }
359
360 public void updateIncomeAndUpkeep() {
362 }
363
364 protected void applyIncomeAndUpkeep(float sizeOverride) {
365 float size = market.getSize();
366 if (sizeOverride >= 0) size = sizeOverride;
367 float sizeMult = getSizeMult(size);
368 sizeMult = Math.max(1, sizeMult - 2);
369
370 float stabilityMult = market.getIncomeMult().getModifiedValue();
371 float upkeepMult = market.getUpkeepMult().getModifiedValue();
372// if (hazardMultOverride >= 0) {
373// upkeepMult = hazardMultOverride;
374// }
375
376
377 int income = (int) (getSpec().getIncome() * sizeMult);
378 if (income != 0) {
379 getIncome().modifyFlatAlways("ind_base", income, "Base value");
380 getIncome().modifyMultAlways("ind_stability", stabilityMult, "Market income multiplier");
381 } else {
382 getIncome().unmodifyFlat("ind_base");
383 getIncome().unmodifyMult("ind_stability");
384 }
385
386
387 int upkeep = (int) (getSpec().getUpkeep() * sizeMult);
388 if (upkeep != 0) {
389 getUpkeep().modifyFlatAlways("ind_base", upkeep, "Base value");
390 getUpkeep().modifyMultAlways("ind_hazard", upkeepMult, "Market upkeep multiplier");
391 } else {
392 getUpkeep().unmodifyFlat("ind_base");
393 getUpkeep().unmodifyMult("ind_hazard");
394 }
395
397
398 if (!isFunctional()) {
399 getIncome().unmodifyFlat("ind_base");
400 getIncome().unmodifyMult("ind_stability");
401 }
402 }
403
404// public static float getUpkeepMult(MarketAPI market) {
405// return getUpkeepHazardMult(market.getHazardValue());
406// }
407// public static float getUpkeepHazardMult(float hazard) {
408// float hazardMult = hazard;
409// if (hazardMult < 0) hazardMult = 0;
410// return hazardMult;
411// }
412
413 public float getBuildTime() {
414 return getSpec().getBuildTime();
415 }
416
417 protected Float buildCostOverride = null;
418 public Float getBuildCostOverride() {
419 return buildCostOverride;
420 }
422 this.buildCostOverride = buildCostOverride;
423 }
424 public float getBuildCost() {
425 if (buildCostOverride != null) return buildCostOverride;
426 return getSpec().getCost();
427 }
428
429 public float getBaseUpkeep() {
430 float size = market.getSize();
431 float sizeMult = getSizeMult(size);
432 sizeMult = Math.max(1, sizeMult - 2);
433 return getSpec().getUpkeep() * sizeMult;
434 }
435
436// public float getActualUpkeep() {
437// return getBaseUpkeep() * market.getUpkeepMult().getModifiedValue();
438// }
439
440 protected boolean wasDisrupted = false;
441 public void advance(float amount) {
442 boolean disrupted = isDisrupted();
443 if (!disrupted && wasDisrupted) {
445 }
446 wasDisrupted = disrupted;
447
448// if (disrupted) {
449// //if (DebugFlags.COLONY_DEBUG) {
450// String key = getDisruptedKey();
451// market.getMemoryWithoutUpdate().unset(key);
452// //}
453// }
454
455 if (building && !disrupted) {
456 float days = Global.getSector().getClock().convertToDays(amount);
457 //DebugFlags.COLONY_DEBUG = true;
459 days *= 100f;
460 }
461 buildProgress += days;
462
463 if (buildProgress >= buildTime) {
465 }
466 }
467
468 }
469
470 protected void notifyDisrupted() {
471
472 }
473
474 protected void disruptionFinished() {
475
476 }
477
478 public boolean isBuilding() {
479 return building;
480 }
481
482 public boolean isFunctional() {
483 if (isDisrupted()) return false;
484 return !(isBuilding() && !isUpgrading());
485 }
486
487 public boolean isUpgrading() {
488 return building && upgradeId != null;
489 }
490
492 if (isDisrupted()) {
493 return 0f;
494 }
495 if (!isBuilding()) return 0f;
496
497 return Math.min(1f, buildProgress / buildTime);
498 }
499
501 if (isDisrupted()) {
502 int left = (int) getDisruptedDays();
503 if (left < 1) left = 1;
504 String days = "days";
505 if (left == 1) days = "day";
506
507 return "" + left + " " + days + "";
508 }
509
510 int left = (int) (buildTime - buildProgress);
511 if (left < 1) left = 1;
512 String days = "days";
513 if (left == 1) days = "day";
514
515 return left + " " + days;
516 }
517
519 if (isDisrupted()) {
520 int left = (int) getDisruptedDays();
521 if (left < 1) left = 1;
522 String days = "days";
523 if (left == 1) days = "day";
524
525 return "Disrupted: " + left + " " + days + " left";
526 }
527
528 int left = (int) (buildTime - buildProgress);
529 if (left < 1) left = 1;
530 String days = "days";
531 if (left == 1) days = "day";
532
533// if (isBuilding() && !isUpgrading()) {
534// //return left + " " + days;
535// return "building: " + (int)Math.round(buildProgress / buildTime * 100f) + "%";
536// }
537
538 if (isUpgrading()) {
539 return "Upgrading: " + left + " " + days + " left";
540 } else {
541 return "Building: " + left + " " + days + " left";
542 }
543 }
544
545 public void startBuilding() {
546 building = true;
547 buildProgress = 0;
548 upgradeId = null;
549
551 unapply();
552 }
553
555 building = false;
556 buildProgress = 0;
557 buildTime = 1f;
558 if (upgradeId != null) {
559 market.removeIndustry(getId(), null, true);
562 industry.setAICoreId(getAICoreId());
563 industry.setImproved(isImproved());
564 industry.upgradeFinished(this);
565 industry.reapply();
566 } else {
568 reapply();
569 }
570 }
571
572 public void startUpgrading() {
573 building = true;
574 buildProgress = 0;
576
577
579 buildTime = upgrade.getBuildTime();
580 }
581
582 public void cancelUpgrade() {
583 building = false;
584 buildProgress = 0;
585 upgradeId = null;
586 }
587
588 public void downgrade() {
589 building = true;
590 buildProgress = 0;
593 }
594
595
596 public void reapply() {
597 unapply();
598 apply();
599 }
600
605
606 public static void buildNextInQueue(MarketAPI market) {
607 ConstructionQueueItem next = null;
608 Iterator<ConstructionQueueItem> iter = market.getConstructionQueue().getItems().iterator();
609 while (iter.hasNext()) {
610 next = iter.next();
611 iter.remove();
612
613 Industry ind = market.instantiateIndustry(next.id);
614 int num = Misc.getNumIndustries(market);
615 int max = Misc.getMaxIndustries(market);
616 if (ind.isAvailableToBuild() && (num <= max || !ind.isIndustry())) { // <= because num includes what's queued
617 break;
618 } else {
619 if (market.isPlayerOwned()) {
621 intel.addLine(BaseIntelPlugin.BULLET + "Construction aborted");
622
623 int refund = next.cost;
625 intel.addLine(BaseIntelPlugin.BULLET + "%s refunded",
627 new String [] {Misc.getDGSCredits(refund)}, Misc.getHighlightColor());
630 Global.getSector().getCampaignUI().addMessage(intel, MessageClickAction.COLONY_INFO, market);
631 }
632 next = null;
633 }
634 }
635
636 if (next != null) {
637 market.addIndustry(next.id);
638 Industry ind = market.getIndustry(next.id);
639 ind.startBuilding();
640 if (ind instanceof BaseIndustry) {
641 ((BaseIndustry)ind).setBuildCostOverride(next.cost);
642 }
643
644 if (market.isPlayerOwned()) {
646 intel.addLine(BaseIntelPlugin.BULLET + "Construction started");
649 Global.getSector().getCampaignUI().addMessage(intel, MessageClickAction.COLONY_INFO, market);
650 }
651 }
652 }
653
654 protected void upgradeFinished(Industry previous) {
656
657 setSpecialItem(previous.getSpecialItem());
658 }
659
660 protected void sendBuildOrUpgradeMessage() {
661 if (market.isPlayerOwned()) {
663 intel.addLine(BaseIntelPlugin.BULLET + "Construction completed");
666 Global.getSector().getCampaignUI().addMessage(intel, MessageClickAction.COLONY_INFO, market);
667 }
668 }
669
670 public void notifyBeingRemoved(MarketInteractionMode mode, boolean forUpgrade) {
671 if (aiCoreId != null && !forUpgrade) {
673 if (cargo != null) {
674 cargo.addCommodity(aiCoreId, 1);
675 }
676 }
677
678 if (special != null && !forUpgrade) {
680 if (cargo != null) {
681 cargo.addSpecial(special, 1);
682 }
683 }
684 }
685
686 protected CargoAPI getCargoForInteractionMode(MarketInteractionMode mode) {
687 CargoAPI cargo = null;
688 if (mode == null) return null;
689
690 if (mode == MarketInteractionMode.REMOTE) {
691 cargo = Misc.getStorageCargo(market);
692 } else {
694 }
695 return cargo;
696 }
697
698 public String getId() {
699 return id;
700 }
701
703 if (spec == null) spec = Global.getSettings().getIndustrySpec(id);
704 return spec;
705 }
706
707 public void clearUnmodified() {
708 if (supply != null) {
709 for (String id : new ArrayList<String>(supply.keySet())) {
710 MutableCommodityQuantity stat = supply.get(id);
711 if (stat != null && (stat.getQuantity().isUnmodified() || stat.getQuantity().getModifiedValue() <= 0)) {
712 supply.remove(id);
713 }
714 }
715 }
716 if (demand != null) {
717 for (String id : new ArrayList<String>(demand.keySet())) {
718 MutableCommodityQuantity stat = demand.get(id);
719 if (stat != null && (stat.getQuantity().isUnmodified() || stat.getQuantity().getModifiedValue() <= 0)) {
720 demand.remove(id);
721 }
722 }
723 }
724 }
725
726 public List<MutableCommodityQuantity> getAllDemand() {
727 List<MutableCommodityQuantity> result = new ArrayList<MutableCommodityQuantity>();
728 for (MutableCommodityQuantity q : demand.values()) {
729 if (q.getQuantity().getModifiedValue() > 0) {
730 result.add(q);
731 }
732 }
733 return result;
734 }
735
736 public List<MutableCommodityQuantity> getAllSupply() {
737 List<MutableCommodityQuantity> result = new ArrayList<MutableCommodityQuantity>();
738 for (MutableCommodityQuantity q : supply.values()) {
739 if (q.getQuantity().getModifiedValue() > 0) {
740 result.add(q);
741 }
742 }
743 return result;
744 }
745
747 MutableCommodityQuantity stat = supply.get(id);
748 if (stat == null) {
749 stat = new MutableCommodityQuantity(id);
750 supply.put(id, stat);
751 }
752 return stat;
753 }
754
756 MutableCommodityQuantity stat = demand.get(id);
757 if (stat == null) {
758 stat = new MutableCommodityQuantity(id);
759 demand.put(id, stat);
760 }
761 return stat;
762 }
763
765 return income;
766 }
767
769 return upkeep;
770 }
771
773 return market;
774 }
775
776// public String getMaxDeficitCommodity(String ... commodityIds) {
777// int max = 0;
778// String result = null;
779// for (String id : commodityIds) {
780// int demand = (int) getDemand(id).getQuantity().getModifiedValue();
781// CommodityOnMarketAPI com = market.getCommodityData(id);
782// int available = com.getAvailable();
783//
784// int deficit = Math.max(demand - available, 0);
785// if (deficit > max) {
786// max = deficit;
787// result = id;
788// }
789// }
790// return result;
791// }
792//
793// public int getMaxDeficit(String ... commodityIds) {
794// int max = 0;
795// for (String id : commodityIds) {
796// int demand = (int) getDemand(id).getQuantity().getModifiedValue();
797// CommodityOnMarketAPI com = market.getCommodityData(id);
798// int available = com.getAvailable();
799//
800// int deficit = Math.max(demand - available, 0);
801// if (deficit > max) max = deficit;
802// }
803// return max;
804// }
805
806 public Pair<String, Integer> getMaxDeficit(String ... commodityIds) {
808 result.two = 0;
809 if (Global.CODEX_TOOLTIP_MODE) return result;
810 for (String id : commodityIds) {
811 int demand = (int) getDemand(id).getQuantity().getModifiedValue();
813 int available = com.getAvailable();
814
815 int deficit = Math.max(demand - available, 0);
816 if (deficit > result.two) {
817 result.one = id;
818 result.two = deficit;
819 }
820 }
821 return result;
822 }
823
824 public List<Pair<String, Integer>> getAllDeficit() {
825 List<String> commodities = new ArrayList<String>();
826 for (MutableCommodityQuantity curr : demand.values()) {
827 commodities.add(curr.getCommodityId());
828 }
829 return getAllDeficit(commodities.toArray(new String[0]));
830 }
831
832 public List<Pair<String, Integer>> getAllDeficit(String ... commodityIds) {
833 List<Pair<String, Integer>> result = new ArrayList<Pair<String,Integer>>();
834 for (String id : commodityIds) {
835 int demand = (int) getDemand(id).getQuantity().getModifiedValue();
837 int available = com.getAvailable();
838
839 int deficit = Math.max(demand - available, 0);
840 if (deficit > 0) {
842 curr.one = id;
843 curr.two = deficit;
844 result.add(curr);
845 }
846 }
847 return result;
848 }
849
850 public float getSizeMult() {
851 return getSizeMult(market.getSize());
852 }
853 public static float getCommodityEconUnitMult(float size) {
854 if (size <= 0) return 0f;
855// if (size == 1) return 0.2f;
856// if (size == 2) return 0.3f;
857// if (size == 3) return 0.5f;
858 return 1f;
859 }
860 public static float getSizeMult(float size) {
861 if (size <= 0) return 0f;
862// if (size == 1) return 0.2f;
863// if (size == 2) return 0.5f;
864// return size - 2f;
865 return size;
866
867// if (size <= 1) return 0.2f;
868// if (size == 2) return 0.3f;
869// if (size == 3) return 0.5f;
870// return size - 3f;
871
872// if (size == 4) return 2f;
873// if (size == 5) return 4f;
874// if (size == 6) return 8f;
875// if (size == 7) return 16f;
876// if (size == 8) return 32f;
877// if (size == 9) return 64f;
878// if (size == 10) return 128f;
879//
880// return (float) Math.pow(2, size - 3);
881 }
882
883
884 public void doPreSaveCleanup() {
885 supply = null;
886 demand = null;
887 income = null;
888 upkeep = null;
889 }
890
891 public void doPostSaveRestore() {
892 supply = new LinkedHashMap<String, MutableCommodityQuantity>();
893 demand = new LinkedHashMap<String, MutableCommodityQuantity>();
894
895 income = new MutableStat(0f);
896 upkeep = new MutableStat(0f);
897 }
898
899
900 public String getCurrentImage() {
901 return getSpec().getImageName();
902 }
903
904 public String getCurrentName() {
905 return getSpec().getName();
906 }
907
908 public boolean isAvailableToBuild() {
911 }
912
913 public boolean showWhenUnavailable() {
915 return true;
916 }
917
918 public String getUnavailableReason() {
919 return "Can not be built";
920 }
921
922 public boolean isTooltipExpandable() {
923 return false;
924 }
925
926 public float getTooltipWidth() {
927 return 400f;
928 }
929
930 protected transient IndustryTooltipMode currTooltipMode = null;
931 public void createTooltip(IndustryTooltipMode mode, TooltipMakerAPI tooltip, boolean expanded) {
932
933 if (getSpec() != null && getSpec().hasTag(Tags.CODEX_UNLOCKABLE)) {
935 }
937
938 currTooltipMode = mode;
939
940 float pad = 3f;
941 float opad = 10f;
942
943 FactionAPI faction = market.getFaction();
944 Color color = faction.getBaseUIColor();
945 Color dark = faction.getDarkUIColor();
946 Color grid = faction.getGridUIColor();
947 Color bright = faction.getBrightUIColor();
948
949 Color gray = Misc.getGrayColor();
950 Color highlight = Misc.getHighlightColor();
951 Color bad = Misc.getNegativeHighlightColor();
952
953
954 MarketAPI copy = market.clone();
955 // the copy is a shallow copy and its conditions point to the original market
956 // so, make it share the suppressed conditions list, too, otherwise
957 // e.g. SolarArray will suppress conditions in the original market and the copy will still apply them
961 MarketAPI orig = market;
962
963 //int numBeforeAdd = Misc.getNumIndustries(market);
964
965 market = copy;
966 boolean needToAddIndustry = !market.hasIndustry(getId());
967 //addDialogMode = true;
968 if (needToAddIndustry) market.getIndustries().add(this);
969
970 if (mode != IndustryTooltipMode.NORMAL) {
973 curr.getAvailableStat().setBaseValue(100);
974 }
975 }
976
977// if (addDialogMode) {
978// market.reapplyConditions();
979// apply();
980// }
982 reapply();
983
984 String type = "";
985 if (isIndustry()) type = " - Industry";
986 if (isStructure()) type = " - Structure";
987
988 tooltip.addTitle(getCurrentName() + type, color);
989
990 String desc = spec.getDesc();
991 String override = getDescriptionOverride();
992 if (override != null) {
993 desc = override;
994 }
996
997 tooltip.addPara(desc, opad);
998
999// Industry inProgress = Misc.getCurrentlyBeingConstructed(market);
1000// if ((mode == IndustryTooltipMode.ADD_INDUSTRY && inProgress != null) ||
1001// (mode == IndustryTooltipMode.UPGRADE && inProgress != null)) {
1002// //tooltip.addPara("Another project (" + inProgress.getCurrentName() + ") in progress", bad, opad);
1003// //tooltip.addPara("Already building: " + inProgress.getCurrentName() + "", bad, opad);
1004// tooltip.addPara("Another construction in progress: " + inProgress.getCurrentName() + "", bad, opad);
1005// }
1006
1007 //tooltip.addPara("Type: %s", opad, gray, highlight, type);
1008 if (isIndustry() && (mode == IndustryTooltipMode.ADD_INDUSTRY ||
1009 mode == IndustryTooltipMode.UPGRADE ||
1010 mode == IndustryTooltipMode.DOWNGRADE)
1011 ) {
1012
1013 int num = Misc.getNumIndustries(market);
1014 int max = Misc.getMaxIndustries(market);
1015
1016
1017 // during the creation of the tooltip, the market has both the current industry
1018 // and the upgrade/downgrade. So if this upgrade/downgrade counts as an industry, it'd count double if
1019 // the current one is also an industry. Thus reduce num by 1 if that's the case.
1020 if (isIndustry()) {
1021 if (mode == IndustryTooltipMode.UPGRADE) {
1022 for (Industry curr : market.getIndustries()) {
1023 if (getSpec().getId().equals(curr.getSpec().getUpgrade())) {
1024 if (curr.isIndustry()) {
1025 num--;
1026 }
1027 break;
1028 }
1029 }
1030 } else if (mode == IndustryTooltipMode.DOWNGRADE) {
1031 for (Industry curr : market.getIndustries()) {
1032 if (getSpec().getId().equals(curr.getSpec().getDowngrade())) {
1033 if (curr.isIndustry()) {
1034 num--;
1035 }
1036 break;
1037 }
1038 }
1039 }
1040 }
1041
1042 Color c = gray;
1043 c = Misc.getTextColor();
1044 Color h1 = highlight;
1045 Color h2 = highlight;
1046 if (num > max) {// || (num >= max && mode == IndustryTooltipMode.ADD_INDUSTRY)) {
1047 //c = bad;
1048 h1 = bad;
1049 num--;
1050
1051 tooltip.addPara("Maximum number of industries reached", bad, opad);
1052 }
1053 //tooltip.addPara("Maximum of %s industries on a colony of this size. Currently: %s.",
1054// LabelAPI label = tooltip.addPara("Maximum industries for a colony of this size: %s. Industries: %s. ",
1055// opad, c, h1, "" + max, "" + num);
1056// label.setHighlightColors(h2, h1);
1057 }
1058
1059
1060
1061 addRightAfterDescriptionSection(tooltip, mode);
1062
1063 if (isDisrupted()) {
1064 int left = (int) getDisruptedDays();
1065 if (left < 1) left = 1;
1066 String days = "days";
1067 if (left == 1) days = "day";
1068
1069 tooltip.addPara("Operations disrupted! %s " + days + " until return to normal function.",
1070 opad, Misc.getNegativeHighlightColor(), highlight, "" + left);
1071 }
1072
1074 if (mode == IndustryTooltipMode.NORMAL) {
1075 if (getSpec().getUpgrade() != null && !isBuilding()) {
1076 tooltip.addPara("Click to manage or upgrade", Misc.getPositiveHighlightColor(), opad);
1077 } else {
1078 tooltip.addPara("Click to manage", Misc.getPositiveHighlightColor(), opad);
1079 }
1080 //tooltip.addPara("Click to manage", market.getFaction().getBrightUIColor(), opad);
1081 }
1082 }
1083
1084 if (mode == IndustryTooltipMode.QUEUED) {
1085 tooltip.addPara("Click to remove or adjust position in queue", Misc.getPositiveHighlightColor(), opad);
1086 tooltip.addPara("Currently queued for construction. Does not have any impact on the colony.", opad);
1087
1088 int left = (int) (getSpec().getBuildTime());
1089 if (left < 1) left = 1;
1090 String days = "days";
1091 if (left == 1) days = "day";
1092 tooltip.addPara("Requires %s " + days + " to build.", opad, highlight, "" + left);
1093
1094 //return;
1095 } else if (!isFunctional() && mode == IndustryTooltipMode.NORMAL && !isDisrupted()) {
1096 tooltip.addPara("Currently under construction and not producing anything or providing other benefits.", opad);
1097
1098 int left = (int) (buildTime - buildProgress);
1099 if (left < 1) left = 1;
1100 String days = "days";
1101 if (left == 1) days = "day";
1102 tooltip.addPara("Requires %s more " + days + " to finish building.", opad, highlight, "" + left);
1103 }
1104
1105
1106 if (!isAvailableToBuild() &&
1107 (mode == IndustryTooltipMode.ADD_INDUSTRY ||
1108 mode == IndustryTooltipMode.UPGRADE ||
1109 mode == IndustryTooltipMode.DOWNGRADE)) {
1110 String reason = getUnavailableReason();
1111 if (reason != null) {
1112 tooltip.addPara(reason, bad, opad);
1113 }
1114 }
1115
1116 boolean category = getSpec().hasTag(Industries.TAG_PARENT);
1117
1118 if (!category) {
1119 int credits = (int) Global.getSector().getPlayerFleet().getCargo().getCredits().get();
1120 String creditsStr = Misc.getDGSCredits(credits);
1121 if (mode == IndustryTooltipMode.UPGRADE || mode == IndustryTooltipMode.ADD_INDUSTRY) {
1122 int cost = (int) getBuildCost();
1123 String costStr = Misc.getDGSCredits(cost);
1124
1125 int days = (int) getBuildTime();
1126 String daysStr = "days";
1127 if (days == 1) daysStr = "day";
1128
1129 LabelAPI label = null;
1130 if (mode == IndustryTooltipMode.UPGRADE) {
1131 label = tooltip.addPara("%s and %s " + daysStr + " to upgrade. You have %s.", opad,
1132 highlight, costStr, "" + days, creditsStr);
1133 } else {
1134 label = tooltip.addPara("%s and %s " + daysStr + " to build. You have %s.", opad,
1135 highlight, costStr, "" + days, creditsStr);
1136 }
1137 label.setHighlight(costStr, "" + days, creditsStr);
1138 if (credits >= cost) {
1139 label.setHighlightColors(highlight, highlight, highlight);
1140 } else {
1141 label.setHighlightColors(bad, highlight, highlight);
1142 }
1143 } else if (mode == IndustryTooltipMode.DOWNGRADE) {
1144 if (getSpec().getUpgrade() != null) {
1145 float refundFraction = Global.getSettings().getFloat("industryRefundFraction");
1146
1147 //int cost = (int) (getBuildCost() * refundFraction);
1149 int cost = (int) (spec.getCost() * refundFraction);
1150 String refundStr = Misc.getDGSCredits(cost);
1151
1152 tooltip.addPara("%s refunded for downgrade.", opad, highlight, refundStr);
1153 }
1154 }
1155
1156
1157 addPostDescriptionSection(tooltip, mode);
1158
1159 if (!getIncome().isUnmodified()) {
1161 tooltip.addPara("Monthly income: %s", opad, highlight, Misc.getDGSCredits(income));
1162 tooltip.addStatModGrid(300, 65, 10, pad, getIncome(), true, new StatModValueGetter() {
1163 public String getPercentValue(StatMod mod) {return null;}
1164 public String getMultValue(StatMod mod) {return null;}
1165 public Color getModColor(StatMod mod) {return null;}
1166 public String getFlatValue(StatMod mod) {
1167 return Misc.getWithDGS(mod.value) + Strings.C;
1168 }
1169 });
1170 }
1171
1172 if (!getUpkeep().isUnmodified()) {
1174 tooltip.addPara("Monthly upkeep: %s", opad, highlight, Misc.getDGSCredits(upkeep));
1175 tooltip.addStatModGrid(300, 65, 10, pad, getUpkeep(), true, new StatModValueGetter() {
1176 public String getPercentValue(StatMod mod) {return null;}
1177 public String getMultValue(StatMod mod) {return null;}
1178 public Color getModColor(StatMod mod) {return null;}
1179 public String getFlatValue(StatMod mod) {
1180 return Misc.getWithDGS(mod.value) + Strings.C;
1181 }
1182 });
1183 }
1184
1185 addPostUpkeepSection(tooltip, mode);
1186
1187 boolean hasSupply = false;
1188 for (MutableCommodityQuantity curr : supply.values()) {
1189 int qty = curr.getQuantity().getModifiedInt();
1190 if (qty <= 0) continue;
1191 hasSupply = true;
1192 break;
1193 }
1194 boolean hasDemand = false;
1195 for (MutableCommodityQuantity curr : demand.values()) {
1196 int qty = curr.getQuantity().getModifiedInt();
1197 if (qty <= 0) continue;
1198 hasDemand = true;
1199 break;
1200 }
1201
1202 float maxIconsPerRow = 10f;
1203 if (hasSupply) {
1204 tooltip.addSectionHeading("Production", color, dark, Alignment.MID, opad);
1205 tooltip.beginIconGroup();
1206 tooltip.setIconSpacingMedium();
1207 float icons = 0;
1208 for (MutableCommodityQuantity curr : supply.values()) {
1209 int qty = curr.getQuantity().getModifiedInt();
1210 //if (qty <= 0) continue;
1211
1212 int normal = qty;
1213 if (normal > 0) {
1214 tooltip.addIcons(market.getCommodityData(curr.getCommodityId()), normal, IconRenderMode.NORMAL);
1215 }
1216
1217 int plus = 0;
1218 int minus = 0;
1219 for (StatMod mod : curr.getQuantity().getFlatMods().values()) {
1220 if (mod.value > 0) {
1221 plus += (int) mod.value;
1222 } else if (mod.desc != null && mod.desc.contains("shortage")) {
1223 minus += (int) Math.abs(mod.value);
1224 }
1225 }
1226 minus = Math.min(minus, plus);
1227 if (minus > 0 && mode == IndustryTooltipMode.NORMAL) {
1228 tooltip.addIcons(market.getCommodityData(curr.getCommodityId()), minus, IconRenderMode.DIM_RED);
1229 }
1230 icons += normal + Math.max(0, minus);
1231 }
1232 int rows = (int) Math.ceil(icons / maxIconsPerRow);
1233 rows = 3;
1234 tooltip.addIconGroup(32, rows, opad);
1235
1236
1237 }
1238// else if (!isFunctional() && mode == IndustryTooltipMode.NORMAL) {
1239// tooltip.addPara("Currently under construction and not producing anything or providing other benefits.", opad);
1240// }
1241
1242 addPostSupplySection(tooltip, hasSupply, mode);
1243
1244 if (hasDemand || hasPostDemandSection(hasDemand, mode)) {
1245 tooltip.addSectionHeading("Demand & effects", color, dark, Alignment.MID, opad);
1246 }
1247 if (hasDemand) {
1248 tooltip.beginIconGroup();
1249 tooltip.setIconSpacingMedium();
1250 float icons = 0;
1251 for (MutableCommodityQuantity curr : demand.values()) {
1252 int qty = curr.getQuantity().getModifiedInt();
1253 if (qty <= 0) continue;
1254
1255 CommodityOnMarketAPI com = orig.getCommodityData(curr.getCommodityId());
1256 int available = com.getAvailable();
1257
1258 int normal = Math.min(available, qty);
1259 int red = Math.max(0, qty - available);
1260
1261 if (mode != IndustryTooltipMode.NORMAL) {
1262 normal = qty;
1263 red = 0;
1264 }
1265 if (normal > 0) {
1266 tooltip.addIcons(com, normal, IconRenderMode.NORMAL);
1267 }
1268 if (red > 0) {
1269 tooltip.addIcons(com, red, IconRenderMode.DIM_RED);
1270 }
1271 icons += normal + Math.max(0, red);
1272 }
1273 int rows = (int) Math.ceil(icons / maxIconsPerRow);
1274 rows = 3;
1275 rows = 1;
1276 tooltip.addIconGroup(32, rows, opad);
1277 }
1278
1279 addPostDemandSection(tooltip, hasDemand, mode);
1280
1281 if (!needToAddIndustry) {
1282 //addAICoreSection(tooltip, AICoreDescriptionMode.TOOLTIP);
1283 addInstalledItemsSection(mode, tooltip, expanded);
1284 addImprovedSection(mode, tooltip, expanded);
1285
1286 ListenerUtil.addToIndustryTooltip(this, mode, tooltip, getTooltipWidth(), expanded);
1287 }
1288
1289 tooltip.addPara("*Shown production and demand values are already adjusted based on current market size and local conditions.", gray, opad);
1290 }
1291
1292 if (needToAddIndustry) {
1293 unapply();
1294 market.getIndustries().remove(this);
1295 }
1296 market = orig;
1298 if (!needToAddIndustry) {
1299 reapply();
1300 }
1302 }
1303
1304 public void addInstalledItemsSection(IndustryTooltipMode mode, TooltipMakerAPI tooltip, boolean expanded) {
1305 float opad = 10f;
1306
1307 FactionAPI faction = market.getFaction();
1308 Color color = faction.getBaseUIColor();
1309 Color dark = faction.getDarkUIColor();
1310
1311 LabelAPI heading = tooltip.addSectionHeading("Items", color, dark, Alignment.MID, opad);
1312
1313 boolean addedSomething = false;
1314 if (aiCoreId != null) {
1315 AICoreDescriptionMode aiCoreDescMode = AICoreDescriptionMode.INDUSTRY_TOOLTIP;
1316 addAICoreSection(tooltip, aiCoreId, aiCoreDescMode);
1317 addedSomething = true;
1318 }
1319 addedSomething |= addNonAICoreInstalledItems(mode, tooltip, expanded);
1320
1321 if (!addedSomething) {
1322 heading.setText("No items installed");
1323 //tooltip.addPara("None.", opad);
1324 }
1325 }
1326
1327 protected boolean addNonAICoreInstalledItems(IndustryTooltipMode mode, TooltipMakerAPI tooltip, boolean expanded) {
1328 if (special == null) return false;
1329
1330 float opad = 10f;
1332
1333 TooltipMakerAPI text = tooltip.beginImageWithText(spec.getIconName(), 48);
1335 effect.addItemDescription(this, text, special, InstallableItemDescriptionMode.INDUSTRY_TOOLTIP);
1336 tooltip.addImageWithText(opad);
1337
1338 return true;
1339 }
1340
1341// public List<SpecialItemData> getVisibleInstalledItems() {
1342// return new ArrayList<SpecialItemData>();
1343// }
1344
1345 public List<SpecialItemData> getVisibleInstalledItems() {
1346 List<SpecialItemData> result = new ArrayList<SpecialItemData>();
1347 if (special != null) {
1348 result.add(special);
1349 }
1350 return result;
1351 }
1352
1354 if (special != null) return false;
1356// String industry = spec.getParams();
1357// //String industry = ItemEffectsRepo.ITEM_TO_INDUSTRY.get(data.getId());
1358// return getId().equals(industry);
1359 String [] industries = spec.getParams().split(",");
1360 Set<String> all = new HashSet<String>();
1361 for (String ind: industries) all.add(ind.trim());
1362 return all.contains(getId());
1363 }
1364
1365// public boolean wantsToUseSpecialItem(SpecialItemData data) {
1366// return false;
1367// }
1368
1369
1370 public void addAICoreSection(TooltipMakerAPI tooltip, AICoreDescriptionMode mode) {
1371 addAICoreSection(tooltip, aiCoreId, mode);
1372 }
1373
1374 public void addAICoreSection(TooltipMakerAPI tooltip, String coreId, AICoreDescriptionMode mode) {
1375 float opad = 10f;
1376
1377 FactionAPI faction = market.getFaction();
1378 Color color = faction.getBaseUIColor();
1379 Color dark = faction.getDarkUIColor();
1380
1381// if (mode == AICoreDescriptionMode.TOOLTIP) {
1382// tooltip.addSectionHeading("AI Core", color, dark, Alignment.MID, opad);
1383// }
1384
1385// if (mode == AICoreDescriptionMode.TOOLTIP || mode == AICoreDescriptionMode.MANAGE_CORE_TOOLTIP) {
1386 if (mode == AICoreDescriptionMode.MANAGE_CORE_TOOLTIP) {
1387 if (coreId == null) {
1388 tooltip.addPara("No AI core currently assigned. Click to assign an AI core from your cargo.", opad);
1389 return;
1390 }
1391 }
1392
1393 boolean alpha = coreId.equals(Commodities.ALPHA_CORE);
1394 boolean beta = coreId.equals(Commodities.BETA_CORE);
1395 boolean gamma = coreId.equals(Commodities.GAMMA_CORE);
1396
1397 if (alpha) {
1398 addAlphaCoreDescription(tooltip, mode);
1399 } else if (beta) {
1400 addBetaCoreDescription(tooltip, mode);
1401 } else if (gamma) {
1402 addGammaCoreDescription(tooltip, mode);
1403 } else {
1404 addUnknownCoreDescription(coreId, tooltip, mode);
1405 }
1406 }
1407
1408 protected void addAlphaCoreDescription(TooltipMakerAPI tooltip, AICoreDescriptionMode mode) {
1409 float opad = 10f;
1410 Color highlight = Misc.getHighlightColor();
1411
1412 String pre = "Alpha-level AI core currently assigned. ";
1413 if (mode == AICoreDescriptionMode.MANAGE_CORE_DIALOG_LIST || mode == AICoreDescriptionMode.INDUSTRY_TOOLTIP) {
1414 pre = "Alpha-level AI core. ";
1415 }
1416 if (mode == AICoreDescriptionMode.INDUSTRY_TOOLTIP || mode == AICoreDescriptionMode.MANAGE_CORE_TOOLTIP) {
1418 TooltipMakerAPI text = tooltip.beginImageWithText(coreSpec.getIconName(), 48);
1419 text.addPara(pre + "Reduces upkeep cost by %s. Reduces demand by %s unit. " +
1420 "Increases production by %s unit.", 0f, highlight,
1421 "" + (int)((1f - UPKEEP_MULT) * 100f) + "%", "" + DEMAND_REDUCTION,
1422 "" + SUPPLY_BONUS);
1423 tooltip.addImageWithText(opad);
1424 return;
1425 }
1426
1427 tooltip.addPara(pre + "Reduces upkeep cost by %s. Reduces demand by %s unit. " +
1428 "Increases production by %s unit.", opad, highlight,
1429 "" + (int)((1f - UPKEEP_MULT) * 100f) + "%", "" + DEMAND_REDUCTION,
1430 "" + SUPPLY_BONUS);
1431 }
1432
1433 protected void addBetaCoreDescription(TooltipMakerAPI tooltip, AICoreDescriptionMode mode) {
1434 float opad = 10f;
1435 Color highlight = Misc.getHighlightColor();
1436
1437 String pre = "Beta-level AI core currently assigned. ";
1438 if (mode == AICoreDescriptionMode.MANAGE_CORE_DIALOG_LIST || mode == AICoreDescriptionMode.INDUSTRY_TOOLTIP) {
1439 pre = "Beta-level AI core. ";
1440 }
1441 if (mode == AICoreDescriptionMode.INDUSTRY_TOOLTIP || mode == AICoreDescriptionMode.MANAGE_CORE_TOOLTIP) {
1443 TooltipMakerAPI text = tooltip.beginImageWithText(coreSpec.getIconName(), 48);
1444 text.addPara(pre + "Reduces upkeep cost by %s. Reduces demand by %s unit.", opad, highlight,
1445 "" + (int)((1f - UPKEEP_MULT) * 100f) + "%", "" + DEMAND_REDUCTION);
1446 tooltip.addImageWithText(opad);
1447 return;
1448 }
1449
1450 tooltip.addPara(pre + "Reduces upkeep cost by %s. Reduces demand by %s unit.", opad, highlight,
1451 "" + (int)((1f - UPKEEP_MULT) * 100f) + "%", "" + DEMAND_REDUCTION);
1452 }
1453 protected void addGammaCoreDescription(TooltipMakerAPI tooltip, AICoreDescriptionMode mode) {
1454 float opad = 10f;
1455 Color highlight = Misc.getHighlightColor();
1456
1457 String pre = "Gamma-level AI core currently assigned. ";
1458 if (mode == AICoreDescriptionMode.MANAGE_CORE_DIALOG_LIST || mode == AICoreDescriptionMode.INDUSTRY_TOOLTIP) {
1459 pre = "Gamma-level AI core. ";
1460 }
1461 if (mode == AICoreDescriptionMode.INDUSTRY_TOOLTIP || mode == AICoreDescriptionMode.MANAGE_CORE_TOOLTIP) {
1463 TooltipMakerAPI text = tooltip.beginImageWithText(coreSpec.getIconName(), 48);
1464// text.addPara(pre + "Reduces upkeep cost by %s.", opad, highlight,
1465// "" + (int)((1f - UPKEEP_MULT) * 100f) + "%");
1466// tooltip.addImageWithText(opad);
1467 text.addPara(pre + "Reduces demand by %s unit.", opad, highlight,
1468 "" + DEMAND_REDUCTION);
1469 tooltip.addImageWithText(opad);
1470 return;
1471 }
1472
1473// tooltip.addPara(pre + "Reduces upkeep cost by %s.", opad, highlight,
1474// "" + (int)((1f - UPKEEP_MULT) * 100f) + "%");
1475 tooltip.addPara(pre + "Reduces demand by %s unit.", opad, highlight,
1476 "" + DEMAND_REDUCTION);
1477 }
1478
1479 protected void addUnknownCoreDescription(String coreId, TooltipMakerAPI tooltip, AICoreDescriptionMode mode) {
1480
1482 if (core == null) return;
1483
1484 float opad = 10f;
1485 Color highlight = Misc.getHighlightColor();
1486
1487 String pre = core.getName() + " currently assigned. ";
1488 if (mode == AICoreDescriptionMode.MANAGE_CORE_DIALOG_LIST || mode == AICoreDescriptionMode.INDUSTRY_TOOLTIP) {
1489 pre = core.getName() + ". ";
1490 }
1491
1492 if (mode == AICoreDescriptionMode.INDUSTRY_TOOLTIP || mode == AICoreDescriptionMode.MANAGE_CORE_TOOLTIP) {
1493 TooltipMakerAPI text = tooltip.beginImageWithText(core.getIconName(), 48);
1494 text.addPara(pre + "No effect.", opad);
1495 tooltip.addImageWithText(opad);
1496 return;
1497 }
1498
1499 tooltip.addPara(pre + "No effect.", opad);
1500 }
1501
1502
1503 protected void addPostSupplySection(TooltipMakerAPI tooltip, boolean hasSupply, IndustryTooltipMode mode) {
1504
1505 }
1506 protected void addPostDemandSection(TooltipMakerAPI tooltip, boolean hasDemand, IndustryTooltipMode mode) {
1507
1508 }
1509 protected void addRightAfterDescriptionSection(TooltipMakerAPI tooltip, IndustryTooltipMode mode) {
1510
1511 }
1512 protected void addPostDescriptionSection(TooltipMakerAPI tooltip, IndustryTooltipMode mode) {
1513
1514 }
1515 protected void addPostUpkeepSection(TooltipMakerAPI tooltip, IndustryTooltipMode mode) {
1516
1517 }
1518
1519 public String getAICoreId() {
1520 return aiCoreId;
1521 }
1522
1523 public void setAICoreId(String aiCoreId) {
1524 this.aiCoreId = aiCoreId;
1525 }
1526
1528 if (aiCoreId == null || Commodities.GAMMA_CORE.equals(aiCoreId)) {
1529 getUpkeep().unmodifyMult("ind_core");
1530 return;
1531 }
1532
1533 float mult = UPKEEP_MULT;
1534 String name = "AI Core assigned";
1535 if (aiCoreId.equals(Commodities.ALPHA_CORE)) {
1536 name = "Alpha Core assigned";
1537 } else if (aiCoreId.equals(Commodities.BETA_CORE)) {
1538 name = "Beta Core assigned";
1539 } else if (aiCoreId.equals(Commodities.GAMMA_CORE)) {
1540 name = "Gamma Core assigned";
1541 }
1542
1543 getUpkeep().modifyMult("ind_core", mult, name);
1544 }
1545
1547 if (aiCoreId == null) {
1548 return;
1549 }
1550
1551 boolean alpha = aiCoreId.equals(Commodities.ALPHA_CORE);
1552 boolean beta = aiCoreId.equals(Commodities.BETA_CORE);
1553 boolean gamma = aiCoreId.equals(Commodities.GAMMA_CORE);
1554
1555 if (alpha) {
1556// supplyBonus.modifyFlat(getModId(0), SUPPLY_BONUS, "Alpha core");
1557// demandReduction.modifyFlat(getModId(0), DEMAND_REDUCTION, "Alpha core");
1559 } else if (beta) {
1560 //demandReduction.modifyFlat(getModId(0), DEMAND_REDUCTION, "Beta core");
1562 } else if (gamma) {
1563 //demandReduction = DEMAND_REDUCTION;
1564 //demandReduction.modifyFlat(getModId(0), DEMAND_REDUCTION, "Gamma core");
1566 }
1567 }
1568
1573
1577
1581
1583
1584// if (this instanceof Mining && market.getName().equals("Louise")) {
1585// System.out.println("efwefwe");
1586// }
1587// supplyBonus = 0;
1588// demandReduction = 0;
1591
1593
1595
1596// supplyBonus += market.getAdmin().getStats().getDynamic().getValue(Stats.SUPPLY_BONUS_MOD, 0);
1597// demandReduction += market.getAdmin().getStats().getDynamic().getValue(Stats.DEMAND_REDUCTION_MOD, 0);
1600
1601 if (supplyBonusFromOther != null) {
1603 }
1604 if (demandReductionFromOther != null) {
1606 }
1607
1608// if (supplyBonusFromOther != null) {
1609// supplyBonusFromOther.unmodify();
1610// }
1611// if (demandReductionFromOther != null) {
1612// demandReductionFromOther.unmodify();
1613// }
1614
1615 }
1616
1617
1618 public boolean showShutDown() {
1619 return true;
1620 }
1621 public boolean canShutDown() {
1622 return true;
1623 }
1624 public String getCanNotShutDownReason() {
1625 return null;
1626 }
1627 public boolean canUpgrade() {
1628 return true;
1629 }
1630 public boolean canDowngrade() {
1631 return true;
1632 }
1633
1634 protected String getDescriptionOverride() {
1635 return null;
1636 }
1637
1638 public String getNameForModifier() {
1639 return Misc.ucFirst(getCurrentName().toLowerCase());
1640 }
1641
1643 return !com.isIllegal();
1644 }
1645
1647 return !com.isIllegal();
1648 }
1649
1650 protected boolean isAICoreId(String str) {
1651 Set<String> cores = new HashSet<String>();
1652 cores.add(Commodities.ALPHA_CORE);
1653 cores.add(Commodities.BETA_CORE);
1654 cores.add(Commodities.GAMMA_CORE);
1655 return cores.contains(str);
1656 }
1657
1658 public void initWithParams(List<String> params) {
1659 for (String str : params) {
1660 if (isAICoreId(str)) {
1661 setAICoreId(str);
1662 break;
1663 }
1664 }
1665
1666 for (String str : params) {
1667// if (Items.PRISTINE_NANOFORGE.equals(str)) {
1668// System.out.println("wefwefew");
1669// }
1671 if (spec == null) continue;
1672
1673 String [] industries = spec.getParams().split(",");
1674 Set<String> all = new HashSet<String>();
1675 for (String ind : industries) all.add(ind.trim());
1676 if (all.contains(getId())) {
1677 setSpecialItem(new SpecialItemData(str, null));
1678 }
1679 }
1680 }
1681
1682 protected boolean hasPostDemandSection(boolean hasDemand, IndustryTooltipMode mode) {
1683 return false;
1684 }
1685
1686
1687 protected int getBaseStabilityMod() {
1688 return 0;
1689 }
1690
1692 int stabilityMod = getBaseStabilityMod();
1693 int stabilityPenalty = getStabilityPenalty();
1694 if (stabilityPenalty > stabilityMod) {
1695 stabilityPenalty = stabilityMod;
1696 }
1697 stabilityMod -= stabilityPenalty;
1698 if (stabilityMod > 0) {
1700 }
1701// else if (stabilityMod < 0) {
1702// String str = getDeficitText(getStabilityAffectingDeficit().one);
1703// market.getStability().modifyFlat(getModId(), stabilityMod, getNameForModifier() + " (" + str.toLowerCase() + ")");
1704// }
1705 }
1706
1710
1714 protected int getStabilityPenalty() {
1715 float deficit = getStabilityAffectingDeficit().two;
1716 if (deficit < 0) deficit = 0;
1717 return (int) Math.round(deficit);
1718 }
1719
1720
1721 protected void addStabilityPostDemandSection(TooltipMakerAPI tooltip, boolean hasDemand, IndustryTooltipMode mode) {
1722 Color h = Misc.getHighlightColor();
1723 float opad = 10f;
1724
1725 MutableStat fake = new MutableStat(0);
1726 int stabilityMod = getBaseStabilityMod();
1727 int stabilityPenalty = getStabilityPenalty();
1728
1729 if (stabilityPenalty > stabilityMod) {
1730 stabilityPenalty = stabilityMod;
1731 }
1732
1733 String str = getDeficitText(getStabilityAffectingDeficit().one);
1734 fake.modifyFlat("1", stabilityMod, getNameForModifier());
1735 if (stabilityPenalty != 0) {
1736 fake.modifyFlat("2", -stabilityPenalty, str);
1737 }
1738
1739 int total = stabilityMod - stabilityPenalty;
1740 String totalStr = "+" + total;
1741 if (total < 0) {
1742 totalStr = "" + total;
1744 }
1745 float pad = 3f;
1746 if (total >= 0) {
1747 tooltip.addPara("Stability bonus: %s", opad, h, totalStr);
1748 } else {
1749 tooltip.addPara("Stability penalty: %s", opad, h, totalStr);
1750 }
1751 tooltip.addStatModGrid(400, 35, opad, pad, fake, new StatModValueGetter() {
1752 public String getPercentValue(StatMod mod) {
1753 return null;
1754 }
1755 public String getMultValue(StatMod mod) {
1756 return null;
1757 }
1758 public Color getModColor(StatMod mod) {
1759 if (mod.value < 0) return Misc.getNegativeHighlightColor();
1760 return null;
1761 }
1762 public String getFlatValue(StatMod mod) {
1763 return null;
1764 }
1765 });
1766 }
1767
1768 public void setHidden(boolean hidden) {
1769 if (hidden) hiddenOverride = true;
1770 else hiddenOverride = null;
1771 }
1772
1773 protected Boolean hiddenOverride = null;
1774 public boolean isHidden() {
1775 if (hiddenOverride != null) return hiddenOverride;
1776 return false;
1777 }
1778
1779 protected transient String dKey = null;
1780 public String getDisruptedKey() {
1781 if (dKey != null) return dKey;
1782 dKey = "$core_disrupted_" + getClass().getSimpleName();
1783 return dKey;
1784 }
1785
1786 public void setDisrupted(float days) {
1787 setDisrupted(days, false);
1788 }
1789 public void setDisrupted(float days, boolean useMax) {
1790 if (!canBeDisrupted()) return;
1791
1792 boolean was = isDisrupted();
1793 String key = getDisruptedKey();
1794
1796 float dur = days;
1797 if (useMax) {
1798 dur = Math.max(memory.getExpire(key), dur);
1799 }
1800
1801 if (dur <= 0) {
1802 memory.unset(key);
1803 } else {
1804 memory.set(key, true, dur);
1805 }
1806
1807 if (!was) {
1809 }
1810 }
1811
1812 public float getDisruptedDays() {
1813 String key = getDisruptedKey();
1814 float dur = market.getMemoryWithoutUpdate().getExpire(key);
1815 if (dur < 0) dur = 0;
1816 return dur;
1817 }
1818
1819 public boolean canBeDisrupted() {
1820 return true;
1821 }
1822
1823 public boolean isDisrupted() {
1824 String key = getDisruptedKey();
1825 return market.getMemoryWithoutUpdate().is(key, true);
1826 }
1827
1828 public float getPatherInterest() {
1829 float interest = 0;
1830 if (Commodities.ALPHA_CORE.equals(aiCoreId)) {
1831 interest += 4f;
1832 } else if (Commodities.BETA_CORE.equals(aiCoreId)) {
1833 interest += 2f;
1834 } else if (Commodities.GAMMA_CORE.equals(aiCoreId)) {
1835 interest += 1f;
1836 }
1837
1838 if (special != null) {
1840 if (spec != null) {
1841 if (spec.hasTag(Items.TAG_PATHER1)) interest += 1;
1842 else if (spec.hasTag(Items.TAG_PATHER2)) interest += 2;
1843 else if (spec.hasTag(Items.TAG_PATHER4)) interest += 4;
1844 else if (spec.hasTag(Items.TAG_PATHER6)) interest += 6;
1845 else if (spec.hasTag(Items.TAG_PATHER8)) interest += 8;
1846 else if (spec.hasTag(Items.TAG_PATHER10)) interest += 10;
1847 }
1848 }
1849
1850 return interest;
1851 }
1852
1854 return null;
1855 }
1856
1858 return getCurrentName();
1859 }
1860
1861
1862 protected SpecialItemData special = null;
1864 return special;
1865 }
1866
1868 //if (special == null && this.special != null) {
1869 if (this.special != null) {
1870 InstallableItemEffect effect = ItemEffectsRepo.ITEM_EFFECTS.get(this.special.getId());
1871 if (effect != null) {
1872 effect.unapply(this);
1873 }
1874 }
1875 this.special = special;
1876 }
1877
1878 protected float getDeficitMult(String ... commodities) {
1879 float deficit = getMaxDeficit(commodities).two;
1880 float demand = 0f;
1881
1882 for (String id : commodities) {
1883 demand = Math.max(demand, getDemand(id).getQuantity().getModifiedInt());
1884 }
1885
1886 if (deficit < 0) deficit = 0f;
1887 if (demand < 1) {
1888 demand = 1;
1889 deficit = 0f;
1890 }
1891
1892 float mult = (demand - deficit) / demand;
1893 if (mult < 0) mult = 0;
1894 if (mult > 1) mult = 1;
1895 return mult;
1896 }
1897
1898
1899 protected void addGroundDefensesImpactSection(TooltipMakerAPI tooltip, float bonus, String ...commodities) {
1900 Color h = Misc.getHighlightColor();
1901 float opad = 10f;
1902
1903 MutableStat fake = new MutableStat(1);
1904
1905 fake.modifyFlat("1", bonus, getNameForModifier());
1906
1907 if (commodities != null) {
1908 float mult = getDeficitMult(commodities);
1909 //mult = 0.89f;
1910 if (mult != 1) {
1911 String com = getMaxDeficit(commodities).one;
1912 fake.modifyFlat("2", -(1f - mult) * bonus, getDeficitText(com));
1913 }
1914 }
1915
1916 float total = Misc.getRoundedValueFloat(fake.getModifiedValue());
1917 String totalStr = Strings.X + total;
1918 if (total < 1f) {
1920 }
1921 float pad = 3f;
1922 tooltip.addPara("Ground defense strength: %s", opad, h, totalStr);
1923 tooltip.addStatModGrid(400, 35, opad, pad, fake, new StatModValueGetter() {
1924 public String getPercentValue(StatMod mod) {
1925 return null;
1926 }
1927 public String getMultValue(StatMod mod) {
1928 return null;
1929 }
1930 public Color getModColor(StatMod mod) {
1931 if (mod.value < 0) return Misc.getNegativeHighlightColor();
1932 return null;
1933 }
1934 public String getFlatValue(StatMod mod) {
1935 String r = Misc.getRoundedValue(mod.value);
1936 if (mod.value >= 0) return "+" + r;
1937 return r;
1938 }
1939 });
1940 }
1941
1942
1943 public boolean isIndustry() {
1945 }
1946
1947 public boolean isStructure() {
1949 }
1950 public boolean isOther() {
1951 return !isIndustry() && !isStructure();
1952 }
1953
1954 public void notifyColonyRenamed() {
1955
1956 }
1957
1958 public boolean canImprove() {
1960 }
1961
1962 public float getImproveBonusXP() {
1963 return 0;
1964 }
1965
1966 public String getImproveMenuText() {
1967 return "Make improvements...";
1968 }
1969
1971 int base = Global.getSettings().getInt("industryImproveBase");
1972 return base * (int) Math.round(Math.pow(2, Misc.getNumImprovedIndustries(market)));
1973
1974 //return 1 + Misc.getNumImprovedIndustries(market);
1975 }
1976
1977// private transient String iKey = null;
1978// public String getImprovedKey() {
1979// if (iKey != null) return iKey;
1980// iKey = "$core_improved_" + getClass().getSimpleName();
1981// return iKey;
1982// }
1983
1984 public boolean isImproved() {
1985 return improved != null && improved;
1986 }
1987
1988 public void setImproved(boolean improved) {
1989 if (!improved) {
1990 this.improved = null;
1991 } else {
1992 this.improved = improved;
1993 }
1994 }
1995
1996 protected void applyImproveModifiers() {
1997
1998 }
1999
2000 public void addImproveDesc(TooltipMakerAPI info, ImprovementDescriptionMode mode) {
2001 float initPad = 0f;
2002 float opad = 10f;
2003 boolean addedSomething = false;
2005 String unit = "unit";
2006 if (getImproveProductionBonus() != 1) {
2007 unit = "units";
2008 }
2009 if (mode == ImprovementDescriptionMode.INDUSTRY_TOOLTIP) {
2010 info.addPara("Production increased by %s " + unit + ".", initPad, Misc.getHighlightColor(),
2012 } else {
2013 info.addPara("Increases production by %s " + unit + ".", initPad, Misc.getHighlightColor(),
2015
2016 }
2017 initPad = opad;
2018 addedSomething = true;
2019 }
2020
2021 if (mode != ImprovementDescriptionMode.INDUSTRY_TOOLTIP) {
2022 // info.addPara("Each improved industry at a colony raises the cost to improve " +
2023 // "another industry by one " + Misc.STORY + " point.", initPad,
2024 // Misc.getStoryOptionColor(), Misc.STORY + " point");
2025 // info.addPara("Each improved industry at a colony doubles the number of " +
2026 // "" + Misc.STORY + " points required to improve an additional industry.", initPad,
2027 // Misc.getStoryOptionColor(), Misc.STORY + " points");
2028 // info.addPara("Each improved industry or structure at a colony doubles the number of " +
2029 // "" + Misc.STORY + " points required to improve an additional industry or structure.", initPad,
2030 // Misc.getStoryOptionColor(), Misc.STORY + " points");
2031 info.addPara("Each improvement made at a colony doubles the number of " +
2032 "" + Misc.STORY + " points required to make an additional improvement.", initPad,
2033 Misc.getStoryOptionColor(), Misc.STORY + " points");
2034 addedSomething = true;
2035 }
2036 if (!addedSomething) {
2037 info.addSpacer(-opad);
2038 }
2039 }
2040
2041 public String getImproveDialogTitle() {
2042 return "Improving " + getSpec().getName();
2043 }
2044
2045 public String getImproveSoundId() {
2047 }
2048
2050 return false;
2051 }
2052
2055 }
2056
2058 return "Improvements";
2059 }
2060
2062 if (!canImproveToIncreaseProduction()) return;
2063 if (!isImproved()) return;
2064
2065 int bonus = getImproveProductionBonus();
2066 if (bonus <= 0) return;
2067
2069 }
2070
2071 public void addImprovedSection(IndustryTooltipMode mode, TooltipMakerAPI tooltip, boolean expanded) {
2072
2073 if (!isImproved()) return;
2074
2075 float opad = 10f;
2076
2077
2078 tooltip.addSectionHeading("Improvements made", Misc.getStoryOptionColor(),
2080
2081 tooltip.addSpacer(opad);
2082 addImproveDesc(tooltip, ImprovementDescriptionMode.INDUSTRY_TOOLTIP);
2083
2084// String noun = "industry";
2085// if (isStructure()) noun = "structure";
2086// tooltip.addPara("You've made improvements to this " + noun + ".",
2087// Misc.getStoryOptionColor(), opad);
2088
2089 }
2090
2091
2092 public RaidDangerLevel adjustCommodityDangerLevel(String commodityId, RaidDangerLevel level) {
2093 return level;
2094 }
2095
2096 public RaidDangerLevel adjustItemDangerLevel(String itemId, String data, RaidDangerLevel level) {
2097 return level;
2098 }
2099
2100 public int adjustMarineTokensToRaidItem(String itemId, String data, int marineTokens) {
2101 return marineTokens;
2102 }
2103
2104
2105 public boolean canInstallAICores() {
2106 return true;
2107 }
2108
2109// public List<InstallableIndustryItemPlugin> getInstallableItems() {
2110// return new ArrayList<InstallableIndustryItemPlugin>();
2111//}
2112
2113 protected transient Boolean hasInstallableItems = null;
2114 public List<InstallableIndustryItemPlugin> getInstallableItems() {
2115 boolean found = false;
2116 if (hasInstallableItems != null) {
2117 found = hasInstallableItems;
2118 } else {
2120 if (spec.getParams() == null || spec.getParams().isEmpty()) continue;
2121 if (spec.getNewPluginInstance(null) instanceof GenericSpecialItemPlugin) {
2122 for (String id : spec.getParams().split(",")) {
2123 id = id.trim();
2124 if (id.equals(getId())) {
2125 found = true;
2126 break OUTER;
2127 }
2128 }
2129 }
2130 }
2131 hasInstallableItems = found;
2132 }
2133 ArrayList<InstallableIndustryItemPlugin> list = new ArrayList<InstallableIndustryItemPlugin>();
2134 if (found) {
2135 list.add(new GenericInstallableItemPlugin(this));
2136 }
2137 return list;
2138 }
2139
2140 public float getBuildProgress() {
2141 return buildProgress;
2142 }
2143
2144 public void setBuildProgress(float buildProgress) {
2145 this.buildProgress = buildProgress;
2146 }
2147
2148
2149
2150
2151}
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
static SettingsAPI getSettings()
Definition Global.java:57
static boolean CODEX_TOOLTIP_MODE
Definition Global.java:15
static SectorAPI getSector()
Definition Global.java:65
static void addToIndustryTooltip(Industry ind, IndustryTooltipMode mode, TooltipMakerAPI tooltip, float width, boolean expanded)
void modifyFlatAlways(String source, float value, String desc)
void modifyFlat(String source, float value)
void modifyMult(String source, float value)
void modifyMultAlways(String source, float value, String desc)
boolean reportPlayerAwareOfIndustry(String industryId, boolean withSave)
void addImproveDesc(TooltipMakerAPI info, ImprovementDescriptionMode mode)
List< Pair< String, Integer > > getAllDeficit(String ... commodityIds)
List< InstallableIndustryItemPlugin > getInstallableItems()
RaidDangerLevel adjustCommodityDangerLevel(String commodityId, RaidDangerLevel level)
void addInstalledItemsSection(IndustryTooltipMode mode, TooltipMakerAPI tooltip, boolean expanded)
void supply(String modId, String commodityId, int quantity, String desc)
Map< String, MutableCommodityQuantity > supply
void demand(int index, String commodityId, int quantity, String desc)
void addRightAfterDescriptionSection(TooltipMakerAPI tooltip, IndustryTooltipMode mode)
void supply(String commodityId, int quantity, String desc)
void createTooltip(IndustryTooltipMode mode, TooltipMakerAPI tooltip, boolean expanded)
void addStabilityPostDemandSection(TooltipMakerAPI tooltip, boolean hasDemand, IndustryTooltipMode mode)
void addAICoreSection(TooltipMakerAPI tooltip, String coreId, AICoreDescriptionMode mode)
void addImprovedSection(IndustryTooltipMode mode, TooltipMakerAPI tooltip, boolean expanded)
int adjustMarineTokensToRaidItem(String itemId, String data, int marineTokens)
boolean hasPostDemandSection(boolean hasDemand, IndustryTooltipMode mode)
void addAlphaCoreDescription(TooltipMakerAPI tooltip, AICoreDescriptionMode mode)
void supply(int index, String commodityId, int quantity, String desc)
void addPostDemandSection(TooltipMakerAPI tooltip, boolean hasDemand, IndustryTooltipMode mode)
void addUnknownCoreDescription(String coreId, TooltipMakerAPI tooltip, AICoreDescriptionMode mode)
boolean addNonAICoreInstalledItems(IndustryTooltipMode mode, TooltipMakerAPI tooltip, boolean expanded)
void addAICoreSection(TooltipMakerAPI tooltip, AICoreDescriptionMode mode)
void addPostDescriptionSection(TooltipMakerAPI tooltip, IndustryTooltipMode mode)
CargoAPI getCargoForInteractionMode(MarketInteractionMode mode)
void demand(String modId, String commodityId, int quantity, String desc)
void addGammaCoreDescription(TooltipMakerAPI tooltip, AICoreDescriptionMode mode)
void addGroundDefensesImpactSection(TooltipMakerAPI tooltip, float bonus, String ...commodities)
void addPostUpkeepSection(TooltipMakerAPI tooltip, IndustryTooltipMode mode)
Map< String, MutableCommodityQuantity > demand
void notifyBeingRemoved(MarketInteractionMode mode, boolean forUpgrade)
void addPostSupplySection(TooltipMakerAPI tooltip, boolean hasSupply, IndustryTooltipMode mode)
void demand(String commodityId, int quantity, String desc)
RaidDangerLevel adjustItemDangerLevel(String itemId, String data, RaidDangerLevel level)
Pair< String, Integer > getMaxDeficit(String ... commodityIds)
void applyDeficitToProduction(int index, Pair< String, Integer > deficit, String ... commodities)
void addBetaCoreDescription(TooltipMakerAPI tooltip, AICoreDescriptionMode mode)
static Map< String, InstallableItemEffect > ITEM_EFFECTS
static final String MARKET_NO_INDUSTRIES_ALLOWED
Definition Tags.java:109
static String getIndustryEntryId(String industryId)
static Color getStoryOptionColor()
Definition Misc.java:782
static Color getTextColor()
Definition Misc.java:839
static String getDGSCredits(float num)
Definition Misc.java:1390
static String getWithDGS(float num)
Definition Misc.java:1381
static int getNumImprovedIndustries(MarketAPI market)
Definition Misc.java:5268
static Color getStoryDarkColor()
Definition Misc.java:773
static String ucFirst(String str)
Definition Misc.java:559
static Color getNegativeHighlightColor()
Definition Misc.java:802
static CargoAPI getStorageCargo(MarketAPI market)
Definition Misc.java:4307
static float getRoundedValueFloat(float value)
Definition Misc.java:661
static Color getBasePlayerColor()
Definition Misc.java:833
static Color getGrayColor()
Definition Misc.java:826
static int getNumIndustries(MarketAPI market)
Definition Misc.java:5248
static Color getHighlightColor()
Definition Misc.java:792
static int getMaxIndustries(MarketAPI market)
Definition Misc.java:5244
static Color getPositiveHighlightColor()
Definition Misc.java:822
static String getRoundedValue(float value)
Definition Misc.java:647
SpecialItemSpecAPI getSpecialItemSpec(String itemId)
IndustrySpecAPI getIndustrySpec(String industryId)
CommoditySpecAPI getCommoditySpec(String commodityId)
List< SpecialItemSpecAPI > getAllSpecialItemSpecs()
void addSpecial(SpecialItemData data, float quantity)
void addCommodity(String commodityId, float quantity)
void addTransientImmigrationModifier(MarketImmigrationModifier mod)
CommodityOnMarketAPI getCommodityData(String commodityId)
void setSuppressedConditions(LinkedHashSet< String > suppressedConditions)
MutableStatWithTempMods getStability()
LinkedHashSet< String > getSuppressedConditions()
void removeIndustry(String id, MarketInteractionMode mode, boolean forUpgrade)
void setRetainSuppressedConditionsSetWhenEmpty(Boolean retainSuppressedConditionsSetWhenEmpty)
void removeTransientImmigrationModifier(MarketImmigrationModifier mod)
List< CommodityOnMarketAPI > getAllCommodities()
void set(String key, Object value)
boolean is(String key, Object value)
String performTokenReplacement(String ruleId, String text, SectorEntityToken entity, Map< String, MemoryAPI > memoryMap)
MutableCharacterStatsAPI getStats()
void addItemDescription(Industry industry, TooltipMakerAPI text, SpecialItemData data, InstallableItemDescriptionMode mode)
Industry getNewPluginInstance(MarketAPI market)
void setHighlight(int start, int end)
void setHighlightColors(Color ... colors)
void addStatModGrid(float width, float valueWidth, float valuePad, float pad, MutableStat stat)
void addIcons(CommodityOnMarketAPI com, int num, IconRenderMode mode)
LabelAPI addPara(String format, float pad, Color hl, String... highlights)
UIComponentAPI addSpacer(float height)
TooltipMakerAPI beginImageWithText(String spriteName, float imageHeight)
LabelAPI addSectionHeading(String str, Alignment align, float pad)
void setCodexEntryId(String codexEntryId)
UIPanelAPI addImageWithText(float pad)