Starsector API
Loading...
Searching...
No Matches
StandardLuddicPathActivityCause2.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.events;
2
3import java.awt.Color;
4import java.util.LinkedHashSet;
5import java.util.List;
6import java.util.Set;
7
8import com.fs.starfarer.api.Global;
9import com.fs.starfarer.api.campaign.StarSystemAPI;
10import com.fs.starfarer.api.campaign.econ.MarketAPI;
11import com.fs.starfarer.api.impl.campaign.ids.Factions;
12import com.fs.starfarer.api.impl.campaign.intel.bases.LuddicPathBaseIntel;
13import com.fs.starfarer.api.impl.campaign.intel.bases.LuddicPathBaseManager;
14import com.fs.starfarer.api.impl.campaign.intel.bases.LuddicPathCellsIntel;
15import com.fs.starfarer.api.impl.campaign.rulecmd.HA_CMD;
16import com.fs.starfarer.api.ui.TooltipMakerAPI;
17import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;
18import com.fs.starfarer.api.util.Misc;
19
21
25
26 @Override
27 public TooltipCreator getTooltip() {
28 return new BaseFactorTooltip() {
29 public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam) {
30 float opad = 10f;
31 tooltip.addPara("Use of advanced technology and AI cores attracts the attention of Pathers.", 0f,
32 Misc.getHighlightColor(), "advanced technology", "AI cores");
33
34 Set<LuddicPathBaseIntel> seen = new LinkedHashSet<LuddicPathBaseIntel>();
35 for (MarketAPI market : Misc.getPlayerMarkets(false)) {
36 LuddicPathBaseIntel base = LuddicPathCellsIntel.getClosestBase(market);
37 if (base == null) continue;
38
39 if (seen.contains(base)) continue;
40
41 LuddicPathCellsIntel cells = LuddicPathCellsIntel.getCellsForMarket(market);
42 if (cells == null || cells.isSleeper()) continue;
43
44 seen.add(base);
45
46 Color h = Misc.getHighlightColor();
47 String system = "";
48 if (base.isPlayerVisible()) {
49 system = " located in the " + base.getSystem().getNameWithLowercaseTypeShort() + "";
50 }
51 tooltip.addPara("Active Pather cells on some of your colonies are being supported "
52 + "by a Pather base" + system + ". %s "
53 + "will reduce the level of Pather fleet actvity.", opad, h,
54 "Dealing with this base");
55 break;
56 }
57
58 for (MarketAPI market : Misc.getPlayerMarkets(false)) {
59 LuddicPathCellsIntel cells = LuddicPathCellsIntel.getCellsForMarket(market);
60 if (cells == null) continue;
61 if (cells.getSleeperTimeout() > 0) {
62 tooltip.addPara("Pather cells on some of your colonies have been disrupted, reducing "
63 + "the Pather interest contribution from these colonies to event progress.", opad,
64 Misc.getPositiveHighlightColor(), "disrupted");
65 break;
66 }
67
68 }
69 }
70 };
71 }
72
73 @Override
74 public boolean shouldShow() {
75 return getProgress() != 0 || HA_CMD.playerHasPatherAgreement();
76 }
77
78 @Override
79 public String getProgressStr() {
80 if (HA_CMD.playerHasPatherAgreement()) return EventFactor.NEGATED_FACTOR_PROGRESS;
81 return super.getProgressStr();
82 }
83
84 @Override
86 if (HA_CMD.playerHasPatherAgreement()) return Misc.getPositiveHighlightColor();
87 return super.getProgressColor(intel);
88 }
89
90 public int getProgress() {
91 if (HA_CMD.playerHasPatherAgreement()) return 0;
93
94 int progress = (int) Math.round(getTotalPatherInterest());
95
96 float unit = Global.getSettings().getFloat("patherProgressUnit");
97 float mult = Global.getSettings().getFloat("patherProgressMult");
98 //progress = 200;
99 int rem = progress;
100 float adjusted = 0;
101 while (rem > unit) {
102 adjusted += unit;
103 rem -= unit;
104 rem *= mult;
105 }
106 adjusted += rem;
107
108 int reduced = Math.round(adjusted);
109 if (progress > 0 && reduced < 1) reduced = 1;
110 progress = reduced;
111
112// int reduced = (int) Math.round(Math.pow(progress, 0.8f));
113// if (progress > 0 && reduced <= 0) reduced = 1;
114// progress = reduced;
115
116 return progress;
117 }
118
119 public String getDesc() {
120 return "Technology and AI core use";
121 }
122
123 public float getTotalPatherInterest() {
124 float total = 0f;
125 for (StarSystemAPI system : Misc.getPlayerSystems(false)) {
126 float noCells = Global.getSettings().getFloat("patherProgressMultNoCells");
127 float sleeperCells = Global.getSettings().getFloat("patherProgressMultSleeperCells");
128 float activeCells = Global.getSettings().getFloat("patherProgressMultActiveCells");
129
130// noCells = 0f;
131// sleeperCells = 0.25f;
132// activeCells = 1f;
133 total += getPatherInterest(system, noCells, sleeperCells, activeCells);
134 }
135 return total;
136 }
137
138 public static float getPatherInterest(StarSystemAPI system, float multIfNoCells, float multIfSleeper, float multIfActive) {
139 return getPatherInterest(system, multIfNoCells, multIfSleeper, multIfActive, false);
140 }
141 public static float getPatherInterest(StarSystemAPI system, float multIfNoCells, float multIfSleeper, float multIfActive, boolean countCellsOnly) {
142 float total = 0f;
143 List<MarketAPI> markets = Misc.getMarketsInLocation(system, Factions.PLAYER);
144 for (MarketAPI market : markets) {
145 float mult = 1f;
146 LuddicPathCellsIntel intel = LuddicPathCellsIntel.getCellsForMarket(market);
147 if (intel == null) {
148 mult = multIfNoCells;
149 } else if (intel.isSleeper()) {
150 mult = multIfSleeper;
151 } else {
152 mult = multIfActive;
153 }
154
155 float interest = LuddicPathBaseManager.getLuddicPathMarketInterest(market);
156 if (countCellsOnly) interest = 1f;
157 total += (interest * mult);
158 }
159 return total;
160 }
161
162
163 public float getMagnitudeContribution(StarSystemAPI system) {
164 if (HA_CMD.playerHasPatherAgreement()) return 0f;
166
167 List<MarketAPI> markets = Misc.getMarketsInLocation(system, Factions.PLAYER);
168
169// float noCells = Global.getSettings().getFloat("luddicPathNoCellsInterestMult");
170// float sleeperCells = Global.getSettings().getFloat("luddicPathSleeperInterestMult");
171// float activeCells = Global.getSettings().getFloat("luddicPathActiveInterestMult");
172
173 float perSleeperBase = Global.getSettings().getFloat("luddicPathSleeperCellsBase");
174 float perSleeperSize = Global.getSettings().getFloat("luddicPathSleeperCellsPerSize");
175 float perActiveBase = Global.getSettings().getFloat("luddicPathActiveCellsBase");
176 float perActiveSize = Global.getSettings().getFloat("luddicPathActiveCellsPerSize");
177 float perPointOfInterest = Global.getSettings().getFloat("luddicPathPerPointOfInterest");
178
179 float max = 0f;
180 for (MarketAPI market : markets) {
181 LuddicPathCellsIntel intel = LuddicPathCellsIntel.getCellsForMarket(market);
182 if (intel == null) continue;
183
184 float curr = 0f;
185 if (intel.isSleeper()) {
186 curr += perSleeperBase + market.getSize() * perSleeperSize;
187 } else {
188 curr += perActiveBase + market.getSize() * perActiveSize;
189 }
190
191 float interest = LuddicPathBaseManager.getLuddicPathMarketInterest(market);
192 curr += interest * perPointOfInterest;
193
194 if (curr >= max) {
195 max = curr;
196 }
197 }
198
199 max = Math.round(max * 100f) / 100f;
200
201 return max;
202 }
203
204}
static SettingsAPI getSettings()
Definition Global.java:51
static float getPatherInterest(StarSystemAPI system, float multIfNoCells, float multIfSleeper, float multIfActive, boolean countCellsOnly)
static float getPatherInterest(StarSystemAPI system, float multIfNoCells, float multIfSleeper, float multIfActive)