Starsector API
Loading...
Searching...
No Matches
PirateActivityIntel.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.bases;
2
3import java.awt.Color;
4import java.util.Set;
5
6import com.fs.starfarer.api.Global;
7import com.fs.starfarer.api.campaign.FactionAPI;
8import com.fs.starfarer.api.campaign.SectorEntityToken;
9import com.fs.starfarer.api.campaign.StarSystemAPI;
10import com.fs.starfarer.api.campaign.econ.MarketAPI;
11import com.fs.starfarer.api.campaign.econ.MarketConditionAPI;
12import com.fs.starfarer.api.campaign.econ.MarketConditionPlugin;
13import com.fs.starfarer.api.impl.campaign.DebugFlags;
14import com.fs.starfarer.api.impl.campaign.ids.Conditions;
15import com.fs.starfarer.api.impl.campaign.ids.Factions;
16import com.fs.starfarer.api.impl.campaign.ids.Tags;
17import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin;
18import com.fs.starfarer.api.impl.campaign.intel.events.PiracyRespiteScript;
19import com.fs.starfarer.api.ui.Alignment;
20import com.fs.starfarer.api.ui.SectorMapAPI;
21import com.fs.starfarer.api.ui.TooltipMakerAPI;
22import com.fs.starfarer.api.util.Misc;
23
25
26 //protected MarketAPI market;
29
31 this.system = system;
32 this.source = source;
33
34
35 boolean hasPlayerMarkets = false;
37 hasPlayerMarkets |= curr.isPlayerOwned();
38 }
39 if (!hasPlayerMarkets) {
41 }
42
44
45
46 //Global.getSector().getIntelManager().queueIntel(this);
49 } else {
51 }
52 }
53
54 @Override
55 public boolean canMakeVisibleToPlayer(boolean playerInRelayRange) {
57 return super.canMakeVisibleToPlayer(playerInRelayRange);
58 }
59
60
62 return source;
63 }
64
65 @Override
66 protected void notifyEnded() {
67 super.notifyEnded();
69 }
70
71
72 @Override
73 protected void notifyEnding() {
74 super.notifyEnding();
75
77 if (curr.hasCondition(Conditions.PIRATE_ACTIVITY)) {
78 curr.removeCondition(Conditions.PIRATE_ACTIVITY);
79 }
80 }
81 }
82
83 @Override
84 protected void advanceImpl(float amount) {
85 super.advanceImpl(amount);
86
87 if (source.isEnding() || source.getTarget() != system) {
90 sendUpdateIfPlayerHasIntel(new Object(), false);
91 }
92 return;
93 }
94
96 if (curr.isPlayerOwned() && PiracyRespiteScript.get() != null) continue;
97
98 if (!curr.hasCondition(Conditions.PIRATE_ACTIVITY)) {
99 curr.addCondition(Conditions.PIRATE_ACTIVITY, source);
100 }
101 }
102 }
103
104 protected void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode) {
105
106 Color h = Misc.getHighlightColor();
107 Color g = Misc.getGrayColor();
108 float pad = 3f;
109 float opad = 10f;
110
111 float initPad = pad;
112 if (mode == ListInfoMode.IN_DESC) initPad = opad;
113
114 Color tc = getBulletColorForMode(mode);
115
116 bullet(info);
117 boolean isUpdate = getListInfoParam() != null;
118
119// info.addPara("Danger level: " + danger, initPad, tc, dangerColor, danger);
120// initPad = 0f;
121
122 unindent(info);
123 }
124
125 @Override
126 public void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode) {
127 Color c = getTitleColor(mode);
128 info.addPara(getName(), c, 0f);
129 addBulletPoints(info, mode);
130 }
131
132 @Override
133 public void createSmallDescription(TooltipMakerAPI info, float width, float height) {
134 Color h = Misc.getHighlightColor();
135 Color g = Misc.getGrayColor();
136 Color tc = Misc.getTextColor();
137 float pad = 3f;
138 float opad = 10f;
139
140 info.addImage(getFactionForUIColors().getLogo(), width, 128, opad);
141
142 info.addPara("Pirates have been targeting colonies and shipping " +
143 "in the " + system.getNameWithLowercaseType() + ".", opad);
144
145 if (source.isPlayerVisible()) {
146 //info.addPara("The pirates are based out of the " + source.getSystem().getNameWithLowercaseType() + ".", opad);
147 info.addPara("The pirates are based out of " +
148 source.getMarket().getName() + " in the " + source.getSystem().getNameWithLowercaseType() + ".", opad);
149 } else {
151 if (distLY < 10) {
152 info.addPara("The location of the pirate base is unknown, but it's likely to be somewhere nearby.", opad);
153 } else {
154 info.addPara("The location of the pirate base is unknown, but there are indications that it's quite distant.", opad);
155 }
156 }
157
158 info.addSectionHeading("Colonies affected", getFactionForUIColors().getBaseUIColor(),
159 getFactionForUIColors().getDarkUIColor(), Alignment.MID, opad);
160
161 //info.addPara("Colonies affected:", opad);
162
163 MarketConditionAPI condition = null;
164 float initPad = opad;
166 if (condition == null) {
167 condition = curr.getCondition(Conditions.PIRATE_ACTIVITY);
168 }
169
170 addMarketToList(info, curr, initPad, tc);
171 initPad = 0f;
172 }
173
174 if (condition != null) {
175 MarketConditionPlugin plugin = condition.getPlugin();
176// String text = condition.getSpec().getDesc();
177// Map<String, String> tokens = plugin.getTokenReplacements();
178// if (tokens != null) {
179// for (String token : tokens.keySet()) {
180// String value = tokens.get(token);
181// text = text.replaceAll("(?s)\\" + token, value);
182// }
183// }
184// if (!text.isEmpty()) {
185// info.addPara(text, opad);
186// }
187
188 ((PirateActivity)plugin).createTooltipAfterDescription(info, true);
189 }
190
191 }
192
193
195 return system;
196 }
197
198 @Override
199 public String getIcon() {
200 return Global.getSettings().getSpriteName("intel", "pirate_activity");
201 }
202
203 @Override
204 public Set<String> getIntelTags(SectorMapAPI map) {
205 Set<String> tags = super.getIntelTags(map);
206 tags.add(Factions.PIRATES);
207
209 tags.add(Tags.INTEL_COLONIES);
210 }
211
212 return tags;
213 }
214
215 public String getSortString() {
216 String base = Misc.ucFirst(getFactionForUIColors().getPersonNamePrefix());
217 return base + " C"; // so it goes after "Pirate Base"
218 }
219
220 public String getName() {
221 String base = "Pirate Activity";
222 if (isEnding()) {
223 return base + " - Over";
224 }
225 return base + " - " + system.getBaseName();
226 }
227
228 @Override
232
233 public String getSmallDescriptionTitle() {
234 return getName();
235 }
236
237 @Override
241
242
243 @Override
244 public String getCommMessageSound() {
245 return getSoundMinorMessage();
246 }
247
248
249}
250
251
252
253
254
255
256
static SettingsAPI getSettings()
Definition Global.java:57
static SectorAPI getSector()
Definition Global.java:65
void setPostingLocation(SectorEntityToken postingLocation)
void sendUpdateIfPlayerHasIntel(Object listInfoParam, TextPanelAPI textPanel)
static void addMarketToList(TooltipMakerAPI info, MarketAPI market, float pad)
void createSmallDescription(TooltipMakerAPI info, float width, float height)
PirateActivityIntel(StarSystemAPI system, PirateBaseIntel source)
static Color getTextColor()
Definition Misc.java:839
static float getDistanceLY(SectorEntityToken from, SectorEntityToken to)
Definition Misc.java:602
static List< MarketAPI > getMarketsInLocation(LocationAPI location, String factionId)
Definition Misc.java:936
static String ucFirst(String str)
Definition Misc.java:559
static Color getGrayColor()
Definition Misc.java:826
static Color getHighlightColor()
Definition Misc.java:792
String getSpriteName(String category, String id)
void addScript(EveryFrameScript script)
void removeScript(EveryFrameScript script)
void queueIntel(IntelInfoPlugin plugin, float maxCommQueueDays)
List< MarketAPI > getMarkets(LocationAPI loc)
void addImage(String spriteName, float pad)
LabelAPI addPara(String format, float pad, Color hl, String... highlights)
LabelAPI addSectionHeading(String str, Alignment align, float pad)