Starsector API
Loading...
Searching...
No Matches
Waystation.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.econ.impl;
2
3import java.awt.Color;
4
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;
17
18
19
20public class Waystation extends BaseIndustry {
21
22 public static float UPKEEP_MULT_PER_DEFICIT = 0.1f;
23 public static float BASE_ACCESSIBILITY = 0.1f;
24
25 public static float IMPROVE_ACCESSIBILITY = 0.2f;
26
27 public static float ALPHA_CORE_ACCESSIBILITY = 0.2f;
28
29
30 public void apply() {
31 super.apply(true);
32
33 int size = market.getSize();
34
35 demand(Commodities.FUEL, size);
37 demand(Commodities.CREW, size);
38
41
42 String desc = getNameForModifier();
43
44// Pair<String, Integer> deficit = getUpkeepAffectingDeficit();
45// if (deficit.two > 0) {
46// float loss = getUpkeepPenalty(deficit);
47// getUpkeep().modifyMult("deficit", 1f + loss, getDeficitText(deficit.one));
48// } else {
49// getUpkeep().unmodifyMult("deficit");
50// }
51
53
54 float a = BASE_ACCESSIBILITY;
55 if (a > 0) {
57 }
58
59 if (market.isPlayerOwned()) {
61 if (sub instanceof LocalResourcesSubmarketPlugin) {
63 float mult = Global.getSettings().getFloat("stockpileMultExcess");
69 }
70 }
71
73 if (intel != null && intel.isStageActive(Stage.SLIPSTREAM_DETECTION)) {
76 }
77
78
79 if (!isFunctional()) {
80 supply.clear();
81 unapply();
82 }
83 }
84
85 @Override
109
110 protected float getUpkeepPenalty(Pair<String, Integer> deficit) {
111 float loss = deficit.two * UPKEEP_MULT_PER_DEFICIT;
112 if (loss < 0) loss = 0;
113 return loss;
114 }
115
119
120
121 @Override
122 protected void addPostDescriptionSection(TooltipMakerAPI tooltip, IndustryTooltipMode mode) {
123 if (!market.isPlayerOwned()) return;
124
125 float opad = 10f;
126
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(),
130
131// tooltip.addPara("As long as demand is met, allows the colony to stockpile fuel, supplies, and crew, even " +
132// "if it does not produce them locally.", opad);
133 }
134
135 protected boolean hasPostDemandSection(boolean hasDemand, IndustryTooltipMode mode) {
136 return mode != IndustryTooltipMode.NORMAL || isFunctional();
137 }
138
139 @Override
140 protected void addPostDemandSection(TooltipMakerAPI tooltip, boolean hasDemand, IndustryTooltipMode mode) {
141 if (mode != IndustryTooltipMode.NORMAL || isFunctional()) {
142 MutableStat fake = new MutableStat(0);
143
144 String desc = getNameForModifier();
145 float a = BASE_ACCESSIBILITY;
146 if (a > 0) {
147 fake.modifyFlat(getModId(0), a, desc);
148 }
149 float total = a;
150 String totalStr = "+" + (int)Math.round(total * 100f) + "%";
151 Color h = Misc.getHighlightColor();
152 if (total < 0) {
154 totalStr = "" + (int)Math.round(total * 100f) + "%";
155 }
156 float opad = 10f;
157 float pad = 3f;
158 if (total >= 0) {
159 tooltip.addPara("Accessibility bonus: %s", opad, h, totalStr);
160 } else {
161 tooltip.addPara("Accessibility penalty: %s", opad, h, totalStr);
162 }
163
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);
166 }
167 }
168
169 @Override
182
183 @Override
195
196 @Override
200
201 protected void addAlphaCoreDescription(TooltipMakerAPI tooltip, AICoreDescriptionMode mode) {
202 float opad = 10f;
203 Color highlight = Misc.getHighlightColor();
204
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. ";
208 }
209 float a = ALPHA_CORE_ACCESSIBILITY;
210 String aStr = "" + (int)Math.round(a * 100f) + "%";
211
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,
217 "" + (int)((1f - UPKEEP_MULT) * 100f) + "%", "" + DEMAND_REDUCTION,
218 aStr);
219 tooltip.addImageWithText(opad);
220 return;
221 }
222
223 tooltip.addPara(pre + "Reduces upkeep cost by %s. Reduces demand by %s unit. " +
224 "Greatly increases stockpiles.", opad, highlight,
225 "" + (int)((1f - UPKEEP_MULT) * 100f) + "%", "" + DEMAND_REDUCTION,
226 aStr);
227
228 }
229
230
231 public boolean isAvailableToBuild() {
232 return market.hasSpaceport();
233 }
234
235 public String getUnavailableReason() {
236 return "Requires a functional spaceport";
237 }
238
239
240 @Override
241 public boolean canImprove() {
242 return true;
243 }
244
253
254 public void addImproveDesc(TooltipMakerAPI info, ImprovementDescriptionMode mode) {
255 float opad = 10f;
256 Color highlight = Misc.getHighlightColor();
257
258 float a = IMPROVE_ACCESSIBILITY;
259 String aStr = "" + (int)Math.round(a * 100f) + "%";
260
261 if (mode == ImprovementDescriptionMode.INDUSTRY_TOOLTIP) {
262 info.addPara("Accessibility increased by %s.", 0f, highlight, aStr);
263 } else {
264 info.addPara("Increases accessibility by %s.", 0f, highlight, aStr);
265 }
266
267 info.addSpacer(opad);
268 super.addImproveDesc(info, mode);
269 }
270}
271
272
273
274
static SettingsAPI getSettings()
Definition Global.java:57
void modifyFlat(String source, float value)
void modifyFlat(String source, float value)
Map< String, MutableCommodityQuantity > supply
Map< String, MutableCommodityQuantity > demand
Pair< String, Integer > getMaxDeficit(String ... commodityIds)
void addAlphaCoreDescription(TooltipMakerAPI tooltip, AICoreDescriptionMode mode)
void addPostDescriptionSection(TooltipMakerAPI tooltip, IndustryTooltipMode mode)
void addPostDemandSection(TooltipMakerAPI tooltip, boolean hasDemand, IndustryTooltipMode mode)
float getUpkeepPenalty(Pair< String, Integer > deficit)
boolean hasPostDemandSection(boolean hasDemand, IndustryTooltipMode mode)
void addImproveDesc(TooltipMakerAPI info, ImprovementDescriptionMode mode)
static final String SLIPSTREAM_REVEAL_RANGE_LY_MOD
Definition Stats.java:35
static Color getNegativeHighlightColor()
Definition Misc.java:802
static SubmarketPlugin getLocalResources(MarketAPI market)
Definition Misc.java:4302
static Color getHighlightColor()
Definition Misc.java:792
CommoditySpecAPI getCommoditySpec(String commodityId)
void setHasWaystation(boolean hasWaystation)
LabelAPI addPara(String format, float pad, Color hl, String... highlights)
UIComponentAPI addSpacer(float height)
TooltipMakerAPI beginImageWithText(String spriteName, float imageHeight)
UIPanelAPI addImageWithText(float pad)