1package com.fs.starfarer.api.impl.campaign.econ.impl;
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.campaign.SubmarketPlugin;
7import com.fs.starfarer.api.campaign.econ.CommoditySpecAPI;
8import com.fs.starfarer.api.combat.MutableStat;
9import com.fs.starfarer.api.impl.campaign.ids.Commodities;
10import com.fs.starfarer.api.impl.campaign.ids.Stats;
11import com.fs.starfarer.api.impl.campaign.intel.events.ht.HyperspaceTopographyEventIntel;
12import com.fs.starfarer.api.impl.campaign.intel.events.ht.HyperspaceTopographyEventIntel.Stage;
13import com.fs.starfarer.api.impl.campaign.submarkets.LocalResourcesSubmarketPlugin;
14import com.fs.starfarer.api.ui.TooltipMakerAPI;
15import com.fs.starfarer.api.util.Misc;
16import com.fs.starfarer.api.util.Pair;
33 int size =
market.getSize();
35 demand(Commodities.FUEL, size);
36 demand(Commodities.SUPPLIES, size);
37 demand(Commodities.CREW, size);
39 demand(Commodities.VOLATILES, 1);
40 demand(Commodities.RARE_METALS, 1);
52 market.setHasWaystation(
true);
59 if (
market.isPlayerOwned()) {
60 SubmarketPlugin sub = Misc.getLocalResources(
market);
61 if (sub instanceof LocalResourcesSubmarketPlugin) {
62 LocalResourcesSubmarketPlugin lr = (LocalResourcesSubmarketPlugin) sub;
64 lr.getStockpilingBonus(Commodities.FUEL).modifyFlat(
getModId(0), size * mult);
65 lr.getStockpilingBonus(Commodities.SUPPLIES).modifyFlat(
getModId(0), size * mult);
66 lr.getStockpilingBonus(Commodities.CREW).modifyFlat(
getModId(0), size * mult);
67 lr.getStockpilingBonus(Commodities.VOLATILES).modifyFlat(
getModId(0), 1f * mult);
68 lr.getStockpilingBonus(Commodities.RARE_METALS).modifyFlat(
getModId(0), 1f * mult);
72 HyperspaceTopographyEventIntel intel = HyperspaceTopographyEventIntel.get();
73 if (intel !=
null && intel.isStageActive(Stage.SLIPSTREAM_DETECTION)) {
74 market.getStats().getDynamic().getMod(Stats.SLIPSTREAM_REVEAL_RANGE_LY_MOD).modifyFlat(
89 market.setHasWaystation(
false);
94 market.getStats().getDynamic().getMod(Stats.SLIPSTREAM_REVEAL_RANGE_LY_MOD).unmodifyFlat(
getModId(0));
96 if (
market.isPlayerOwned()) {
97 SubmarketPlugin sub = Misc.getLocalResources(
market);
98 if (sub instanceof LocalResourcesSubmarketPlugin) {
99 LocalResourcesSubmarketPlugin lr = (LocalResourcesSubmarketPlugin) sub;
101 lr.getStockpilingBonus(Commodities.FUEL).unmodifyFlat(
getModId(0));
102 lr.getStockpilingBonus(Commodities.SUPPLIES).unmodifyFlat(
getModId(0));
103 lr.getStockpilingBonus(Commodities.CREW).unmodifyFlat(
getModId(0));
104 lr.getStockpilingBonus(Commodities.VOLATILES).unmodifyFlat(
getModId(0));
105 lr.getStockpilingBonus(Commodities.RARE_METALS).unmodifyFlat(
getModId(0));
112 if (loss < 0) loss = 0;
117 return getMaxDeficit(Commodities.FUEL, Commodities.SUPPLIES, Commodities.CREW);
123 if (!
market.isPlayerOwned())
return;
127 tooltip.addPara(
"Increases the range at which slipstreams are detected around the colony by %s, once "
128 +
"the capability to do so is available.", opad, Misc.getHighlightColor(),
129 "" + (
int)HyperspaceTopographyEventIntel.WAYSTATION_BONUS);
136 return mode != IndustryTooltipMode.NORMAL ||
isFunctional();
141 if (mode != IndustryTooltipMode.NORMAL ||
isFunctional()) {
142 MutableStat fake =
new MutableStat(0);
147 fake.modifyFlat(
getModId(0), a, desc);
150 String totalStr =
"+" + (int)Math.round(total * 100f) +
"%";
151 Color h = Misc.getHighlightColor();
153 h = Misc.getNegativeHighlightColor();
154 totalStr =
"" + (int)Math.round(total * 100f) +
"%";
159 tooltip.addPara(
"Accessibility bonus: %s", opad, h, totalStr);
161 tooltip.addPara(
"Accessibility penalty: %s", opad, h, totalStr);
164 tooltip.addPara(
"As long as demand is met, allows the colony to stockpile fuel, supplies, and crew, even " +
165 "if it does not produce them locally. The stockpile levels exceed those generated by equivalent local production.", opad);
171 if (
market.isPlayerOwned()) {
172 SubmarketPlugin sub = Misc.getLocalResources(
market);
173 if (sub instanceof LocalResourcesSubmarketPlugin) {
175 LocalResourcesSubmarketPlugin lr = (LocalResourcesSubmarketPlugin) sub;
176 lr.getStockpilingBonus(Commodities.FUEL).modifyFlat(
getModId(1), bonus);
177 lr.getStockpilingBonus(Commodities.SUPPLIES).modifyFlat(
getModId(1), bonus);
178 lr.getStockpilingBonus(Commodities.CREW).modifyFlat(
getModId(1), bonus);
185 if (
market.isPlayerOwned()) {
186 SubmarketPlugin sub = Misc.getLocalResources(
market);
187 if (sub instanceof LocalResourcesSubmarketPlugin) {
188 LocalResourcesSubmarketPlugin lr = (LocalResourcesSubmarketPlugin) sub;
189 lr.getStockpilingBonus(Commodities.FUEL).unmodifyFlat(
getModId(1));
190 lr.getStockpilingBonus(Commodities.SUPPLIES).unmodifyFlat(
getModId(1));
191 lr.getStockpilingBonus(Commodities.CREW).unmodifyFlat(
getModId(1));
203 Color highlight = Misc.getHighlightColor();
205 String pre =
"Alpha-level AI core currently assigned. ";
206 if (mode == AICoreDescriptionMode.MANAGE_CORE_DIALOG_LIST || mode == AICoreDescriptionMode.INDUSTRY_TOOLTIP) {
207 pre =
"Alpha-level AI core. ";
210 String aStr =
"" + (int)Math.round(a * 100f) +
"%";
212 if (mode == AICoreDescriptionMode.INDUSTRY_TOOLTIP) {
214 TooltipMakerAPI text = tooltip.beginImageWithText(coreSpec.getIconName(), 48);
215 text.addPara(pre +
"Reduces upkeep cost by %s. Reduces demand by %s unit. " +
216 "Greatly increases stockpiles.", 0f, highlight,
219 tooltip.addImageWithText(opad);
223 tooltip.addPara(pre +
"Reduces upkeep cost by %s. Reduces demand by %s unit. " +
224 "Greatly increases stockpiles.", opad, highlight,
232 return market.hasSpaceport();
236 return "Requires a functional spaceport";
254 public void addImproveDesc(TooltipMakerAPI info, ImprovementDescriptionMode mode) {
256 Color highlight = Misc.getHighlightColor();
259 String aStr =
"" + (int)Math.round(a * 100f) +
"%";
261 if (mode == ImprovementDescriptionMode.INDUSTRY_TOOLTIP) {
262 info.addPara(
"Accessibility increased by %s.", 0f, highlight, aStr);
264 info.addPara(
"Increases accessibility by %s.", 0f, highlight, aStr);
267 info.addSpacer(opad);
268 super.addImproveDesc(info, mode);
static SettingsAPI getSettings()
static int DEMAND_REDUCTION
Map< String, MutableCommodityQuantity > supply
String getImprovementsDescForModifiers()
Map< String, MutableCommodityQuantity > demand
String getNameForModifier()
MutableStat demandReduction
Pair< String, Integer > getMaxDeficit(String ... commodityIds)
void addAlphaCoreDescription(TooltipMakerAPI tooltip, AICoreDescriptionMode mode)
static float UPKEEP_MULT_PER_DEFICIT
void addPostDescriptionSection(TooltipMakerAPI tooltip, IndustryTooltipMode mode)
void applyAlphaCoreSupplyAndDemandModifiers()
String getUnavailableReason()
static float ALPHA_CORE_ACCESSIBILITY
void applyAlphaCoreModifiers()
void addPostDemandSection(TooltipMakerAPI tooltip, boolean hasDemand, IndustryTooltipMode mode)
boolean isAvailableToBuild()
void applyNoAICoreModifiers()
static float BASE_ACCESSIBILITY
static float IMPROVE_ACCESSIBILITY
Pair< String, Integer > getUpkeepAffectingDeficit()
float getUpkeepPenalty(Pair< String, Integer > deficit)
boolean hasPostDemandSection(boolean hasDemand, IndustryTooltipMode mode)
void addImproveDesc(TooltipMakerAPI info, ImprovementDescriptionMode mode)
void applyImproveModifiers()
CommoditySpecAPI getCommoditySpec(String commodityId)
float getFloat(String key)