Starsector API
Loading...
Searching...
No Matches
SurveyDataSpecial.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.rulecmd.salvage.special;
2
3import java.util.List;
4
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.campaign.InteractionDialogAPI;
7import com.fs.starfarer.api.campaign.PlanetAPI;
8import com.fs.starfarer.api.campaign.SectorEntityToken;
9import com.fs.starfarer.api.campaign.StarSystemAPI;
10import com.fs.starfarer.api.campaign.econ.MarketAPI.SurveyLevel;
11import com.fs.starfarer.api.characters.MarketConditionSpecAPI;
12import com.fs.starfarer.api.impl.campaign.ids.Conditions;
13import com.fs.starfarer.api.impl.campaign.ids.Entities;
14import com.fs.starfarer.api.impl.campaign.intel.misc.SurveyDataForPlanetIntel;
15import com.fs.starfarer.api.impl.campaign.procgen.themes.DerelictThemeGenerator;
16import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.SalvageSpecialInteraction.SalvageSpecialData;
17import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.SalvageSpecialInteraction.SalvageSpecialPlugin;
18import com.fs.starfarer.api.plugins.SurveyPlugin;
19import com.fs.starfarer.api.util.Misc;
20
22
23 public static float MAX_RANGE = 30000f;
24
25 public static enum SurveyDataSpecialType {
26 SCRAMBLED, // used when the planet is already surveyed or doesn't exist anymore or nothing is found etc
27 PLANET_SURVEY_DATA,
28
29 // these are not really interesting enough
30 @Deprecated PLANET_INTERESTING_PROPERTY,
31 @Deprecated SYSTEM_PRELIMINARY_SURVEY,
32 @Deprecated AUTO_PICK, // generate one of the above automatically, for a nearby planet or system
33 @Deprecated AUTO_PICK_NOT_SYSTEM, // pick either property or data, but not full system
34 }
35
36
37 public static class SurveyDataSpecialData implements SalvageSpecialData {
38 public SurveyDataSpecialType type = null;
39 public String entityId = null;
40
41 @Deprecated public String secondaryId = null;
42
43 public boolean includeRuins = true;
44 public SurveyDataSpecialData(SurveyDataSpecialType type) {
45 this.type = type;
46 }
47
48 public SalvageSpecialPlugin createSpecialPlugin() {
49 return new SurveyDataSpecial();
50 }
51 }
52
53 private SurveyDataSpecialData data;
54
56 }
57
58 @Override
59 public void init(InteractionDialogAPI dialog, Object specialData) {
60 super.init(dialog, specialData);
61
62 data = (SurveyDataSpecialData) specialData;
63
64 //random = new Random();
65
66 if (data.type == SurveyDataSpecialType.PLANET_SURVEY_DATA && data.entityId == null) {
67 List<StarSystemAPI> systems = Misc.getSystemsInRange(entity, null, true, MAX_RANGE);
68 PlanetAPI planet = DerelictThemeGenerator.findInterestingPlanet(systems, null, false, data.includeRuins, random);
69 if (planet != null) {
70 data.entityId = planet.getId();
71 }
72 }
73
74 if (data.entityId != null) {
76 StarSystemAPI system = Global.getSector().getStarSystem(data.entityId);
77 if (entity == null && system == null) {
78 data.entityId = null;
79 data.type = SurveyDataSpecialType.SCRAMBLED;
80 }
81 } else {
82 data.type = SurveyDataSpecialType.SCRAMBLED;
83 }
84
85
86 switch (data.type) {
87 case SCRAMBLED:
89 break;
90 case PLANET_SURVEY_DATA:
92 break;
93 default:
95 break;
96 }
97
98 }
99
100 public void initNothing() {
101 addText("The $shortName's memory banks have been scrubbed clean by hard radiation, and the systems are largely inert and non-functional.");
102 setDone(true);
103 }
104
105
106 protected void initPlanetSurveyData() {
107 if (data.entityId == null) {
108 initNothing();
109 return;
110 }
111
112 PlanetAPI planet = (PlanetAPI) Global.getSector().getEntityById(data.entityId);
113 if (planet.getMarket() != null && planet.getMarket().getSurveyLevel() == SurveyLevel.FULL) {
114 initNothing();
115 return;
116 }
117
118
119 String name = planet.getName();
120 String world = planet.getSpec().getAOrAn() + " " + planet.getTypeNameWithWorld().toLowerCase();
121 //String loc = getLocationName(planet);
122 String loc = BreadcrumbSpecial.getLocatedString(planet, true);
123 loc = loc.replaceFirst("located ", "");
124
125 String text1 = "The $shortName's memory banks are partially accessible, " +
126 "and contain full survey data for " + name + ", " + world + " located " + loc + ".";
127
128 String text1ForIntel = "While exploring $aOrAn $nameInText, your crews found " +
129 "partially accessible memory banks that contain full survey data for " +
130 name + ", " + world + " located " + loc + ".";
131
132 boolean debris = Entities.DEBRIS_FIELD_SHARED.equals(entity.getCustomEntityType());
133 if (debris) {
134 text1 = "Your salvage crews find a functional memory bank in the debris. " +
135 "It contains full survey data for " + name + ", " + world + " located " + loc + ".";
136 }
137
138 String conditionId = DerelictThemeGenerator.getInterestingCondition(planet, data.includeRuins);
139 if (conditionId != null) {
141 if (spec != null) {
142 text1 += " The world is notable for ";
143 text1ForIntel += " The world is notable for ";
144 if (conditionId.equals(Conditions.HABITABLE)) {
145 text1 += "being habitable.";
146 text1ForIntel += "being habitable.";
147 } else {
148 text1 += "having " + spec.getName().toLowerCase() + ".";
149 text1ForIntel += "having " + spec.getName().toLowerCase() + ".";
150 }
151 }
152 }
153
154
155 //planet.getMarket().setSurveyLevel(SurveyLevel.PRELIMINARY);
156
157 //String subject = "Survey Data: " + name + ", " + planet.getTypeNameWithWorld();
158
159 addText(text1);
160 Misc.setFullySurveyed(planet.getMarket(), null, false);
161 Misc.addSurveyDataFor(planet, text);
162// text.setFontSmallInsignia();
163// text.addParagraph("Acquired full survey data for " + name + ", " + planet.getTypeNameWithWorld().toLowerCase(),
164// planet.getSpec().getIconColor());
165// text.setFontInsignia();
166
168 plugin.init(Global.getSector().getPlayerFleet(), planet);
169 long xp = plugin.getXP();
170 if (xp > 0) {
172 }
173
174 new SurveyDataForPlanetIntel(planet, getString(text1ForIntel), text);
175
176// BreadcrumbIntel intel = new BreadcrumbIntel(entity, planet);
177// intel.setTitle(getString(subject));
178// intel.setText(getString(text1ForIntel));
179// intel.setShowSpecificEntity(true);
180// //intel.setIcon(Global.getSettings().getSpriteName("intel", "found_planet_data"));
181// intel.setIconId("found_planet_data");
182// Global.getSector().getIntelManager().addIntel(intel, false, text);
183
184// CommMessageAPI message = FleetLog.beginEntry(subject, planet);
185// message.getSection1().addPara(getString(text1));
186// FleetLog.addToLog(message, text);
187
188 //unsetData();
189 setDone(true);
190 }
191
192
193 @Override
194 public void optionSelected(String optionText, Object optionData) {
195 super.optionSelected(optionText, optionData);
196 }
197
198
199
200}
static SettingsAPI getSettings()
Definition Global.java:57
static SectorAPI getSector()
Definition Global.java:65
static PlanetAPI findInterestingPlanet(List< StarSystemAPI > systems, Set< PlanetAPI > exclude)
static String getInterestingCondition(PlanetAPI planet, boolean includeRuins)
static List< StarSystemAPI > getSystemsInRange(SectorEntityToken from, Set< StarSystemAPI > exclude, boolean nonEmpty, float maxRange)
Definition Misc.java:3654
static void addSurveyDataFor(PlanetAPI planet, TextPanelAPI text)
Definition Misc.java:2984
static void setFullySurveyed(MarketAPI market, TextPanelAPI text, boolean withNotification)
Definition Misc.java:3003
MarketConditionSpecAPI getMarketConditionSpec(String conditionId)
Object getNewPluginInstance(String id)
StarSystemAPI getStarSystem(String name)
SectorEntityToken getEntityById(String id)
void addXP(long xp, TextPanelAPI textPanel, boolean withMessage, boolean allowBonusXP, boolean withLevelUp)
MutableCharacterStatsAPI getStats()
void init(CampaignFleetAPI fleet, PlanetAPI planet)