Starsector API
Loading...
Searching...
No Matches
PlanetaryShieldIntel.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.bar.events;
2
3import java.util.List;
4import java.util.Map;
5import java.util.Set;
6
7import java.awt.Color;
8
9import com.fs.starfarer.api.Global;
10import com.fs.starfarer.api.campaign.CampaignFleetAPI;
11import com.fs.starfarer.api.campaign.CargoAPI;
12import com.fs.starfarer.api.campaign.FactionAPI;
13import com.fs.starfarer.api.campaign.InteractionDialogAPI;
14import com.fs.starfarer.api.campaign.PlanetAPI;
15import com.fs.starfarer.api.campaign.SectorEntityToken;
16import com.fs.starfarer.api.campaign.econ.MarketAPI;
17import com.fs.starfarer.api.campaign.rules.MemoryAPI;
18import com.fs.starfarer.api.characters.PersonAPI;
19import com.fs.starfarer.api.impl.campaign.ids.Tags;
20import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin;
21import com.fs.starfarer.api.impl.campaign.rulecmd.AddRemoveCommodity;
22import com.fs.starfarer.api.ui.SectorMapAPI;
23import com.fs.starfarer.api.ui.TooltipMakerAPI;
24import com.fs.starfarer.api.util.Misc;
25import com.fs.starfarer.api.util.Misc.Token;
26
28
29 public static enum PSIStage {
30 TALK_TO_PILOT,
31 GO_TO_PLANET,
32 DONE,
33 ;
34 }
35
36 public static int FINISHED_XP = 20000;
37 public static int PAY_PILOT_XP = 5000;
38
39 protected PlanetAPI planet;
41
42 protected PSIStage stage;
43 protected int pilotCredits;
44
46 this.planet = planet;
47 this.event = event;
48
49 PersonAPI pilot = event.getPilot();
50 Misc.makeImportant(pilot, "psi");
51 MarketAPI market = event.getPilotMarket();
52 market.addPerson(pilot);
53 market.getCommDirectory().addPerson(pilot);
54
55 pilotCredits = 10000 + 1000 * Misc.random.nextInt(10);
56
57 pilot.getMemoryWithoutUpdate().set("$psi_isPilot", true);
58 pilot.getMemoryWithoutUpdate().set("$psi_eventRef", this);
60
61 //Misc.makeImportant(planet, "saci");
62 //cache.getMemoryWithoutUpdate().set("$saic_eventRef", this);
63 //Global.getSector().addScript(this);
64
65 stage = PSIStage.TALK_TO_PILOT;
66 }
67
68 @Override
69 protected void notifyEnded() {
70 super.notifyEnded();
72
73 PersonAPI pilot = event.getPilot();
74 MarketAPI market = event.getPilotMarket();
75 market.removePerson(pilot);
76 market.getCommDirectory().removePerson(pilot);
78 }
79
80
81
82 @Override
83 public boolean callEvent(String ruleId, InteractionDialogAPI dialog,
84 List<Token> params, Map<String, MemoryAPI> memoryMap) {
85 String action = params.get(0).getString(memoryMap);
86
88 CargoAPI cargo = playerFleet.getCargo();
89 //MemoryAPI memory = planet.getMemoryWithoutUpdate();
90
91 PersonAPI pilot = event.getPilot();
92 MarketAPI market = event.getPilotMarket();
93
94 if (action.equals("prepare")) {
95 pilot.getMemoryWithoutUpdate().set("$psi_credits", Misc.getDGSCredits(pilotCredits), 0);
96 pilot.getMemoryWithoutUpdate().set("$psi_playerCredits", Misc.getDGSCredits(cargo.getCredits().get()), 0);
97 } else if (action.equals("canPay")) {
98 return cargo.getCredits().get() >= pilotCredits;
99 } else if (action.equals("payPilot")) {
100 market.removePerson(pilot);
101 market.getCommDirectory().removePerson(pilot);
102
106
107 Misc.makeImportant(planet, "psi");
108 stage = PSIStage.GO_TO_PLANET;
109 sendUpdate(PSIStage.GO_TO_PLANET, dialog.getTextPanel());
110 }
111
112 return true;
113 }
114
115 @Override
116 public void endAfterDelay() {
117 stage = PSIStage.DONE;
119 super.endAfterDelay();
120 }
121
122 @Override
123 protected void notifyEnding() {
124 super.notifyEnding();
125 }
126
127
128 protected void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode) {
129
130 Color h = Misc.getHighlightColor();
131 Color g = Misc.getGrayColor();
132 float pad = 3f;
133 float opad = 10f;
134
135 float initPad = pad;
136 if (mode == ListInfoMode.IN_DESC) initPad = opad;
137
138 Color tc = getBulletColorForMode(mode);
139
140 bullet(info);
141 boolean isUpdate = getListInfoParam() != null;
142
143 MarketAPI market = event.getPilotMarket();
144
145 if (stage == PSIStage.TALK_TO_PILOT) {
146 info.addPara("Talk to the pilot at %s", initPad, tc, market.getFaction().getBaseUIColor(), market.getName());
147 } else if (stage == PSIStage.GO_TO_PLANET) {
148 info.addPara("Explore the planet", tc, initPad);
149 }
150
151 initPad = 0f;
152
153 unindent(info);
154 }
155
156
157 @Override
158 public void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode) {
159 Color c = getTitleColor(mode);
161 info.addPara(getName(), c, 0f);
162 info.setParaFontDefault();
163 addBulletPoints(info, mode);
164
165 }
166
167 @Override
168 public void createSmallDescription(TooltipMakerAPI info, float width, float height) {
169 Color h = Misc.getHighlightColor();
170 Color g = Misc.getGrayColor();
171 Color tc = Misc.getTextColor();
172 float pad = 3f;
173 float opad = 10f;
174
175 if (stage == PSIStage.TALK_TO_PILOT) {
176 info.addPara("An old spacer told you a tale about a mysterious red planet. " +
177 "The pilot - the only other survivor of the salvage expedition - may know the planet's location.", opad);
178 } else if (stage == PSIStage.GO_TO_PLANET) {
179 info.addPara("You've talked to the old spacer's pilot comrade and convinced " +
180 "them to divulge the location of the planet.", opad);
181 } else {
182 info.addPara("You've found the planet and uncovered its secret.", opad);
183 }
184
185 addBulletPoints(info, ListInfoMode.IN_DESC);
186
187 }
188
189 @Override
190 public String getIcon() {
191 return Global.getSettings().getSpriteName("intel", "red_planet");
192 }
193
194 @Override
195 public Set<String> getIntelTags(SectorMapAPI map) {
196 Set<String> tags = super.getIntelTags(map);
197 tags.add(Tags.INTEL_STORY);
198 tags.add(Tags.INTEL_EXPLORATION);
199 tags.add(Tags.INTEL_ACCEPTED);
200 tags.add(Tags.INTEL_MISSIONS);
201 return tags;
202 }
203
204 @Override
205 public IntelSortTier getSortTier() {
206 return IntelSortTier.TIER_2;
207 }
208
209 public String getSortString() {
210 return "Red Planet";
211 }
212
213 public String getName() {
214 if (isEnded() || isEnding()) {
215 return "Red Planet - Completed";
216 }
217 return "Red Planet";
218 }
219
220 @Override
222 return super.getFactionForUIColors();
223 }
224
225 public String getSmallDescriptionTitle() {
226 return getName();
227 }
228
229 @Override
231 if (stage == PSIStage.TALK_TO_PILOT) {
232 return event.getPilotMarket().getPrimaryEntity();
233 }
234 return planet;
235 }
236
237 @Override
238 public boolean shouldRemoveIntel() {
239 return super.shouldRemoveIntel();
240 }
241
242 @Override
243 public String getCommMessageSound() {
244 return getSoundMajorPosting();
245 }
246
247}
248
249
250
251
252
253
254
static SettingsAPI getSettings()
Definition Global.java:57
static SectorAPI getSector()
Definition Global.java:65
void sendUpdate(Object listInfoParam, TextPanelAPI textPanel)
boolean callEvent(String ruleId, InteractionDialogAPI dialog, List< Token > params, Map< String, MemoryAPI > memoryMap)
void createSmallDescription(TooltipMakerAPI info, float width, float height)
static void addCreditsLossText(int credits, TextPanelAPI text)
static Color getTextColor()
Definition Misc.java:839
static String getDGSCredits(float num)
Definition Misc.java:1390
static void makeImportant(SectorEntityToken entity, String reason)
Definition Misc.java:4051
static Color getGrayColor()
Definition Misc.java:826
static void makeUnimportant(SectorEntityToken entity, String reason)
Definition Misc.java:4077
static Color getHighlightColor()
Definition Misc.java:792
String getSpriteName(String category, String id)
void removeScript(EveryFrameScript script)
void set(String key, Object value)
void addXP(long xp, TextPanelAPI textPanel, boolean withMessage, boolean allowBonusXP, boolean withLevelUp)
MutableCharacterStatsAPI getStats()
LabelAPI addPara(String format, float pad, Color hl, String... highlights)