Starsector API
Loading...
Searching...
No Matches
RecoverAPlanetkiller.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.missions;
2
3import java.awt.Color;
4import java.util.List;
5import java.util.Map;
6
7import com.fs.starfarer.api.Global;
8import com.fs.starfarer.api.campaign.CampaignFleetAPI;
9import com.fs.starfarer.api.campaign.InteractionDialogAPI;
10import com.fs.starfarer.api.campaign.PlanetAPI;
11import com.fs.starfarer.api.campaign.SectorEntityToken;
12import com.fs.starfarer.api.campaign.StarSystemAPI;
13import com.fs.starfarer.api.campaign.econ.MarketAPI;
14import com.fs.starfarer.api.campaign.rules.MemoryAPI;
15import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithSearch;
16import com.fs.starfarer.api.impl.campaign.procgen.themes.MiscellaneousThemeGenerator;
17import com.fs.starfarer.api.ui.SectorMapAPI;
18import com.fs.starfarer.api.ui.TooltipMakerAPI;
19import com.fs.starfarer.api.util.Misc;
20import com.fs.starfarer.api.util.Misc.Token;
21
22public class RecoverAPlanetkiller extends HubMissionWithSearch {
23
24 public static enum Stage {
25 GO_TO_NEXUS,
26 RECOVER_PK,
27 COMPLETED,
28 FAILED,
29 }
30
31 public static boolean startedAtPather() {
32 return Global.getSector().getMemoryWithoutUpdate().getBoolean("$pk_startedAtPather");
33 }
34 public static boolean startedAtNexus() {
35 return Global.getSector().getMemoryWithoutUpdate().getBoolean("$pk_startedAtNexus");
36 }
37 public static boolean gotDataFromMysteryAI() {
38 return Global.getSector().getMemoryWithoutUpdate().getBoolean("$pk_gotDataFromMysteryAI");
39 }
40 public static CampaignFleetAPI getNexus() {
41 return (CampaignFleetAPI) Global.getSector().getPersistentData().get(MiscellaneousThemeGenerator.PK_NEXUS_KEY);
42 }
43 public StarSystemAPI getNexusSystem() {
44 CampaignFleetAPI nexus = getNexus();
45 if (nexus != null && nexus.isAlive()) {
46 return nexus.getStarSystem();
47 }
48 return null;
49 }
50 public static MarketAPI getTundraMarket() {
51 PlanetAPI p = getTundra();
52 if (p == null) return null;
53 return p.getMarket();
54 }
55 public static PlanetAPI getTundra() {
56 return (PlanetAPI) Global.getSector().getPersistentData().get(MiscellaneousThemeGenerator.PK_PLANET_KEY);
57 }
58 public static StarSystemAPI getPKSystem() {
59 return (StarSystemAPI) Global.getSector().getPersistentData().get(MiscellaneousThemeGenerator.PK_SYSTEM_KEY);
60 }
61
62 @Override
63 protected boolean create(MarketAPI createdAt, boolean barEvent) {
64 //genRandom = Misc.random;
65 setPersonOverride(null);
66
67 setStoryMission();
68 setNoAbandon();
69
70 if (!setGlobalReference("$pk_ref", "$pk_inProgress")) {
71 return false;
72 }
73
74 CampaignFleetAPI nexus = getNexus();
75 if (nexus != null && nexus.isAlive()) {
76 makeImportant(nexus, "$pk_nexus", Stage.GO_TO_NEXUS);
77 }
78
79 if (startedAtNexus()) {
80 setStartingStage(Stage.RECOVER_PK);
81 } else {
82 if (nexus == null || !nexus.isAlive() || getNexusSystem() == null) {
83 return false;
84 }
85 setStartingStage(Stage.GO_TO_NEXUS);
86 }
87
88 setSuccessStage(Stage.COMPLETED);
89 setFailureStage(Stage.FAILED);
90
91// setRepFactionChangesVeryHigh();
92// setRepPersonChangesVeryHigh();
93
94 setRepPenaltyFaction(0f);
95 setRepPenaltyPerson(0f);
96
97 connectWithGlobalFlag(Stage.GO_TO_NEXUS, Stage.RECOVER_PK, "$pk_nexusDataGained");
98 if (nexus != null) {
99 connectWithEntityNotAlive(Stage.GO_TO_NEXUS, Stage.RECOVER_PK, nexus);
100 }
101 setStageOnGlobalFlag(Stage.COMPLETED, "$pk_completed");
102
103 beginStageTrigger(Stage.COMPLETED);
104 triggerSetGlobalMemoryValue("$pk_recovered", true);
105 triggerSetGlobalMemoryValue("$pk_missionCompleted", true);
106 endTrigger();
107
108 return true;
109 }
110
111 @Override
112 public SectorEntityToken getMapLocation(SectorMapAPI map, Object currentStage) {
113 if (currentStage == Stage.RECOVER_PK) {
114 return getPKSystem().getCenter();
115 }
116 return super.getMapLocation(map, currentStage);
117 }
118
119// @Override
120// protected void endAbandonImpl() {
121// super.endAbandonImpl();
122// endFailureImpl(null, null);
123// }
124
125 @Override
126 protected void endFailureImpl(InteractionDialogAPI dialog, Map<String, MemoryAPI> memoryMap) {
127 if (currentStage == Stage.FAILED) {
128 //KantaCMD.loseProtection(dialog);
129 }
130 }
131
132
133 protected void updateInteractionDataImpl() {
134 CampaignFleetAPI nexus = getNexus();
135 StarSystemAPI ns = getNexusSystem();
136 StarSystemAPI pks = getPKSystem();
137
138 if (getCurrentStage() != null) {
139 set("$pk_stage", ((Enum)getCurrentStage()).name());
140 }
141
142 if (ns != null) {
143 set("$pk_nexusSystemName", ns.getNameWithLowercaseTypeShort());
144 }
145 if (pks != null) {
146 set("$pk_pkSystemName", pks.getNameWithLowercaseTypeShort());
147 }
148 }
149
150 @Override
151 public void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height) {
152 float opad = 10f;
153 Color h = Misc.getHighlightColor();
154 if (currentStage == Stage.GO_TO_NEXUS) {
155 StarSystemAPI ns = getNexusSystem();
156 if (ns != null) {
157 info.addPara("Recover information about a Hegemony fleet last seen in a Tri-Tachyon held "
158 + "system during the first AI War, more than a hundred cycles ago. The fleet is rumored to "
159 + "have been carrying a planetkiller weapon.", opad);
160 info.addPara("The information should be contained in the data banks of a remnant Nexus"
161 + " located in the " +
162 ns.getNameWithLowercaseType() + ".", opad);
163 }
164 } else if (currentStage == Stage.RECOVER_PK) {
165 StarSystemAPI pks = getPKSystem();
166 if (pks != null) {
167 if (startedAtNexus()) {
168 info.addPara("You've destroyed a remnant Nexus and recovered information about "
169 + "a Hegemony fleet estimated to be carrying a planetkiller weapon.", opad);
170 info.addPara("A log entry records "
171 + "a large Ordo sent in pursuit; its last hyperwave report placed it "
172 + "near the " + pks.getNameWithLowercaseTypeShort() +
173 ". The log entry dates to the first AI War, more than a hundred cycles ago", opad);
175 info.addPara("A mysterious voice, some kind of AI, provided you with coordinates for the " + pks.getNameWithLowercaseTypeShort() +", and implied that the planetkiller weapon could be found there.", opad);
176 info.addPara("Perhaps it brings 'much amusement' to this AI to not provide more detailed instructions.", opad);
177 }
178 } else {
179 info.addPara("The data banks of the remnant Nexus contained information about the Hegemony fleet rumored "
180 + "to be carrying a planetkiller weapon. ", opad);
181 info.addPara("A log entry records "
182 + "a large Ordo sent in pursuit; its last hyperwave report placed it "
183 + "near the " + pks.getNameWithLowercaseTypeShort() +
184 ". The log entry dates to the first AI War, more than a hundred cycles ago", opad);
185 }
186 }
187 } else if (currentStage == Stage.FAILED) {
188 // not actually possible to fail
189 }
190 }
191
192 @Override
193 public boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad) {
194 Color h = Misc.getHighlightColor();
195 if (currentStage == Stage.GO_TO_NEXUS) {
196 StarSystemAPI ns = getNexusSystem();
197 if (ns != null) {
198 info.addPara("Recover information from remnant Nexus in the " + ns.getNameWithLowercaseTypeShort(), tc, pad);
199 }
200 return true;
201 } else if (currentStage == Stage.RECOVER_PK) {
202 StarSystemAPI pks = getPKSystem();
203 if (pks != null) {
204 info.addPara("Investigate the " + pks.getNameWithLowercaseTypeShort(), tc, pad);
205 }
206 return true;
207 }
208 return false;
209 }
210
211 protected String getMissionTypeNoun() {
212 return "task";
213 }
214
215 @Override
216 public String getPostfixForState() {
217 if (startingStage != null) {
218 return "";
219 }
220 return super.getPostfixForState();
221 }
222 @Override
223 public String getBaseName() {
224 return "The Scythe of Orion";
225 }
226
227// Global.getSector().getListenerManager().removeListener(this);
228// endAfterDelay();
229
230 @Override
231 public void acceptImpl(InteractionDialogAPI dialog, Map<String, MemoryAPI> memoryMap) {
232 super.acceptImpl(dialog, memoryMap);
233 //Global.getSector().getListenerManager().addListener(this);
234 }
235
236 @Override
237 protected void notifyEnding() {
238 super.notifyEnding();
239 //Global.getSector().getListenerManager().removeListener(this);
240 }
241
242 @Override
243 protected boolean callAction(String action, String ruleId, InteractionDialogAPI dialog, List<Token> params,
244 Map<String, MemoryAPI> memoryMap) {
245 if (action.equals("showNexusSystem")) {
246 StarSystemAPI system = getNexusSystem();
247 if (system != null) {
248 dialog.getVisualPanel().showMapMarker(system.getHyperspaceAnchor(),
249 system.getNameWithLowercaseTypeShort(), getFactionForUIColors().getBaseUIColor(),
250 true, getIcon(), null, getIntelTags(null));
251 }
252 return true;
253 } else if (action.equals("hideNexusSystem")) {
254 dialog.getVisualPanel().removeMapMarkerFromPersonInfo();
255 return true;
256 }
257 return super.callAction(action, ruleId, dialog, params, memoryMap);
258 }
259
260
261}
262
263
264
265
266
static SectorAPI getSector()
Definition Global.java:59
void endFailureImpl(InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap)
SectorEntityToken getMapLocation(SectorMapAPI map, Object currentStage)
boolean addNextStepText(TooltipMakerAPI info, Color tc, float pad)
void addDescriptionForNonEndStage(TooltipMakerAPI info, float width, float height)
boolean callAction(String action, String ruleId, InteractionDialogAPI dialog, List< Token > params, Map< String, MemoryAPI > memoryMap)
void acceptImpl(InteractionDialogAPI dialog, Map< String, MemoryAPI > memoryMap)