Starsector API
Loading...
Searching...
No Matches
PlanetaryShield.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.PlanetAPI;
7import com.fs.starfarer.api.campaign.econ.CommoditySpecAPI;
8import com.fs.starfarer.api.impl.campaign.ids.Conditions;
9import com.fs.starfarer.api.impl.campaign.ids.Stats;
10import com.fs.starfarer.api.impl.campaign.ids.Strings;
11import com.fs.starfarer.api.ui.TooltipMakerAPI;
12import com.fs.starfarer.api.util.Misc;
13
14
15
16public class PlanetaryShield extends BaseIndustry {
17
18 public static float DEFENSE_BONUS = 2f;
19
20 public static float ALPHA_CORE_BONUS = 0.5f;
21 public static float IMPROVE_DEFENSE_BONUS = 0.25f;
22
23 public void apply() {
24 super.apply(false);
25
26 int size = 5;
28
29 float bonus = DEFENSE_BONUS;
31 .modifyMult(getModId(), 1f + bonus, getNameForModifier());
32
33 if (isFunctional()) {
36 } else {
37 unapply();
38 }
39 }
40
41 public static void applyVisuals(PlanetAPI planet) {
42 if (planet == null) return;
43 planet.getSpec().setShieldTexture(Global.getSettings().getSpriteName("industry", "shield_texture"));
44 //planet.getSpec().setShieldThickness(0.07f);
45 //planet.getSpec().setShieldColor(new Color(255,0,0,255));
46 planet.getSpec().setShieldThickness(0.1f);
47 planet.getSpec().setShieldColor(new Color(255,255,255,175));
48 planet.applySpecChanges();
49 }
50
51 public static void unapplyVisuals(PlanetAPI planet) {
52 if (planet == null) return;
53 planet.getSpec().setShieldTexture(null);
54 planet.getSpec().setShieldThickness(0f);
55 planet.getSpec().setShieldColor(null);
56 planet.applySpecChanges();
57 }
58
59
60 @Override
69
70 @Override
71 public boolean isAvailableToBuild() {
73 return false;
74 }
76 }
77
78 @Override
79 public String getUnavailableReason() {
80 if (!super.isAvailableToBuild()) return super.getUnavailableReason();
81 return "Can not be built at a gas giant";
82 }
83
84 public boolean showWhenUnavailable() {
86 }
87
88 protected boolean hasPostDemandSection(boolean hasDemand, IndustryTooltipMode mode) {
89 return mode != IndustryTooltipMode.NORMAL || isFunctional();
90 }
91
92 @Override
93 protected void addPostDemandSection(TooltipMakerAPI tooltip, boolean hasDemand, IndustryTooltipMode mode) {
94 if (mode != IndustryTooltipMode.NORMAL || isFunctional()) {
95
96 float bonus = DEFENSE_BONUS;
97 addGroundDefensesImpactSection(tooltip, bonus, (String[])null);
98 }
99 }
100
101
102 @Override
107
108 @Override
112
113 @Override
117
118 protected void addAlphaCoreDescription(TooltipMakerAPI tooltip, AICoreDescriptionMode mode) {
119 float opad = 10f;
120 Color highlight = Misc.getHighlightColor();
121
122 String pre = "Alpha-level AI core currently assigned. ";
123 if (mode == AICoreDescriptionMode.MANAGE_CORE_DIALOG_LIST || mode == AICoreDescriptionMode.INDUSTRY_TOOLTIP) {
124 pre = "Alpha-level AI core. ";
125 }
126 float a = ALPHA_CORE_BONUS;
127 //String str = Strings.X + (int)Math.round(a * 100f) + "%";
128 String str = Strings.X + (1f + a) + "";
129
130 if (mode == AICoreDescriptionMode.INDUSTRY_TOOLTIP) {
132 TooltipMakerAPI text = tooltip.beginImageWithText(coreSpec.getIconName(), 48);
133 text.addPara(pre + "Reduces upkeep cost by %s. Reduces demand by %s unit. " +
134 "Increases ground defenses by %s.", 0f, highlight,
135 "" + (int)((1f - UPKEEP_MULT) * 100f) + "%", "" + DEMAND_REDUCTION,
136 str);
137 tooltip.addImageWithText(opad);
138 return;
139 }
140
141 tooltip.addPara(pre + "Reduces upkeep cost by %s. Reduces demand by %s unit. " +
142 "Increases ground defenses by %s.", opad, highlight,
143 "" + (int)((1f - UPKEEP_MULT) * 100f) + "%", "" + DEMAND_REDUCTION,
144 str);
145
146 }
147
148
149 @Override
150 public boolean canImprove() {
151 return true;
152 }
153
163
164 public void addImproveDesc(TooltipMakerAPI info, ImprovementDescriptionMode mode) {
165 float opad = 10f;
166 Color highlight = Misc.getHighlightColor();
167
168 float a = IMPROVE_DEFENSE_BONUS;
169 String str = Strings.X + (1f + a) + "";
170
171 if (mode == ImprovementDescriptionMode.INDUSTRY_TOOLTIP) {
172 info.addPara("Ground defenses increased by %s.", 0f, highlight, str);
173 } else {
174 info.addPara("Increases ground defenses by %s.", 0f, highlight, str);
175 }
176
177 info.addSpacer(opad);
178 super.addImproveDesc(info, mode);
179 }
180}
static SettingsAPI getSettings()
Definition Global.java:57
static SectorAPI getSector()
Definition Global.java:65
void modifyFlat(String source, float value)
void modifyMult(String source, float value)
void addGroundDefensesImpactSection(TooltipMakerAPI tooltip, float bonus, String ...commodities)
void addAlphaCoreDescription(TooltipMakerAPI tooltip, AICoreDescriptionMode mode)
void addPostDemandSection(TooltipMakerAPI tooltip, boolean hasDemand, IndustryTooltipMode mode)
boolean hasPostDemandSection(boolean hasDemand, IndustryTooltipMode mode)
void addImproveDesc(TooltipMakerAPI info, ImprovementDescriptionMode mode)
static Color getHighlightColor()
Definition Misc.java:792
String getSpriteName(String category, String id)
CommoditySpecAPI getCommoditySpec(String commodityId)
boolean knowsIndustry(String industryId)
void setShieldTexture(String shieldTexture)
void setShieldThickness(float shieldThickness)
LabelAPI addPara(String format, float pad, Color hl, String... highlights)
UIComponentAPI addSpacer(float height)
TooltipMakerAPI beginImageWithText(String spriteName, float imageHeight)
UIPanelAPI addImageWithText(float pad)