Starsector API
Loading...
Searching...
No Matches
FGWaitAction.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel.group;
2
3import java.util.List;
4
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.campaign.CampaignFleetAPI;
7import com.fs.starfarer.api.campaign.FleetAssignment;
8import com.fs.starfarer.api.campaign.SectorEntityToken;
9import com.fs.starfarer.api.impl.campaign.fleets.RouteManager.RouteData;
10import com.fs.starfarer.api.impl.campaign.fleets.RouteManager.RouteSegment;
11import com.fs.starfarer.api.util.IntervalUtil;
12
13public class FGWaitAction extends FGDurationAction {
14
15 protected SectorEntityToken where;
16 protected IntervalUtil interval = new IntervalUtil(0.1f, 0.3f);
17
18 protected String waitText;
19 protected boolean doNotGetSidetracked = true;
20
21 public FGWaitAction(SectorEntityToken where, float waitDays) {
22 this(where, waitDays, "orbiting " + where.getName());
23 }
24
25 public FGWaitAction(SectorEntityToken where, float waitDays, String waitText) {
26 super(waitDays);
27 this.where = where;
28 this.waitText = waitText;
29
30 interval.forceIntervalElapsed();
31 }
32
33 @Override
34 public void addRouteSegment(RouteData route) {
35 RouteSegment segment = new RouteSegment(getDurDays(), where);
36 route.addSegment(segment);
37 }
38
39
40 @Override
41 public void directFleets(float amount) {
42 super.directFleets(amount);
43 if (isActionFinished()) return;
44
45 List<CampaignFleetAPI> fleets = intel.getFleets();
46 if (fleets.isEmpty()) {
48 return;
49 }
50
51 float days = Global.getSector().getClock().convertToDays(amount);
52 interval.advance(days);
53
54 if (!interval.intervalElapsed()) return;
55
56
57 for (CampaignFleetAPI fleet : fleets) {
58 fleet.clearAssignments();
59
60 if (where.getStarSystem() != null && where == where.getStarSystem().getCenter()) {
61 fleet.addAssignment(FleetAssignment.PATROL_SYSTEM, null, 3f, waitText);
62 } else {
64 fleet.addAssignment(FleetAssignment.ORBIT_PASSIVE, where, 3f, waitText);
65 } else {
66 fleet.addAssignment(FleetAssignment.ORBIT_AGGRESSIVE, where, 3f, waitText);
67 }
68 }
69 }
70 }
71
72
73
74 public SectorEntityToken getWhere() {
75 return where;
76 }
77
78 public void setWhere(SectorEntityToken where) {
79 this.where = where;
80 }
81
82 public String getWaitText() {
83 return waitText;
84 }
85
86 public void setWaitText(String waitText) {
87 this.waitText = waitText;
88 }
89
90 public boolean isDoNotGetSidetracked() {
92 }
93
95 this.doNotGetSidetracked = doNotGetSidetracked;
96 }
97
98}
99
100
101
102
static SectorAPI getSector()
Definition Global.java:59
FGWaitAction(SectorEntityToken where, float waitDays)
FGWaitAction(SectorEntityToken where, float waitDays, String waitText)