Starsector API
Loading...
Searching...
No Matches
GateHaulerIntel.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.misc;
2
3import java.awt.Color;
4import java.util.ArrayList;
5import java.util.List;
6import java.util.Set;
7
8import org.lwjgl.util.vector.Vector2f;
9
10import com.fs.starfarer.api.Global;
11import com.fs.starfarer.api.campaign.CampaignFleetAPI;
12import com.fs.starfarer.api.campaign.CampaignTerrainAPI;
13import com.fs.starfarer.api.campaign.FactionAPI;
14import com.fs.starfarer.api.campaign.PlanetAPI;
15import com.fs.starfarer.api.campaign.SectorEntityToken;
16import com.fs.starfarer.api.campaign.StarSystemAPI;
17import com.fs.starfarer.api.campaign.comm.IntelInfoPlugin;
18import com.fs.starfarer.api.campaign.rules.MemoryAPI;
19import com.fs.starfarer.api.impl.campaign.entities.GateHaulerEntityPlugin;
20import com.fs.starfarer.api.impl.campaign.ids.Drops;
21import com.fs.starfarer.api.impl.campaign.ids.Entities;
22import com.fs.starfarer.api.impl.campaign.ids.Factions;
23import com.fs.starfarer.api.impl.campaign.ids.Tags;
24import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin;
25import com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator;
26import com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator.AddedEntity;
27import com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator.EntityLocation;
28import com.fs.starfarer.api.impl.campaign.procgen.themes.BaseThemeGenerator.OrbitGap;
29import com.fs.starfarer.api.impl.campaign.rulecmd.missions.GateHaulerCMD;
30import com.fs.starfarer.api.impl.campaign.terrain.DebrisFieldTerrainPlugin.DebrisFieldParams;
31import com.fs.starfarer.api.impl.campaign.terrain.DebrisFieldTerrainPlugin.DebrisFieldSource;
32import com.fs.starfarer.api.loading.Description;
33import com.fs.starfarer.api.loading.Description.Type;
34import com.fs.starfarer.api.ui.Alignment;
35import com.fs.starfarer.api.ui.SectorMapAPI;
36import com.fs.starfarer.api.ui.TooltipMakerAPI;
37import com.fs.starfarer.api.util.Misc;
38
39public class GateHaulerIntel extends BaseIntelPlugin {
40
41 public static float TRANSIT_DAYS_BASE = 100;
42 public static float TRANSIT_SPEED_LY_PER_CYCLE = 50;
43
44
45 public static Object UPDATE_WITNESSED_ARRIVAL = new Object();
46
47 public static enum GateHaulerAction {
48 OUTBOUND,
49 DEEP_SPACE_TRANSIT,
50 INBOUND,
51 DEPLOYING,
52 }
53
54 public static GateHaulerIntel get(SectorEntityToken gateHauler) {
55 for (IntelInfoPlugin p : Global.getSector().getIntelManager().getIntel(GateHaulerIntel.class)) {
56 if (p instanceof GateHaulerIntel) {
58 if (intel.getGateHauler() == gateHauler) {
59 return intel;
60 }
61 }
62 }
63 return null;
64 }
65
66 protected SectorEntityToken gateHauler;
67 protected StarSystemAPI destination;
68 protected float departureAngle;
69 protected int transitDays;
70 protected float elapsedDaysInAction;
71 protected SectorEntityToken parkingOrbit;
72 protected SectorEntityToken stableLocation;
73 protected GateHaulerAction action = null;
74
75 //protected CampaignEntityMovementUtil movement;
76
77 public GateHaulerIntel(SectorEntityToken gateHauler) {
78 this.gateHauler = gateHauler;
79 Global.getSector().addScript(this);
80
81 //movement = new CampaignEntityMovementUtil(gateHauler, 0.5f, 3f, 5f, 2000f);
82 }
83
84 @Override
85 protected void notifyEnded() {
86 super.notifyEnded();
87 Global.getSector().removeScript(this);
88 }
89
90 public void updateMemoryFlags() {
91// MemoryAPI mem = gateHauler.getMemoryWithoutUpdate();
92// mem.set("$state", state.name());
93// if (state == GateHaulerState.OUTBOUND || state == GateHaulerState.INBOUND) {
94// mem.set("$inTransit", true);
95// } else {
96// mem.unset("$inTransit");
97// }
98 }
99
100 public void activate() {
101 // don't actually need to do anything; all handled in the entity plugin and rules
102 }
103
104 public int computeTransitDays(StarSystemAPI destination) {
105 //if (Global.getSettings().isDevMode()) return 1;
106
107 if (destination == null) return 0;
108
109 float dist = Misc.getDistanceLY(gateHauler, destination.getHyperspaceAnchor());
111 return Math.round(transitDays);
112 }
113
114 public void initiateDeployment(SectorEntityToken stableLocation) {
115 if (stableLocation == null) return;
116
117 setAction(GateHaulerAction.DEPLOYING);
118 this.stableLocation = stableLocation;
119
120 getPlugin().getMovement().moveToLocation(stableLocation.getLocation());
121 getPlugin().getMovement().setFaceInOppositeDirection(false);
122 getPlugin().getMovement().setTurnThenAccelerate(true);
123 getPlugin().setLongBurn(false);
124
125 gateHauler.getMemoryWithoutUpdate().set("$deploying", true);
126
127
128 gateHauler.fadeOutIndicator();
129 gateHauler.addTag(Tags.NON_CLICKABLE);
130 //gateHauler.addTag(Tags.NO_ENTITY_TOOLTIP);
131
132 stableLocation.fadeOutIndicator();
133 stableLocation.addTag(Tags.NON_CLICKABLE);
134 stableLocation.addTag(Tags.NO_ENTITY_TOOLTIP);
135 }
136
137 public void initiateDeparture(StarSystemAPI destination) {
138 if (destination == null || destination == gateHauler.getContainingLocation()) return;
139
140 setAction(GateHaulerAction.OUTBOUND);
141 if (parkingOrbit != null) {
142 gateHauler.getContainingLocation().removeEntity(parkingOrbit);
143 parkingOrbit = null;
144 }
145
147 this.destination = destination;
148
149 departureAngle = Misc.getAngleInDegrees(gateHauler.getLocationInHyperspace(), destination.getLocation());
150
151 gateHauler.fadeOutIndicator();
152 getPlugin().getMovement().moveInDirection(departureAngle);
153 getPlugin().getMovement().setFaceInOppositeDirection(false);
154 getPlugin().getMovement().setTurnThenAccelerate(true);
155 getPlugin().setLongBurn(true);
156
157 gateHauler.getMemoryWithoutUpdate().set("$inTransit", true);
158 }
159
160 public void initiateArrival() {
161 if (destination == null) return; // something's badly wrong and the gate hauler is probably gone for good
162
163 setAction(GateHaulerAction.INBOUND);
164
166
167 float brakeTime = GateHaulerEntityPlugin.MAX_SPEED / GateHaulerEntityPlugin.ACCELERATION;
168 float brakeDist = GateHaulerEntityPlugin.MAX_SPEED * 0.5f * brakeTime;
169
170 Vector2f spawnLoc = Misc.getUnitVectorAtDegreeAngle(departureAngle + 180f);
171 Vector2f spawnVel = new Vector2f(spawnLoc);
172
173 spawnVel.scale(GateHaulerEntityPlugin.MAX_SPEED);
174 spawnVel.negate();
175 spawnLoc.scale(brakeDist * 1f + 4000f);
176 Vector2f.add(spawnLoc, parkingOrbit.getLocation(), spawnLoc);
177
178 gateHauler.setExpired(false);
179 gateHauler.removeTag(Tags.NON_CLICKABLE);
180 gateHauler.removeTag(Tags.FADING_OUT_AND_EXPIRING);
181 gateHauler.setAlwaysUseSensorFaderBrightness(null);
182
183 if (!destination.getAllEntities().contains(gateHauler)) {
184 destination.addEntity(gateHauler);
185 }
186
187 gateHauler.fadeOutIndicator();
188
189 getPlugin().getMovement().setLocation(spawnLoc);
190 getPlugin().getMovement().setVelocity(spawnVel);
191 getPlugin().getMovement().setFacing(departureAngle + 180f);
192
193 getPlugin().getMovement().moveToLocation(parkingOrbit.getLocation());
194 getPlugin().getMovement().setTurnThenAccelerate(true);
195 getPlugin().getMovement().setFaceInOppositeDirection(true);
196 getPlugin().setLongBurn(true);
197 }
198
199 protected void findParkingOrbit() {
200 float minDist = 4000f;
201 float maxDist = 8000f;
202 parkingOrbit = null;
203 SectorEntityToken found = null;
204 for (SectorEntityToken curr : destination.getEntitiesWithTag(Tags.STABLE_LOCATION)) {
205 float dist = curr.getLocation().length();
206 if (dist >= minDist && dist <= 8000f) {
207 found = curr;
208 break;
209 }
210 }
211 if (found == null) {
212 for (PlanetAPI curr : destination.getPlanets()) {
213 if (curr.isMoon()) continue;
214 float dist = curr.getLocation().length();
215 if (dist >= minDist && dist <= 8000f) {
216 found = curr;
217 break;
218 }
219 }
220 }
221
222 if (found != null) {
223 Vector2f loc = Misc.getPointAtRadius(found.getLocation(), found.getRadius() + 400f);
224 parkingOrbit = destination.createToken(loc);
225 float orbitRadius = found.getRadius() + 250f;
226 float orbitDays = orbitRadius / (20f + Misc.random.nextFloat() * 5f);
227 parkingOrbit.setCircularOrbit(found, Misc.random.nextFloat() * 360f, orbitRadius, orbitDays);
228 } else {
229 List<OrbitGap> gaps = BaseThemeGenerator.findGaps(
230 destination.getCenter(), minDist, maxDist, gateHauler.getRadius() + 50f);
231 if (!gaps.isEmpty()) {
232 OrbitGap gap = gaps.get(0);
233 float orbitRadius = (gap.start + gap.end) * 0.5f;
234 Vector2f loc = Misc.getPointAtRadius(destination.getCenter().getLocation(), orbitRadius);
235 parkingOrbit = destination.createToken(loc);
236
237 if (!destination.isNebula()) {
238 float orbitDays = orbitRadius / (20f + Misc.random.nextFloat() * 5f);
239 parkingOrbit.setCircularOrbit(destination.getCenter(), Misc.random.nextFloat() * 360f, orbitRadius, orbitDays);
240 }
241 }
242 }
243
244 if (parkingOrbit == null) {
245 float orbitRadius = minDist + (maxDist - minDist) * Misc.random.nextFloat();
246 Vector2f loc = Misc.getPointAtRadius(destination.getCenter().getLocation(), orbitRadius);
247 parkingOrbit = destination.createToken(loc);
248
249 if (!destination.isNebula()) {
250 float orbitDays = orbitRadius / (20f + Misc.random.nextFloat() * 5f);
251 parkingOrbit.setCircularOrbit(destination.getCenter(), Misc.random.nextFloat() * 360f, orbitRadius, orbitDays);
252 }
253 }
254
255 destination.addEntity(parkingOrbit);
256 }
257
258 protected void setAction(GateHaulerAction action) {
259 this.action = action;
261 }
262
263 public GateHaulerEntityPlugin getPlugin() {
264 return (GateHaulerEntityPlugin) gateHauler.getCustomPlugin();
265 }
266
267 @Override
268 public void advance(float amount) {
269 super.advance(amount);
270
271 if (action != null) {
272 float days = Misc.getDays(amount);
273 elapsedDaysInAction += days;
274
275 gateHauler.fadeOutIndicator();
276 if (action == GateHaulerAction.DEPLOYING && stableLocation != null) {
277 stableLocation.fadeOutIndicator();
278 }
279 }
280
281 //System.out.println("Gate Hauler speed: " + gateHauler.getVelocity().length() + ", loc: " + gateHauler.getLocation());
282 //System.out.println("Loc: " + gateHauler.getLocation());
283 //System.out.println("Player speed: " + Global.getSector().getPlayerFleet().getVelocity().length());
284 if (action == GateHaulerAction.OUTBOUND) {
285 float speed = gateHauler.getVelocity().length();
286 float dist = gateHauler.getLocation().length();
287 CampaignFleetAPI pf = Global.getSector().getPlayerFleet();
288 boolean nearPlayer = pf != null && gateHauler.isInCurrentLocation() &&
289 Misc.getDistance(pf, gateHauler) < 10000f;
290 if (!nearPlayer && elapsedDaysInAction > 20f &&
291 speed >= GateHaulerEntityPlugin.MAX_SPEED * 0.95f && dist > 40000f) {
292 Misc.fadeAndExpire(gateHauler);
293 setAction(GateHaulerAction.DEEP_SPACE_TRANSIT);
294 sendUpdateIfPlayerHasIntel(GateHaulerAction.DEEP_SPACE_TRANSIT, false);
295 }
296 }
297
298 if (action == GateHaulerAction.DEEP_SPACE_TRANSIT) {
301 sendUpdateIfPlayerHasIntel(GateHaulerAction.INBOUND, false);
302 }
303 }
304
305 if (action == GateHaulerAction.INBOUND) {
306 getPlugin().getMovement().moveToLocation(parkingOrbit.getLocation());
307 float speed = gateHauler.getVelocity().length();
308 float dist = Misc.getDistance(parkingOrbit, gateHauler);
309
310 boolean overshot = Misc.isInArc(gateHauler.getFacing(), 270f,
311 gateHauler.getLocation(), parkingOrbit.getLocation());
312 if (overshot || dist < 700f) {
313 getPlugin().getMovement().setTurnThenAccelerate(false);
314 getPlugin().getMovement().setFaceInOppositeDirection(false);
315 }
316 boolean closeEnough = speed < 20f && dist < 100f + parkingOrbit.getRadius() + gateHauler.getRadius();
317 if (dist < 200f + parkingOrbit.getRadius() + gateHauler.getRadius() && elapsedDaysInAction > 30f) {
318 closeEnough = true;
319 }
320 if (closeEnough) {
321 setAction(null);
322 destination = null;
323 gateHauler.fadeInIndicator();
324 getPlugin().getMovement().setFaceInOppositeDirection(false);
325 getPlugin().setLongBurn(false);
326 float orbitAngle = Misc.getAngleInDegrees(parkingOrbit.getLocation(), gateHauler.getLocation());
327 float orbitDays = 1000000f;
328 gateHauler.setCircularOrbit(parkingOrbit, orbitAngle, dist, orbitDays);
329
330 if (!gateHauler.isInCurrentLocation()) {
331 for (int i = 0; i < 10; i++) {
332 getPlugin().getEngineGlow().showIdling();
333 getPlugin().getEngineGlow().advance(1f);
334 }
335 }
336 gateHauler.getMemoryWithoutUpdate().unset("$inTransit");
337
338 if (gateHauler.isInCurrentLocation()) {
339 String key = "$witnessedGateHaulerArrival";
340 MemoryAPI mem = Global.getSector().getPlayerMemoryWithoutUpdate();
341 if (!mem.getBoolean(key)) {
342 float distToPlayer = Misc.getDistance(Global.getSector().getPlayerFleet(), gateHauler);
343 if (distToPlayer < 2000f) {
345 Global.getSector().getPlayerStats().addStoryPoints(1, null, false);
346 mem.set(key, true);
347 }
348 }
349 }
350 }
351 }
352
353
354 if (action == GateHaulerAction.DEPLOYING) {
355 if (gateHauler.getOrbit() == null) {
356 getPlugin().getMovement().moveToLocation(stableLocation.getLocation());
357 }
358
359 if (elapsedDaysInAction > 1f) {
360 if (gateHauler.getOrbit() == null) {
361 float speed = gateHauler.getVelocity().length();
362 float dist = Misc.getDistance(stableLocation, gateHauler);
363
364 if (dist < 1000f) {
365 getPlugin().getMovement().setTurnThenAccelerate(false);
366 }
367 float test = 100f;
368 if (!gateHauler.isInCurrentLocation()) test = 400f;
369 boolean closeEnough = speed < 20f && dist < test + stableLocation.getRadius() + gateHauler.getRadius();
370 if (dist < 500f + stableLocation.getRadius() + gateHauler.getRadius() +
371 (elapsedDaysInAction - 50f) * 50f && elapsedDaysInAction > 50f) {
372 closeEnough = true;
373 }
374 if (closeEnough) {
375 float orbitAngle = Misc.getAngleInDegrees(stableLocation.getLocation(), gateHauler.getLocation());
376 float orbitDays = 1000000f;
377 gateHauler.setCircularOrbit(stableLocation, orbitAngle, dist, orbitDays);
379 }
380 } else {
381 // set the orbit and waited a day; deploy
382 setAction(null);
383
385
386 EntityLocation loc = new EntityLocation();
387 if (stableLocation.getOrbit() != null) {
388 loc.orbit = stableLocation.getOrbit().makeCopy();
389 } else {
390 loc.location = new Vector2f(stableLocation.getLocation());
391 }
392 AddedEntity added = BaseThemeGenerator.addNonSalvageEntity(
393 stableLocation.getStarSystem(), loc, Entities.INACTIVE_GATE, Factions.NEUTRAL);
394
395 gateHauler.getMemoryWithoutUpdate().unset("$deploying");
396 gateHauler.addTag(Tags.NO_ENTITY_TOOLTIP);
397 Misc.fadeAndExpire(gateHauler, 10f);
398 Misc.fadeAndExpire(stableLocation, 10f);
400
401 if (added.entity != null) {
402 Misc.fadeIn(added.entity, 3f);
403 }
404 }
405 }
406 }
407 }
408
409
410 protected void addDebrisField() {
411 if (stableLocation == null) return;
412
413 DebrisFieldParams params = new DebrisFieldParams(
414 400f, // field radius - should not go above 1000 for performance reasons
415 -1f, // density, visual - affects number of debris pieces
416 3f, // duration in days
417 0f); // days the field will keep generating glowing pieces
418 params.source = DebrisFieldSource.MIXED;
419 params.density = 1f;
420 params.baseSalvageXP = (long) 500; // base XP for scavenging in field
421
422 SectorEntityToken debris = (CampaignTerrainAPI) Misc.addDebrisField(
423 stableLocation.getContainingLocation(), params, null);
424
425 debris.setDiscoverable(null);
426 debris.setDiscoveryXP(null);
427
428 debris.addDropValue(Drops.EXTENDED, 100000);
429
430 debris.getLocation().set(stableLocation.getLocation());
431 if (stableLocation.getOrbit() != null) {
432 debris.setOrbit(stableLocation.getOrbit().makeCopy());
433 }
434 }
435
436
437
438 protected void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode) {
439
440 Color h = Misc.getHighlightColor();
441 Color g = Misc.getGrayColor();
442 float pad = 3f;
443 float opad = 10f;
444
445 FactionAPI faction = getFactionForUIColors();
446 Color base = faction.getBaseUIColor();
447 Color dark = faction.getDarkUIColor();
448
449 float initPad = pad;
450 if (mode == ListInfoMode.IN_DESC) initPad = opad;
451
452 Color tc = getBulletColorForMode(mode);
453
454 bullet(info);
455 boolean isUpdate = getListInfoParam() != null;
456
457 if (isUpdate) {
458 if (getListInfoParam() == GateHaulerAction.DEEP_SPACE_TRANSIT) {
459 info.addPara("Entered open space", tc, initPad);
460 String dStr = "days";
461 if (transitDays == 1) dStr = "day";
462 info.addPara("Estimated %s " + dStr + " to complete transit", initPad, tc,
463 h, "" + transitDays);
464 return;
465 }
466 if (getListInfoParam() == GateHaulerAction.INBOUND) {
467 info.addPara("Arrived at " + destination.getNameWithLowercaseType(), tc, initPad);
468 return;
469 }
471 info.addPara("Witnessed the arrival of a Gate Hauler to a star system", tc, initPad);
472 return;
473 }
474 }
475
476 if (mode == ListInfoMode.INTEL) {
477 String locStr = gateHauler.getContainingLocation().getNameWithLowercaseTypeShort();
478 if (gateHauler.getContainingLocation() != null && gateHauler.getContainingLocation().isDeepSpace()) {
479 locStr = "deep space";
480 } else if (gateHauler.getContainingLocation() != null) {
481 locStr = gateHauler.getContainingLocation().getNameWithLowercaseTypeShort();
482 }
483 if (getPlugin().isInTransit() && action == GateHaulerAction.DEEP_SPACE_TRANSIT) {
484 locStr = "transiting deep space";
485 }
486
487 info.addPara("Location: " + locStr, tc, initPad);
488 initPad = 0f;
489
490 GateHaulerEntityPlugin plugin = getPlugin();
491 if (!plugin.isActivated()) {
492 info.addPara("Status: dormant", tc, initPad);
493 } else if (plugin.isActivating()) {
494 info.addPara("Status: activating", tc, initPad);
495 } else if (action == null) {
496 info.addPara("Status: operational", tc, initPad);
497 } else if (action == GateHaulerAction.OUTBOUND) {
498 info.addPara("Departing current location", tc, initPad);
499
500 String dStr = "days";
501 if (transitDays == 1) dStr = "day";
502 info.addPara("Estimated %s " + dStr + " for transit", initPad, tc,
503 h, "" + transitDays);
504 } else if (action == GateHaulerAction.DEEP_SPACE_TRANSIT) {
505 String dStr = "days";
506 int daysRemaining = (int) Math.round(transitDays - elapsedDaysInAction);
507 if (daysRemaining < 1) daysRemaining = 1;
508 if (daysRemaining == 1) dStr = "day";
509 info.addPara("Estimated %s " + dStr + " to complete transit", initPad, tc,
510 h, "" + daysRemaining);
511 } else if (action == GateHaulerAction.INBOUND) {
512 info.addPara("Arriving at " + destination.getNameWithLowercaseType(), tc, initPad);
513 }
514 }
515
516// if (GateEntityPlugin.isScanned(gateHauler)) {
517// info.addPara("Scanned", tc, initPad);
518// initPad = 0f;
519// }
520
521 unindent(info);
522 }
523
524
525 @Override
526 public void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode) {
527 String pre = "";
528 String post = "";
529// if (mode == ListInfoMode.MESSAGES && !getPlugin().isActivated()) {
530// pre = "Discovered: ";
531// }
532
533 Color c = getTitleColor(mode);
534 info.addPara(pre + getName() + post, c, 0f);
535 addBulletPoints(info, mode);
536 }
537
538 @Override
539 public void createSmallDescription(TooltipMakerAPI info, float width, float height) {
540 Color h = Misc.getHighlightColor();
541 Color g = Misc.getGrayColor();
542 Color tc = Misc.getTextColor();
543 float pad = 3f;
544 float opad = 10f;
545
546 if (gateHauler.getCustomInteractionDialogImageVisual() != null) {
547 info.addImage(gateHauler.getCustomInteractionDialogImageVisual().getSpriteName(), width, opad);
548 }
549
550 Description desc = Global.getSettings().getDescription(gateHauler.getCustomDescriptionId(), Type.CUSTOM);
551 info.addPara(desc.getText1(), opad);
552
553 FactionAPI faction = getFactionForUIColors();
554 Color base = faction.getBaseUIColor();
555 Color dark = faction.getDarkUIColor();
556
557 info.addSectionHeading("Status", base, dark, Alignment.MID, opad);
558
559 GateHaulerEntityPlugin plugin = getPlugin();
560 if (!plugin.isActivated()) {
561 GateHaulerCMD cmd = new GateHaulerCMD();
562 info.addPara("The gate hauler is dormant, its systems shut down to conserve power.", opad);
563 info.showCost("Resources required to activate:", false, base, dark, opad, cmd.getResources(), cmd.getQuantities());
564 } else if (plugin.isActivating()) {
565 info.addPara("The gate hauler is in the process of reactivating its systems and should be operational "
566 + "within a day.", opad);
567 } else if (action == null) {
568 info.addPara("The gate hauler is operational and ready to travel to another star system or "
569 + "deploy its gate at a stable location.", opad);
570 } else if (action == GateHaulerAction.OUTBOUND) {
571 info.addPara("The gate hauler is outbound from its current location, "
572 + "heading for open space and accelerating.", opad);
573
574 String dStr = "days";
575 if (transitDays == 1) dStr = "day";
576 info.addPara("Once it's in open space, it's estimated that it will take %s " + dStr + " until it arrives "
577 + "to its destination, the " + destination.getNameWithLowercaseTypeShort() + ". On arrival, "
578 + "it will take some time to decelerate and attain a parking orbit.", opad,
579 h, "" + transitDays);
580 } else if (action == GateHaulerAction.DEEP_SPACE_TRANSIT) {
581 String dStr = "days";
582 int daysRemaining = (int) Math.round(transitDays - elapsedDaysInAction);
583 if (daysRemaining < 1) daysRemaining = 1;
584 if (daysRemaining == 1) dStr = "day";
585 info.addPara("The gate hauler is in transit, in deep space. It's estimated that it will take %s " + dStr + " until it arrives "
586 + "to its destination, the " + destination.getNameWithLowercaseTypeShort() + ". On arrival, "
587 + "it will take some time to decelerate and attain a parking orbit.", opad,
588 h, "" + daysRemaining);
589 } else if (action == GateHaulerAction.INBOUND) {
590 info.addPara("The gate hauler has arrived to the " + destination.getNameWithLowercaseTypeShort() + " "
591 + "and is decelerating in order to attain a parking orbit.", opad);
592 } else if (action == GateHaulerAction.DEPLOYING) {
593 info.addPara("The gate hauler has been given an order to deploy its gate.", opad);
594 }
595
596
597 //addBulletPoints(info, ListInfoMode.IN_DESC);
598
599 }
600
601 @Override
602 public String getIcon() {
603 return Global.getSettings().getSpriteName("intel", "gate_hauler");
604 }
605
606 @Override
607 public Set<String> getIntelTags(SectorMapAPI map) {
608 Set<String> tags = super.getIntelTags(map);
609 tags.add(Tags.INTEL_GATES);
610 tags.add(Tags.INTEL_EXPLORATION);
611 return tags;
612 }
613
614 public String getSortString() {
615 return super.getSortString();
616 }
617
618
619 public String getName() {
620 return "Gate Hauler";
621 }
622
623 @Override
624 public FactionAPI getFactionForUIColors() {
625 return gateHauler.getFaction();
626 //return super.getFactionForUIColors();
627 }
628
629 public String getSmallDescriptionTitle() {
630 //return getName() + " - " + gateHauler.getContainingLocation().getNameWithTypeShort();
631 return getName();
632 }
633
634 @Override
635 public SectorEntityToken getMapLocation(SectorMapAPI map) {
636 if (!gateHauler.isAlive() && destination != null) {
637 return destination.getCenter();
638 }
639 return gateHauler;
640 }
641
642 @Override
643 public String getCommMessageSound() {
644 return "ui_discovered_entity";
645 }
646
647 public SectorEntityToken getGateHauler() {
648 return gateHauler;
649 }
650
651 @Override
652 public List<ArrowData> getArrowData(SectorMapAPI map) {
653 if (destination == null || action == null) {
654 return null;
655 }
656
657 boolean showArrow = action == GateHaulerAction.OUTBOUND || action == GateHaulerAction.DEEP_SPACE_TRANSIT;
658 if (!showArrow) return null;
659
660 if (gateHauler.getContainingLocation() == destination) {
661 return null;
662 }
663
664 List<ArrowData> result = new ArrayList<ArrowData>();
665
666 ArrowData arrow = new ArrowData(gateHauler, destination.getCenter());
667 arrow.color = getFactionForUIColors().getBaseUIColor();
668 arrow.width = 20f;
669 result.add(arrow);
670
671 return result;
672 }
673
674
675
676}
677
678
679
680
681
682
683
static SettingsAPI getSettings()
Definition Global.java:51
static SectorAPI getSector()
Definition Global.java:59
void sendUpdateIfPlayerHasIntel(Object listInfoParam, TextPanelAPI textPanel)
void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode)
void createSmallDescription(TooltipMakerAPI info, float width, float height)
void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode)
Description getDescription(String id, Type type)
String getSpriteName(String category, String id)