Starsector API
Loading...
Searching...
No Matches
DomainSurveyDerelictSpecial.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.rulecmd.salvage.special;
2
3import com.fs.starfarer.api.Global;
4import com.fs.starfarer.api.campaign.InteractionDialogAPI;
5import com.fs.starfarer.api.campaign.LocationAPI;
6import com.fs.starfarer.api.campaign.PlanetAPI;
7import com.fs.starfarer.api.campaign.SectorEntityToken;
8import com.fs.starfarer.api.campaign.StarSystemAPI;
9import com.fs.starfarer.api.impl.campaign.ids.StarTypes;
10import com.fs.starfarer.api.impl.campaign.intel.misc.BreadcrumbIntel;
11import com.fs.starfarer.api.impl.campaign.procgen.Constellation;
12import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.SalvageSpecialInteraction.SalvageSpecialData;
13import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.SalvageSpecialInteraction.SalvageSpecialPlugin;
14
16
17 public static enum SpecialType {
18 SCRAMBLED,
19 LOCATION_SURVEY_SHIP,
20 LOCATION_MOTHERSHIP,
21
22// PLANET_INTERESTING_PROPERTY,
23// PLANET_SURVEY_DATA,
24// SYSTEM_PRELIMINARY_SURVEY,
25
26 ACTIVATE_PROBE,
27 ACTIVATE_SURVEY_SHIP,
28 }
29
30
31 public static class DomainSurveyDerelictSpecialData implements SalvageSpecialData {
32 public SpecialType type = SpecialType.SCRAMBLED;
33 public String entityId = null;
34 public String secondaryId = null;
35 public DomainSurveyDerelictSpecialData(SpecialType type) {
36 this.type = type;
37 }
38 public SalvageSpecialPlugin createSpecialPlugin() {
39 return new DomainSurveyDerelictSpecial();
40 }
41 }
42
43 private DomainSurveyDerelictSpecialData data;
44
47
48 @Override
49 public void init(InteractionDialogAPI dialog, Object specialData) {
50 super.init(dialog, specialData);
51
52 data = (DomainSurveyDerelictSpecialData) specialData;
53
54 if (data.entityId != null) {
55 SectorEntityToken entity = Global.getSector().getEntityById(data.entityId);
56 if (entity == null) {// ||
57// (entity != null && entity instanceof CustomCampaignEntityAPI &&
58// !((CustomCampaignEntityAPI)entity).isDiscoverable())) {
59 data.entityId = null;
60 data.type = SpecialType.SCRAMBLED;
61 }
62 }
63
64 switch (data.type) {
65 case SCRAMBLED:
67 break;
68// case PLANET_INTERESTING_PROPERTY:
69// initInterestingProperty();
70// break;
71// case PLANET_SURVEY_DATA:
72// initPlanetSurveyData();
73// break;
74// case SYSTEM_PRELIMINARY_SURVEY:
77// initPreliminarySystemSurvey();
78// break;
79 case LOCATION_SURVEY_SHIP:
80 initSurveyParentEntity();
81 break;
82 case LOCATION_MOTHERSHIP:
83 initSurveyParentEntity();
84 break;
85// case CONSTELLATION_PRELIMINARY_SURVEY:
86// break;
87 }
88
89// for (PlanetAPI curr : entity.getContainingLocation().getPlanets()) {
90// if (!curr.isStar()) {
91// planet = curr;
92// break;
93// }
94// }
95//
96// dialog.getTextPanel().addParagraph("Survey data for " + planet.getName() + " gained.");
97// //Misc.setFullySurveyed(planet.getMarket());
98// planet.getMarket().setSurveyLevel(SurveyLevel.PRELIMINARY);
99//
100// setDone(true);
101// dialog.getOptionPanel().clearOptions();
102// dialog.getOptionPanel().addOption("Continue", "continue");
103 }
104
105 public boolean shouldShowAgain() {
106 return data != null && (
107 data.type == SpecialType.ACTIVATE_PROBE ||
108 data.type == SpecialType.ACTIVATE_SURVEY_SHIP
109 );
110 }
111
112
113 private void initSurveyParentEntity() {
114 if (data.entityId == null) {
115 initNothing();
116 return;
117 }
118
119 SectorEntityToken parent = Global.getSector().getEntityById(data.entityId);
120 if (parent == null || !parent.hasSensorProfile()) {
121 initNothing();
122 return;
123 }
124
125 String text1 = "The $shortName's memory banks are partially accessible, and ";
126 String text1ForIntel = "While exploring $aOrAn $nameInText, your crews found " +
127 "partially accessible memory banks that ";
128 //entity.getCustomEntitySpec().getAOrAn() + " " +
129 String name = parent.getCustomEntitySpec().getNameInText();
130 String nameForTitle = parent.getCustomEntitySpec().getDefaultName();
131 //String loc = BreadcrumbSpecial.getLocatedString(parent);
132
133 String subject = getString("Derelict " + nameForTitle + " Location");
134
135 text1 += "contain information pointing to the location of a " + name + ". ";
136 text1ForIntel += "contain information pointing to the location of a " + name + ". ";
137 //text1 += "It was last seen by this $shortName " + orbiting + loc + ".";
138
139 String located = BreadcrumbSpecial.getLocatedString(parent, true);
140 //located = located.replaceFirst("located ", "");
141 text1 += "It was last seen by this $shortName " + located + ".";
142 text1ForIntel += "It was last seen by this $shortName " + located + ".";
143
144 text1 = getString(text1);
145
146 addText(text1);
147
148 BreadcrumbIntel intel = new BreadcrumbIntel(entity, parent);
149 intel.setTitle(getString(subject));
150 intel.setText(getString(text1ForIntel));
151 Global.getSector().getIntelManager().addIntel(intel, false, text);
152
153// CommMessageAPI message = FleetLog.beginEntry(subject, parent);
154// message.getSection1().addPara(getString(text1));
155// FleetLog.addToLog(message, text);
156
157 //unsetData();
158 setDone(true);
159 }
160
161 public void initNothing() {
162 addText("The $shortName's memory banks have been scrubbed clean by hard radiation, and the systems are largely inert and non-functional.");
163
164 //unsetData();
165 setDone(true);
166 }
167
168
169// protected void initInterestingProperty() {
170// if (data.entityId == null || data.secondaryId == null) {
171// initNothing();
172// return;
173// }
174//
175// PlanetAPI planet = (PlanetAPI) Global.getSector().getEntityById(data.entityId);
176// if (planet.getMarket() != null && planet.getMarket().getSurveyLevel() == SurveyLevel.FULL) {
177// initNothing();
178// return;
179// }
180//
181// String text1 = getString("The $shortName's memory banks are partially accessible, and ");
182// String text1ForIntel = "While exploring $aOrAn $nameInText, your crews found " +
183// "partially accessible memory banks that ";
184//
185// String desc = "";
186// String world = planet.getSpec().getAOrAn() + " " + planet.getTypeNameWithWorld().toLowerCase();
187// //String loc = getLocationDescription(planet);
188//
189// String loc = BreadcrumbSpecial.getLocatedString(planet);
190// loc = loc.replaceFirst("located ", "");
191//
192// String subject = "";
193// MarketConditionSpecAPI spec = Global.getSettings().getMarketConditionSpec(data.secondaryId);
194// if (spec.getId().equals(Conditions.HABITABLE)) {
195// subject = "Habitable planet location";
196// desc = "point to the existence of " + world + " with a low hazard rating " + loc;
197//
198// } else {
199// subject = Misc.ucFirst(spec.getName().toLowerCase()) + " location";
200// desc = "contain information about " + spec.getName().toLowerCase() + " on " + world + " " + loc;
201// }
202//
203// desc += ".";
204//
205// addText(text1 + desc);
206//
207// BreadcrumbIntel intel = new BreadcrumbIntel(entity, planet);
208// intel.setTitle(getString(subject));
209// intel.setText(getString(text1ForIntel));
210// Global.getSector().getIntelManager().addIntel(intel, false, text);
211//
215//
216// //unsetData();
217// setDone(true);
218// }
219
220
221// protected void initPlanetSurveyData() {
222// if (data.entityId == null) {
223// initNothing();
224// return;
225// }
226//
227// PlanetAPI planet = (PlanetAPI) Global.getSector().getEntityById(data.entityId);
228// if (planet.getMarket() != null && planet.getMarket().getSurveyLevel() == SurveyLevel.FULL) {
229// initNothing();
230// return;
231// }
232//
233//
234// String name = planet.getName();
235// String world = planet.getSpec().getAOrAn() + " " + planet.getTypeNameWithWorld().toLowerCase();
236// //String loc = getLocationName(planet);
237// String loc = BreadcrumbSpecial.getLocatedString(planet);
238// loc = loc.replaceFirst("located ", "");
239//
240// String text1 = getString("The $shortName's memory banks are partially accessible, " +
241// "and contain full survey data for " + name + ", " + world + " located " + loc + ".");
242//
243// //planet.getMarket().setSurveyLevel(SurveyLevel.PRELIMINARY);
244//
245// String subject = "Full survey data for " + name;
246//
247// addText(text1);
248// Misc.setFullySurveyed(planet.getMarket(), null, false);
249// Misc.addSurveyDataFor(planet, text);
254//
255// SurveyPlugin plugin = (SurveyPlugin) Global.getSettings().getPlugin("surveyPlugin");
256// plugin.init(Global.getSector().getPlayerFleet(), planet);
257// long xp = plugin.getXP();
258// if (xp > 0) {
259// Global.getSector().getPlayerPerson().getStats().addXP(xp, text);
260// }
261//
262// CommMessageAPI message = FleetLog.beginEntry(subject, planet);
263// message.getSection1().addPara(getString(text1));
264// FleetLog.addToLog(message, text);
265//
266// //unsetData();
267// setDone(true);
268// }
269
270
271// protected void initPreliminarySystemSurvey() {
272// if (data.entityId == null) {
273// initNothing();
274// return;
275// }
276//
277// StarSystemAPI system = Global.getSector().getStarSystem(data.entityId);
278// if (system == null) {
279// initNothing();
280// return;
281// }
282//
283// String name = system.getNameWithLowercaseType();
284// String text1 = getString("The $shortName's memory banks are partially accessible, " +
285// "and contain complete preliminary survey data for the " + name + ".");
286//
287// String subject = "Acquired complete preliminary survey data for the " + name;
288//
289// addText(text1);
290//
291// String data = "";
292// Highlights h = new Highlights();
293// for (PlanetAPI planet : system.getPlanets()) {
294// if (planet.isStar()) continue;
295// if (planet.getMarket() == null) continue;
296// if (!planet.getMarket().isPlanetConditionMarketOnly()) continue;
297// if (planet.getMarket().getSurveyLevel().ordinal() > SurveyLevel.PRELIMINARY.ordinal()) continue;
298//
299// String curr = planet.getName() + ", " + planet.getTypeNameWithWorld().toLowerCase();
300// data += " " + curr + "\n";
301// h.append(curr, planet.getSpec().getIconColor());
302//
305// planet.getMarket().setSurveyLevel(SurveyLevel.PRELIMINARY);
306//
307// //Misc.setPreliminarySurveyed(planet.getMarket(), text, true);
308// }
309// //data = "";
310// if (!data.isEmpty()) {
311// text.setFontSmallInsignia();
312// text.addParagraph("Preliminary survey data for:", Misc.getTooltipTitleAndLightHighlightColor());
313// //data = data.substring(0, data.length() - 2);
314// data = " " + data.trim();
315// text.addParagraph(data);
316// text.setHighlightsInLastPara(h);
317// text.setFontInsignia();
318//
319// CommMessageAPI message = FleetLog.beginEntry(subject, system.getCenter());
320// message.getSection1().addPara(getString(text1));
321// FleetLog.addToLog(message, text);
322// } else {
323// text.addParagraph("However, you've already acquired this data through other means.");
324// }
325//
326// //unsetData();
327// setDone(true);
328// }
329
330
331// protected void unsetData() {
332// BaseCommandPlugin.getEntityMemory(memoryMap).unset(MemFlags.SALVAGE_SPECIAL_DATA);
333// }
334
335 public static String getLocationName(SectorEntityToken entity) {
336 LocationAPI loc = entity.getContainingLocation();
337 if (loc == null) {
338 return "in an unknown location nearby";
339 }
340 if (loc.isHyperspace()) {
341 return "in hyperspace nearby";
342 }
343 StarSystemAPI system = (StarSystemAPI) loc;
344
345 if (system == Global.getSector().getCurrentLocation()) {
346 if (system.isNebula()) {
347 return "inside this nebula";
348 }
349 return "in this system";
350 }
351
352 return "in the " + system.getNameWithLowercaseType();
353 }
354
355 public static String getLocationDescription(SectorEntityToken entity) {
356 LocationAPI loc = entity.getContainingLocation();
357 if (loc == null) {
358 return "in an unknown location nearby";
359 }
360 if (loc.isHyperspace()) {
361 return "in hyperspace nearby";
362 }
363 StarSystemAPI system = (StarSystemAPI) loc;
364
365 if (system == Global.getSector().getCurrentLocation()) {
366 if (system.isNebula()) {
367 return "inside this nebula";
368 }
369 return "in this system";
370 }
371
372 if (entity.getConstellation() != null && entity.getConstellation() != Global.getSector().getCurrentLocation().getConstellation()) {
373 Constellation c = entity.getConstellation();
374 String cText = "in the " + c.getNameWithLowercaseType();
375 if (c.getSystems().size() == 1) {
376 return "orbiting " + getStarDescription(system.getStar()) + " nearby";
377 }
378
379 if (system.isNebula()) {
380 return "inside a nebula " + cText;
381 }
382
383 if (system.getTertiary() != null) {
384 return "in a trinary star system " + cText;
385 }
386
387 if (system.getSecondary() != null) {
388 return "in a binary star system " + cText;
389 }
390
391 //if (system.getType() == StarSystemType.SINGLE) {
392 return "orbiting " + getStarDescription(system.getStar()) + " " + cText;
393 }
394
395 if (system.isNebula()) {
396 return "inside a nearby nebula";
397 }
398
399 if (system.getTertiary() != null) {
400 return "in a nearby trinary star system";
401 }
402
403 if (system.getSecondary() != null) {
404 return "in a nearby binary star system";
405 }
406
407 //if (system.getType() == StarSystemType.SINGLE) {
408 return "orbiting " + getStarDescription(system.getStar()) + " nearby";
409 //}
410 }
411
412
413 public static String getStarDescription(PlanetAPI star) {
414 String type = star.getTypeId();
415
416 if (type.equals(StarTypes.BLACK_HOLE)) return "a black hole";
417 if (type.equals(StarTypes.NEUTRON_STAR)) return "a neutron star";
418
419 if (type.equals(StarTypes.ORANGE) ||
420 type.equals(StarTypes.ORANGE_GIANT)) {
421 return "an orange star";
422 }
423
424 if (type.equals(StarTypes.RED_DWARF) ||
425 type.equals(StarTypes.RED_SUPERGIANT) ||
426 type.equals(StarTypes.RED_GIANT)) {
427 return "a red star";
428 }
429
430 if (type.equals(StarTypes.BLUE_GIANT) ||
431 type.equals(StarTypes.BLUE_SUPERGIANT)) {
432 return "a blue star";
433 }
434
435 if (type.equals(StarTypes.BROWN_DWARF) ||
436 type.equals(StarTypes.WHITE_DWARF)) {
437 return "a dim star";
438 }
439
440 if (type.equals(StarTypes.YELLOW)) {
441 return "a yellow star";
442 }
443
444 return "a star of unknown type";
445 }
446
447
448 @Override
449 public void optionSelected(String optionText, Object optionData) {
450 super.optionSelected(optionText, optionData);
451
452 if ("continue".equals(optionData)) {
453 setDone(true);
454 }
455 }
456
457 @Override
458 public boolean endWithContinue() {
459 return super.endWithContinue();
460 }
461
462
463}
static SectorAPI getSector()
Definition Global.java:59