1package com.fs.starfarer.api.impl.campaign.rulecmd.salvage.special;
3import org.lwjgl.util.vector.Vector2f;
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.campaign.CampaignTerrainAPI;
7import com.fs.starfarer.api.campaign.CustomCampaignEntityAPI;
8import com.fs.starfarer.api.campaign.InteractionDialogAPI;
9import com.fs.starfarer.api.campaign.JumpPointAPI;
10import com.fs.starfarer.api.campaign.LocationAPI;
11import com.fs.starfarer.api.campaign.PlanetAPI;
12import com.fs.starfarer.api.campaign.SectorEntityToken;
13import com.fs.starfarer.api.campaign.StarSystemAPI;
14import com.fs.starfarer.api.combat.ShipAPI.HullSize;
15import com.fs.starfarer.api.combat.ShipVariantAPI;
16import com.fs.starfarer.api.impl.campaign.DerelictShipEntityPlugin;
17import com.fs.starfarer.api.impl.campaign.ids.Entities;
18import com.fs.starfarer.api.impl.campaign.ids.Tags;
19import com.fs.starfarer.api.impl.campaign.ids.Terrain;
20import com.fs.starfarer.api.impl.campaign.intel.misc.BreadcrumbIntelV2;
21import com.fs.starfarer.api.impl.campaign.intel.misc.SalvorsTallyIntel;
22import com.fs.starfarer.api.impl.campaign.procgen.Constellation;
23import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.SalvageSpecialInteraction.SalvageSpecialData;
24import com.fs.starfarer.api.impl.campaign.rulecmd.salvage.SalvageSpecialInteraction.SalvageSpecialPlugin;
25import com.fs.starfarer.api.impl.campaign.terrain.DebrisFieldTerrainPlugin;
26import com.fs.starfarer.api.util.CountingMap;
27import com.fs.starfarer.api.util.Misc;
32 public static class BreadcrumbSpecialData
implements SalvageSpecialData {
33 public String targetId =
null;
34 public String targetName =
null;
35 public BreadcrumbSpecialData(String targetId) {
36 this.targetId = targetId;
39 public SalvageSpecialPlugin createSpecialPlugin() {
47 private BreadcrumbSpecialData data;
55 super.init(
dialog, specialData);
57 data = (BreadcrumbSpecialData) specialData;
62 private void initEntityLocation() {
63 if (data.targetId ==
null) {
87 String targetNameUC =
getNameWithAOrAn(target, data.targetName,
false,
true);
91 String nameForTitle = targetNameUC.substring(targetNameUC.indexOf(
" ") + 1);
93 String subject =
getString(
"Location: " + nameForTitle);
100 String text1 =
"The $shortName's memory banks are partially accessible, and ";
101 text1 +=
"contain information indicating that " + targetName +
" is " + located +
".";
103 String text1ForIntel =
"While exploring $aOrAn $nameInText, your crews found a " +
104 "partially accessible memory bank " +
105 "containing information that indicates " + targetName +
" is " + located +
".";
109 text1 =
"Your salvage crews find a functional memory bank in the debris. It contains information " +
110 "indicating that " + targetName.toLowerCase() +
" is " + located +
".";
115 DerelictShipEntityPlugin dsep = (DerelictShipEntityPlugin) target.
getCustomPlugin();
116 ShipVariantAPI variant = dsep.getData().ship.variant;
117 if (variant ==
null && dsep.getData().ship.variantId !=
null) {
118 variant = Global.getSettings().getVariant(dsep.getData().ship.variantId);
120 if (variant !=
null) {
122 if (variant.getHullSize() == HullSize.FRIGATE ||
123 variant.getHullSize() == HullSize.DESTROYER) {
124 size =
"Based on the information, it's likely the ship is small, a frigate or a destroyer at the largest.";
126 size =
"The vessel is likely to be at least cruiser-sized.";
130 text1 +=
"\n\n" + size;
131 text1ForIntel +=
"\n\n" + size;
138 BreadcrumbIntelV2 intel =
new BreadcrumbIntelV2(target);
143 String iconId =
null;
144 if (target instanceof CampaignTerrainAPI &&
145 ((CampaignTerrainAPI)target).getPlugin() instanceof DebrisFieldTerrainPlugin) {
146 iconId =
"link_to_debris_field";
148 if (iconId ==
null) {
149 boolean wreck = SalvorsTallyIntel.isDerelictShip(target);
150 boolean station = SalvorsTallyIntel.isOrbitalInstallation(target);
151 if (target instanceof PlanetAPI) {
152 iconId =
"link_to_ruins";
154 iconId =
"link_to_derelict_ship";
155 }
else if (station) {
156 iconId =
"link_to_orbital_installation";
158 iconId =
"link_to_other";
162 if (iconId !=
null) {
164 intel.setIconId(iconId);
166 Global.getSector().getIntelManager().addIntel(intel,
false,
text);
178 String targetAOrAn =
"a";
179 String targetName = override;
180 if (targetName ==
null) {
184 if (forTitle) targetName = custom.
getName();
186 }
else if (target instanceof
PlanetAPI) {
189 targetName +=
" with unexplored ruins";
197 targetName = targetName.toLowerCase();
199 return targetAOrAn +
" " + targetName;
208 String orbiting =
"";
209 boolean useTerrain =
false;
215 if (!focus.
isStar() || !isPrimary) {
221 orbiting =
"located in the heart of ";
222 }
else if (dist > 12000) {
223 orbiting =
"located in the outer reaches of ";
226 orbiting =
"located some distance away from the center of ";
234 orbiting =
"orbiting a jump-point in ";
239 orbiting =
"located inside " + a +
" " + n +
" ";
243 orbiting +=
"in the heart of ";
244 }
else if (dist > 12000) {
245 orbiting +=
"in the outer reaches of ";
247 orbiting +=
"some distance away from the center of ";
253 orbiting =
"located in the heart of ";
254 }
else if (dist > 12000) {
255 orbiting =
"located in the outer reaches of ";
258 orbiting =
"located some distance away from the center of ";
265 orbiting =
"located in the heart of ";
266 }
else if (dist > 12000) {
267 orbiting =
"located on the outskirts of ";
270 orbiting =
"located some distance away from the center of ";
277 if (terrainString !=
null) {
278 orbiting =
"located in " + terrainString +
" in ";
282 if (orbiting ==
null || orbiting.isEmpty()) orbiting =
"located in ";
283 return orbiting + loc;
291 if (!terrain.getPlugin().containsEntity(
entity))
continue;
293 String type = terrain.getType();
299 if (
Terrain.
RING.equals(type))
return "a ring system";
308 return "an unknown location";
332 return "a nebula " + cText;
336 return "a trinary star system " + cText;
340 return "a binary star system " + cText;
346 return "a black hole system " + cText;
354 String sysText =
null;
356 int cColor = counts.
getCount(color);
358 if (cColor > 1 && cType > cColor) {
359 sysText =
"a system with " + star.
getSpec().
getAOrAn() +
" " + color +
" primary star ";
360 }
else if (cType > 0) {
361 sysText =
"a system with " +
"a" +
" " + type +
" primary star ";
362 }
else if (cColor > 0) {
363 sysText =
"a system with " + star.
getSpec().
getAOrAn() +
" " + color +
" primary star ";
366 if (sysText !=
null) {
367 return sysText + cText;
380 if (system.isNebula())
continue;
381 if (system.getSecondary() !=
null)
continue;
382 if (system.getTertiary() !=
null)
continue;
386 if (type !=
null) map.
add(type);
387 if (color !=
null) map.
add(color);
394 if (name.contains(
" dwarf")) {
396 }
else if (name.contains(
" star")) {
398 }
else if (name.contains(
" giant")) {
400 }
else if (name.contains(
" supergiant")) {
407 if (name.contains(
" dwarf")) {
408 name = name.replace(
" dwarf",
"");
409 }
else if (name.contains(
" star")) {
410 name = name.replace(
" star",
"");
411 }
else if (name.contains(
" giant")) {
412 name = name.replace(
" giant",
"");
413 }
else if (name.contains(
" supergiant")) {
414 name = name.replace(
" supergiant",
"");
460 super.optionSelected(optionText, optionData);
static SectorAPI getSector()
static final String ASTEROID_BELT
static final String ASTEROID_FIELD
List< StarSystemAPI > getSystems()
String getNameWithLowercaseType()
void setDone(boolean done)
InteractionDialogAPI dialog
void addText(String format)
String getString(String format)
static String getTerrainString(SectorEntityToken entity)
void init(InteractionDialogAPI dialog, Object specialData)
static CountingMap< String > getTypeAndColorCounts(Constellation c)
static String getStarTypeName(PlanetAPI star)
void optionSelected(String optionText, Object optionData)
static String getStarColorName(PlanetAPI star)
static String getLocatedString(SectorEntityToken target, boolean withSystem)
static String getLocationDescription(SectorEntityToken entity, boolean withSystem)
static String getNameWithAOrAn(SectorEntityToken target, String override, boolean lowercaseDebris, boolean forTitle)
static String getLocatedString(SectorEntityToken target)
void add(K key, int quantity)
static MarketConditionSpecAPI getRuinsSpec(MarketAPI market)
static String getAOrAnFor(String word)
static float getDistance(SectorEntityToken from, SectorEntityToken to)
static boolean hasUnexploredRuins(MarketAPI market)
CampaignTerrainPlugin getPlugin()
String getNameForTooltip()
String getNameWithLowercaseType()
List< CampaignTerrainAPI > getTerrainCopy()
String getTypeNameWithLowerCaseWorld()
String getTypeNameWithWorld()
SectorEntityToken getEntityById(String id)
LocationAPI getContainingLocation()
CustomCampaignEntityPlugin getCustomPlugin()
boolean isInCurrentLocation()
String getCustomEntityType()
boolean hasSensorProfile()
SectorEntityToken getOrbitFocus()
Constellation getConstellation()
boolean hasTag(String tag)
CustomEntitySpecAPI getCustomEntitySpec()