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.BreadcrumbIntelV2;
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) {
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 String subject = getString("Location: " + nameForTitle);
135
136 text1 += "contain information pointing to the location of a " + name + ". ";
137 text1ForIntel += "contain information pointing to the location of a " + name + ". ";
138 //text1 += "It was last seen by this $shortName " + orbiting + loc + ".";
139
140 String located = BreadcrumbSpecial.getLocatedString(parent, true);
141 //located = located.replaceFirst("located ", "");
142 text1 += "It was last seen by this $shortName " + located + ".";
143 text1ForIntel += "It was last seen by this $shortName " + located + ".";
144
145 text1 = getString(text1);
146
147 addText(text1);
148
149 BreadcrumbIntelV2 intel = new BreadcrumbIntelV2(parent);
150 intel.setTitle(getString(subject));
151 intel.setText(getString(text1ForIntel));
152 //intel.setIcon(Global.getSettings().getSpriteName("intel", "leading_to_larger_domain_derelict"));
153 intel.setIconId("leading_to_larger_domain_derelict");
154 Global.getSector().getIntelManager().addIntel(intel, false, text);
155
156// CommMessageAPI message = FleetLog.beginEntry(subject, parent);
157// message.getSection1().addPara(getString(text1));
158// FleetLog.addToLog(message, text);
159
160 //unsetData();
161 setDone(true);
162 }
163
164 public void initNothing() {
165 addText("The $shortName's memory banks have been scrubbed clean by hard radiation, and the systems are largely inert and non-functional.");
166
167 //unsetData();
168 setDone(true);
169 }
170
171
172// protected void initInterestingProperty() {
173// if (data.entityId == null || data.secondaryId == null) {
174// initNothing();
175// return;
176// }
177//
178// PlanetAPI planet = (PlanetAPI) Global.getSector().getEntityById(data.entityId);
179// if (planet.getMarket() != null && planet.getMarket().getSurveyLevel() == SurveyLevel.FULL) {
180// initNothing();
181// return;
182// }
183//
184// String text1 = getString("The $shortName's memory banks are partially accessible, and ");
185// String text1ForIntel = "While exploring $aOrAn $nameInText, your crews found " +
186// "partially accessible memory banks that ";
187//
188// String desc = "";
189// String world = planet.getSpec().getAOrAn() + " " + planet.getTypeNameWithWorld().toLowerCase();
190// //String loc = getLocationDescription(planet);
191//
192// String loc = BreadcrumbSpecial.getLocatedString(planet);
193// loc = loc.replaceFirst("located ", "");
194//
195// String subject = "";
196// MarketConditionSpecAPI spec = Global.getSettings().getMarketConditionSpec(data.secondaryId);
197// if (spec.getId().equals(Conditions.HABITABLE)) {
198// subject = "Habitable planet location";
199// desc = "point to the existence of " + world + " with a low hazard rating " + loc;
200//
201// } else {
202// subject = Misc.ucFirst(spec.getName().toLowerCase()) + " location";
203// desc = "contain information about " + spec.getName().toLowerCase() + " on " + world + " " + loc;
204// }
205//
206// desc += ".";
207//
208// addText(text1 + desc);
209//
210// BreadcrumbIntel intel = new BreadcrumbIntel(entity, planet);
211// intel.setTitle(getString(subject));
212// intel.setText(getString(text1ForIntel));
213// Global.getSector().getIntelManager().addIntel(intel, false, text);
214//
218//
219// //unsetData();
220// setDone(true);
221// }
222
223
224// protected void initPlanetSurveyData() {
225// if (data.entityId == null) {
226// initNothing();
227// return;
228// }
229//
230// PlanetAPI planet = (PlanetAPI) Global.getSector().getEntityById(data.entityId);
231// if (planet.getMarket() != null && planet.getMarket().getSurveyLevel() == SurveyLevel.FULL) {
232// initNothing();
233// return;
234// }
235//
236//
237// String name = planet.getName();
238// String world = planet.getSpec().getAOrAn() + " " + planet.getTypeNameWithWorld().toLowerCase();
239// //String loc = getLocationName(planet);
240// String loc = BreadcrumbSpecial.getLocatedString(planet);
241// loc = loc.replaceFirst("located ", "");
242//
243// String text1 = getString("The $shortName's memory banks are partially accessible, " +
244// "and contain full survey data for " + name + ", " + world + " located " + loc + ".");
245//
246// //planet.getMarket().setSurveyLevel(SurveyLevel.PRELIMINARY);
247//
248// String subject = "Full survey data for " + name;
249//
250// addText(text1);
251// Misc.setFullySurveyed(planet.getMarket(), null, false);
252// Misc.addSurveyDataFor(planet, text);
257//
258// SurveyPlugin plugin = (SurveyPlugin) Global.getSettings().getPlugin("surveyPlugin");
259// plugin.init(Global.getSector().getPlayerFleet(), planet);
260// long xp = plugin.getXP();
261// if (xp > 0) {
262// Global.getSector().getPlayerPerson().getStats().addXP(xp, text);
263// }
264//
265// CommMessageAPI message = FleetLog.beginEntry(subject, planet);
266// message.getSection1().addPara(getString(text1));
267// FleetLog.addToLog(message, text);
268//
269// //unsetData();
270// setDone(true);
271// }
272
273
274// protected void initPreliminarySystemSurvey() {
275// if (data.entityId == null) {
276// initNothing();
277// return;
278// }
279//
280// StarSystemAPI system = Global.getSector().getStarSystem(data.entityId);
281// if (system == null) {
282// initNothing();
283// return;
284// }
285//
286// String name = system.getNameWithLowercaseType();
287// String text1 = getString("The $shortName's memory banks are partially accessible, " +
288// "and contain complete preliminary survey data for the " + name + ".");
289//
290// String subject = "Acquired complete preliminary survey data for the " + name;
291//
292// addText(text1);
293//
294// String data = "";
295// Highlights h = new Highlights();
296// for (PlanetAPI planet : system.getPlanets()) {
297// if (planet.isStar()) continue;
298// if (planet.getMarket() == null) continue;
299// if (!planet.getMarket().isPlanetConditionMarketOnly()) continue;
300// if (planet.getMarket().getSurveyLevel().ordinal() > SurveyLevel.PRELIMINARY.ordinal()) continue;
301//
302// String curr = planet.getName() + ", " + planet.getTypeNameWithWorld().toLowerCase();
303// data += " " + curr + "\n";
304// h.append(curr, planet.getSpec().getIconColor());
305//
308// planet.getMarket().setSurveyLevel(SurveyLevel.PRELIMINARY);
309//
310// //Misc.setPreliminarySurveyed(planet.getMarket(), text, true);
311// }
312// //data = "";
313// if (!data.isEmpty()) {
314// text.setFontSmallInsignia();
315// text.addParagraph("Preliminary survey data for:", Misc.getTooltipTitleAndLightHighlightColor());
316// //data = data.substring(0, data.length() - 2);
317// data = " " + data.trim();
318// text.addParagraph(data);
319// text.setHighlightsInLastPara(h);
320// text.setFontInsignia();
321//
322// CommMessageAPI message = FleetLog.beginEntry(subject, system.getCenter());
323// message.getSection1().addPara(getString(text1));
324// FleetLog.addToLog(message, text);
325// } else {
326// text.addParagraph("However, you've already acquired this data through other means.");
327// }
328//
329// //unsetData();
330// setDone(true);
331// }
332
333
334// protected void unsetData() {
335// BaseCommandPlugin.getEntityMemory(memoryMap).unset(MemFlags.SALVAGE_SPECIAL_DATA);
336// }
337
340 if (loc == null) {
341 return "in an unknown location nearby";
342 }
343 if (loc.isHyperspace()) {
344 return "in hyperspace nearby";
345 }
346 StarSystemAPI system = (StarSystemAPI) loc;
347
348 if (system == Global.getSector().getCurrentLocation()) {
349 if (system.isNebula()) {
350 return "inside this nebula";
351 }
352 return "in this system";
353 }
354
355 return "in the " + system.getNameWithLowercaseType();
356 }
357
360 if (loc == null) {
361 return "in an unknown location nearby";
362 }
363 if (loc.isHyperspace()) {
364 return "in hyperspace nearby";
365 }
366 StarSystemAPI system = (StarSystemAPI) loc;
367
368 if (system == Global.getSector().getCurrentLocation()) {
369 if (system.isNebula()) {
370 return "inside this nebula";
371 }
372 return "in this system";
373 }
374
377 String cText = "in the " + c.getNameWithLowercaseType();
378 if (c.getSystems().size() == 1) {
379 return "orbiting " + getStarDescription(system.getStar()) + " nearby";
380 }
381
382 if (system.isNebula()) {
383 return "inside a nebula " + cText;
384 }
385
386 if (system.getTertiary() != null) {
387 return "in a trinary star system " + cText;
388 }
389
390 if (system.getSecondary() != null) {
391 return "in a binary star system " + cText;
392 }
393
394 //if (system.getType() == StarSystemType.SINGLE) {
395 return "orbiting " + getStarDescription(system.getStar()) + " " + cText;
396 }
397
398 if (system.isNebula()) {
399 return "inside a nearby nebula";
400 }
401
402 if (system.getTertiary() != null) {
403 return "in a nearby trinary star system";
404 }
405
406 if (system.getSecondary() != null) {
407 return "in a nearby binary star system";
408 }
409
410 //if (system.getType() == StarSystemType.SINGLE) {
411 return "orbiting " + getStarDescription(system.getStar()) + " nearby";
412 //}
413 }
414
415
416 public static String getStarDescription(PlanetAPI star) {
417 String type = star.getTypeId();
418
419 if (type.equals(StarTypes.BLACK_HOLE)) return "a black hole";
420 if (type.equals(StarTypes.NEUTRON_STAR)) return "a neutron star";
421
422 if (type.equals(StarTypes.ORANGE) ||
423 type.equals(StarTypes.ORANGE_GIANT)) {
424 return "an orange star";
425 }
426
427 if (type.equals(StarTypes.RED_DWARF) ||
428 type.equals(StarTypes.RED_SUPERGIANT) ||
429 type.equals(StarTypes.RED_GIANT)) {
430 return "a red star";
431 }
432
433 if (type.equals(StarTypes.BLUE_GIANT) ||
434 type.equals(StarTypes.BLUE_SUPERGIANT)) {
435 return "a blue star";
436 }
437
438 if (type.equals(StarTypes.BROWN_DWARF) ||
439 type.equals(StarTypes.WHITE_DWARF)) {
440 return "a dim star";
441 }
442
443 if (type.equals(StarTypes.YELLOW)) {
444 return "a yellow star";
445 }
446
447 return "a star of unknown type";
448 }
449
450
451 @Override
452 public void optionSelected(String optionText, Object optionData) {
453 super.optionSelected(optionText, optionData);
454
455 if ("continue".equals(optionData)) {
456 setDone(true);
457 }
458 }
459
460 @Override
461 public boolean endWithContinue() {
462 return super.endWithContinue();
463 }
464
465
466}
static SectorAPI getSector()
Definition Global.java:65
SectorEntityToken getEntityById(String id)