1package com.fs.starfarer.api.impl.campaign.econ.impl;
5import org.lwjgl.util.vector.Vector2f;
7import com.fs.starfarer.api.Global;
8import com.fs.starfarer.api.campaign.SectorEntityToken;
9import com.fs.starfarer.api.campaign.econ.CommoditySpecAPI;
10import com.fs.starfarer.api.campaign.econ.MarketAPI;
11import com.fs.starfarer.api.campaign.econ.MarketImmigrationModifier;
12import com.fs.starfarer.api.campaign.listeners.ColonyOtherFactorsListener;
13import com.fs.starfarer.api.impl.campaign.ids.Commodities;
14import com.fs.starfarer.api.impl.campaign.ids.Factions;
15import com.fs.starfarer.api.impl.campaign.ids.Tags;
16import com.fs.starfarer.api.impl.campaign.population.PopulationComposition;
17import com.fs.starfarer.api.ui.TooltipMakerAPI;
18import com.fs.starfarer.api.util.Misc;
19import com.fs.starfarer.api.util.Pair;
36 demand(Commodities.ORGANICS, 10);
46 return mode != IndustryTooltipMode.NORMAL ||
isFunctional();
50 protected void addPostDemandSection(TooltipMakerAPI tooltip,
boolean hasDemand, IndustryTooltipMode mode) {
51 if (mode != IndustryTooltipMode.NORMAL ||
isFunctional()) {
52 Color h = Misc.getHighlightColor();
63 String dStr =
"" + Misc.getRoundedValueMaxOneAfterDecimal(p.two);
64 String lights =
"light-years";
65 if (dStr.equals(
"1")) lights =
"light-year";
66 tooltip.addPara(
"Distance to nearest cryosleeper: %s " + lights +
", growth bonus multiplier: %s.",
68 "" + Misc.getRoundedValueMaxOneAfterDecimal(p.two),
69 "" + (
int)Math.round(distMult * 100f) +
"%");
71 if (mode != IndustryTooltipMode.NORMAL) {
72 tooltip.addPara(
"If any demand is unmet, " +
73 "the maximum growth bonus is reduced by %s.",
77 tooltip.addPara(
"%s growth bonus multiplier based on met demand. If any demand is unmet, " +
78 "the maximum bonus is reduced by %s.",
80 "" + (
int)Math.round(demandMult * 100f) +
"%",
85 tooltip.addPara(
"Population growth: %s (max for colony size: %s)", opad, h,
"+" + Math.round(bonus),
"+" + Math.round(max));
115 return "Requires in-system cryosleeper";
123 if (Commodities.ALPHA_CORE.equals(
getAICoreId())) {
150 Color highlight = Misc.getHighlightColor();
152 String pre =
"Alpha-level AI core currently assigned. ";
153 if (mode == AICoreDescriptionMode.MANAGE_CORE_DIALOG_LIST || mode == AICoreDescriptionMode.INDUSTRY_TOOLTIP) {
154 pre =
"Alpha-level AI core. ";
157 String str =
"+" + (int)Math.round(a);
159 if (mode == AICoreDescriptionMode.INDUSTRY_TOOLTIP) {
161 TooltipMakerAPI text = tooltip.beginImageWithText(coreSpec.getIconName(), 48);
162 text.addPara(pre +
"Reduces upkeep cost by %s. Reduces demand by %s unit. " +
163 "%s population growth.", 0f, highlight,
166 tooltip.addImageWithText(opad);
170 tooltip.addPara(pre +
"Reduces upkeep cost by %s. Reduces demand by %s unit. " +
171 "%s population growth.", opad, highlight,
183 public void addImproveDesc(TooltipMakerAPI info, ImprovementDescriptionMode mode) {
185 Color highlight = Misc.getHighlightColor();
188 String str =
"" + (int)Math.round(a);
190 if (mode == ImprovementDescriptionMode.INDUSTRY_TOOLTIP) {
191 info.addPara(
"Population growth increased by %s.", 0f, highlight,str);
193 info.addPara(
"Increases population growth by %s.", 0f, highlight,str);
196 info.addSpacer(opad);
197 super.addImproveDesc(info, mode);
202 SectorEntityToken nearest =
null;
203 float minDist = Float.MAX_VALUE;
205 for (SectorEntityToken entity :
Global.
getSector().getCustomEntitiesWithTag(Tags.CRYOSLEEPER)) {
206 if (!usable || entity.getMemoryWithoutUpdate().contains(
"$usable")) {
207 float dist = Misc.getDistanceLY(locInHyper, entity.getLocationInHyperspace());
211 if (dist < minDist) {
218 if (nearest ==
null)
return null;
220 return new Pair<SectorEntityToken, Float>(nearest, minDist);
226 if (p ==
null)
return 0f;
240 Pair<String, Integer> deficit =
getMaxDeficit(Commodities.ORGANICS);
241 float demand =
getDemand(Commodities.ORGANICS).getQuantity().getModifiedValue();
242 float def = deficit.two;
246 if (def > 0 &&
demand > 0) {
262 public static class CryosleeperFactor
implements ColonyOtherFactorsListener {
263 public boolean isActiveFactorFor(SectorEntityToken entity) {
267 public void printOtherFactors(TooltipMakerAPI text, SectorEntityToken entity) {
272 Color h = Misc.getHighlightColor();
275 String dStr =
"" + Misc.getRoundedValueMaxOneAfterDecimal(p.two);
276 String lights =
"light-years";
277 if (dStr.equals(
"1")) lights =
"light-year";
280 text.addPara(
"The nearest cryosleeper is located in the " +
281 p.one.getContainingLocation().getNameWithLowercaseType() +
", %s " + lights +
" away. The maximum " +
282 "range at which sleepers can be safely brought over for revival is %s light-years.",
284 "" + Misc.getRoundedValueMaxOneAfterDecimal(p.two),
287 text.addPara(
"The nearest cryosleeper is located in the " +
288 p.one.getContainingLocation().getNameWithLowercaseType() +
", %s " + lights +
" away, allowing " +
289 "a Cryorevival Facility built here to operate at %s effectiveness.",
291 "" + Misc.getRoundedValueMaxOneAfterDecimal(p.two),
292 "" + (
int)Math.round(distMult * 100f) +
"%");
static SettingsAPI getSettings()
static SectorAPI getSector()
static int DEMAND_REDUCTION
String getImprovementsDescForModifiers()
MutableCommodityQuantity getDemand(String id)
Map< String, MutableCommodityQuantity > demand
String getNameForModifier()
MutableStat demandReduction
Pair< String, Integer > getMaxDeficit(String ... commodityIds)
float getMaxImmigrationBonus()
boolean isAvailableToBuild()
boolean hasPostDemandSection(boolean hasDemand, IndustryTooltipMode mode)
void applyNoAICoreModifiers()
void addPostDemandSection(TooltipMakerAPI tooltip, boolean hasDemand, IndustryTooltipMode mode)
String getUnavailableReason()
static float MAX_BONUS_DIST_LY
void addAlphaCoreDescription(TooltipMakerAPI tooltip, AICoreDescriptionMode mode)
void applyAlphaCoreModifiers()
static float IMPROVE_BONUS
static float ALPHA_CORE_BONUS
static float MAX_BONUS_WHEN_UNMET_DEMAND
void modifyIncoming(MarketAPI market, PopulationComposition incoming)
void applyAlphaCoreSupplyAndDemandModifiers()
float getDemandMetPopulationMult()
boolean showWhenUnavailable()
static float MIN_BONUS_MULT
static float getDistancePopulationMult(Vector2f locInHyper)
void addImproveDesc(TooltipMakerAPI info, ImprovementDescriptionMode mode)
static Pair< SectorEntityToken, Float > getNearestCryosleeper(Vector2f locInHyper, boolean usable)
float getImmigrationBonus()
CommoditySpecAPI getCommoditySpec(String commodityId)