1package com.fs.starfarer.api.impl.campaign.econ.impl;
7import org.lwjgl.util.vector.Vector2f;
9import com.fs.starfarer.api.Global;
10import com.fs.starfarer.api.campaign.SectorEntityToken;
11import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin;
12import com.fs.starfarer.api.campaign.econ.CommoditySpecAPI;
13import com.fs.starfarer.api.campaign.econ.MarketAPI;
14import com.fs.starfarer.api.campaign.econ.MarketImmigrationModifier;
15import com.fs.starfarer.api.campaign.listeners.ColonyOtherFactorsListener;
16import com.fs.starfarer.api.impl.PlanetSearchData.PlanetFilter;
17import com.fs.starfarer.api.impl.campaign.ids.Commodities;
18import com.fs.starfarer.api.impl.campaign.ids.Factions;
19import com.fs.starfarer.api.impl.campaign.ids.Industries;
20import com.fs.starfarer.api.impl.campaign.intel.misc.CryosleeperIntel;
21import com.fs.starfarer.api.impl.campaign.population.PopulationComposition;
22import com.fs.starfarer.api.loading.IndustrySpecAPI;
23import com.fs.starfarer.api.ui.TooltipMakerAPI;
24import com.fs.starfarer.api.util.Misc;
25import com.fs.starfarer.api.util.Pair;
52 return mode != IndustryTooltipMode.NORMAL ||
isFunctional();
57 if (mode != IndustryTooltipMode.NORMAL ||
isFunctional()) {
70 String lights =
"light-years";
71 if (dStr.equals(
"1")) lights =
"light-year";
72 tooltip.
addPara(
"Distance to nearest cryosleeper: %s " + lights +
", growth bonus multiplier: %s.",
75 "" + (
int)Math.round(distMult * 100f) +
"%");
77 if (mode != IndustryTooltipMode.NORMAL) {
78 tooltip.
addPara(
"If any demand is unmet, " +
79 "the maximum growth bonus is reduced by %s.",
83 tooltip.
addPara(
"%s growth bonus multiplier based on met demand. If any demand is unmet, " +
84 "the maximum bonus is reduced by %s.",
86 "" + (
int)Math.round(demandMult * 100f) +
"%",
91 tooltip.
addPara(
"Population growth: %s (max for colony size: %s)", opad, h,
"+" + Math.round(bonus),
"+" + Math.round(max));
121 return "Requires in-system cryosleeper";
158 String pre =
"Alpha-level AI core currently assigned. ";
159 if (mode == AICoreDescriptionMode.MANAGE_CORE_DIALOG_LIST || mode == AICoreDescriptionMode.INDUSTRY_TOOLTIP) {
160 pre =
"Alpha-level AI core. ";
163 String str =
"+" + (int)Math.round(a);
165 if (mode == AICoreDescriptionMode.INDUSTRY_TOOLTIP) {
168 text.
addPara(pre +
"Reduces upkeep cost by %s. Reduces demand by %s unit. " +
169 "%s population growth.", 0f, highlight,
176 tooltip.
addPara(pre +
"Reduces upkeep cost by %s. Reduces demand by %s unit. " +
177 "%s population growth.", opad, highlight,
194 String str =
"" + (int)Math.round(a);
196 if (mode == ImprovementDescriptionMode.INDUSTRY_TOOLTIP) {
197 info.
addPara(
"Population growth increased by %s.", 0f, highlight,str);
199 info.
addPara(
"Increases population growth by %s.", 0f, highlight,str);
203 super.addImproveDesc(info, mode);
209 float minDist = Float.MAX_VALUE;
220 if (dist < minDist) {
227 if (nearest ==
null)
return null;
235 if (p ==
null)
return 0f;
251 float def = deficit.
two;
255 if (def > 0 &&
demand > 0) {
285 String lights =
"light-years";
286 if (dStr.equals(
"1")) lights =
"light-year";
289 text.
addPara(
"The nearest cryosleeper is located in the " +
290 p.
one.getContainingLocation().getNameWithLowercaseType() +
", %s " + lights +
" away. The maximum " +
291 "range at which sleepers can be safely brought over for revival is %s light-years.",
296 text.
addPara(
"The nearest cryosleeper is located in the " +
297 p.
one.getContainingLocation().getNameWithLowercaseType() +
", %s " + lights +
" away, allowing " +
298 "a Cryorevival Facility built here to operate at %s effectiveness.",
301 "" + (
int)Math.round(distMult * 100f) +
"%");
306 public String getOtherFactorId() {
307 return "cryosleeper";
310 public String getOtherFactorButtonText() {
311 return "Domain-era Cryosleeper within range";
315 public boolean accept(SectorEntityToken entity, Map<String, String> params) {
316 if (!params.containsKey(getOtherFactorId()))
return true;
318 if (entity.getMarket() ==
null)
return false;
320 Pair<SectorEntityToken, Float> p = Cryorevival.getNearestCryosleeper(entity.getLocationInHyperspace(),
false);
321 if (p ==
null || p.two > Cryorevival.MAX_BONUS_DIST_LY)
return false;
326 public boolean shouldShow() {
327 return Global.getSector().getIntelManager().getIntelCount(CryosleeperIntel.class,
true) > 0;
330 public void createTooltip(TooltipMakerAPI info,
float width, String param) {
332 Color h = Misc.getHighlightColor();
333 IndustrySpecAPI
spec = Global.getSettings().getIndustrySpec(Industries.CRYOREVIVAL);
334 info.addTitle(
"Cryosleeper");
335 info.addPara(
"Only show planets within %s light-years of a Domain-era Cryosleeper. Colonies "
336 +
"within range can build a %s and benefit from hugely increased population growth.",
337 opad, h,
"" + (
int)Math.round(Cryorevival.MAX_BONUS_DIST_LY),
spec.
getName());
static SettingsAPI getSettings()
static SectorAPI getSector()
MutableStat getQuantity()
void modifyFlat(String source, float value)
static int DEMAND_REDUCTION
String getImprovementsDescForModifiers()
MutableCommodityQuantity getDemand(String id)
Map< String, MutableCommodityQuantity > demand
String getNameForModifier()
transient IndustrySpecAPI spec
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()
static final String ALPHA_CORE
static final String ORGANICS
static final String SLEEPER
SectorEntityToken getEntity()
void add(String id, float value)
static float getDistanceLY(SectorEntityToken from, SectorEntityToken to)
static Color getHighlightColor()
static String getRoundedValueMaxOneAfterDecimal(float value)
CommoditySpecAPI getCommoditySpec(String commodityId)
IntelManagerAPI getIntelManager()
Vector2f getLocationInHyperspace()
MemoryAPI getMemoryWithoutUpdate()
List< IntelInfoPlugin > getIntel()
Vector2f getLocationInHyperspace()
boolean contains(String key)