1package com.fs.starfarer.api.impl.campaign.procgen.themes;
5import org.lwjgl.util.vector.Vector2f;
7import com.fs.starfarer.api.Global;
8import com.fs.starfarer.api.Script;
9import com.fs.starfarer.api.campaign.CampaignFleetAPI;
10import com.fs.starfarer.api.campaign.FleetAssignment;
11import com.fs.starfarer.api.campaign.LocationAPI;
12import com.fs.starfarer.api.campaign.SectorEntityToken;
13import com.fs.starfarer.api.campaign.StarSystemAPI;
14import com.fs.starfarer.api.impl.campaign.fleets.RouteLocationCalculator;
15import com.fs.starfarer.api.impl.campaign.fleets.RouteManager.RouteData;
16import com.fs.starfarer.api.impl.campaign.fleets.RouteManager.RouteSegment;
17import com.fs.starfarer.api.util.Misc;
21 public static enum TravelState {
47 if (segment.isInSystem()) {
48 return TravelState.IN_SYSTEM;
51 if (segment.hasLeaveSystemPhase() && segment.getLeaveProgress() < 1f) {
52 return TravelState.LEAVING_SYSTEM;
54 if (segment.hasEnterSystemPhase() && segment.getEnterProgress() > 0f) {
55 return TravelState.ENTERING_SYSTEM;
58 return TravelState.IN_HYPER_TRANSIT;
63 case ENTERING_SYSTEM: {
64 if (segment.to !=
null) {
97 protected void advance(
float amount,
boolean withReturnAssignments) {
99 RouteSegment current =
route.getCurrent();
100 if (current !=
null && current.from !=
null &&
104 "returning to " + current.from.
getName());
111 super.advance(amount);
131 if (to ==
null) to = segment.from;
133 return "returning to " + to.
getName();
143 RouteSegment current =
route.getCurrent();
144 if (current ==
null)
return;
146 List<RouteSegment> segments =
route.getSegments();
147 int index =
route.getSegments().indexOf(
route.getCurrent());
150 if (index == 0 &&
route.getMarket() !=
null && !current.isTravel()) {
159 if (index == segments.size() - 1 &&
route.getMarket() !=
null && !current.isTravel()
160 && (current.elapsed >= current.daysMax || current.getFrom() ==
route.getMarket().
getPrimaryEntity())) {
166 if (current.isTravel()) {
167 if (index == segments.size() - 1 &&
169 current.elapsed >= current.daysMax) {
178 if (!current.isTravel()) {
188 float progress = current.getProgress();
199 route.goToAtLeastNext(current);
206 float progress = current.getProgress();
208 current.getDestination(), current.getDestination());
219 if (to ==
null) to = current.from;
222 if (to ==
null || !to.
isAlive()) {
231 "returning to " + to.
getName());
232 if (current.daysMax > current.elapsed) {
244 float progress = current.getProgress();
246 current.from, current.getDestination());
248 if (current.from !=
null && current.to ==
null && !current.isFromSystemCenter()) {
278 if (state == TravelState.LEAVING_SYSTEM) {
279 float p = current.getLeaveProgress();
281 if (jp ==
null) jp = current.from;
296 else if (state == TravelState.ENTERING_SYSTEM) {
297 float p = current.getEnterProgress();
299 if (jp ==
null) jp = current.to;
314 else if (state == TravelState.IN_SYSTEM) {
315 float p = current.getTransitProgress();
317 current.from, current.to);
324 else if (state == TravelState.IN_HYPER_TRANSIT) {
325 float p = current.getTransitProgress();
static SectorAPI getSector()
static int setLocation(CampaignFleetAPI fleet, float daysElapsed, float maxDays, int overflowIndex, boolean onlyAdjustIntervals, float[] intervals, SectorEntityToken ... sequence)
static JumpPointAPI findJumpPointToUse(CampaignFleetAPI fleet, SectorEntityToken from)
FleetActionDelegate delegate
RouteFleetAssignmentAI(CampaignFleetAPI fleet, RouteData route, FleetActionDelegate delegate)
LocationAPI getLocationForState(RouteSegment segment, TravelState state)
String getStartingActionText(RouteSegment segment)
Boolean gaveReturnAssignments
String getTravelActionText(RouteSegment segment)
Script goNextScript(final RouteSegment current)
void addTravelAssignment(final RouteSegment current, boolean justSpawned)
void giveInitialAssignments()
void addEndingAssignment(final RouteSegment current, boolean justSpawned)
String getEndingActionText(RouteSegment segment)
void pickNext(boolean justSpawned)
void addLocalAssignment(final RouteSegment current, boolean justSpawned)
void addStartingAssignment(final RouteSegment current, boolean justSpawned)
String getInSystemActionText(RouteSegment segment)
void advance(float amount)
void advance(float amount, boolean withReturnAssignments)
TravelState getTravelState(RouteSegment segment)
RouteFleetAssignmentAI(CampaignFleetAPI fleet, RouteData route)
static void giveStandardReturnToSourceAssignments(CampaignFleetAPI fleet)
static float getDistance(SectorEntityToken from, SectorEntityToken to)
static Vector2f getPointAtRadius(Vector2f from, float r)
GO_TO_LOCATION_AND_DESPAWN
LocationAPI getContainingLocation()
void addAssignment(FleetAssignment assignment, SectorEntityToken target, float maxDurationInDays)
void addEntity(SectorEntityToken entity)
SectorEntityToken createToken(float x, float y)
void removeEntity(SectorEntityToken entity)
LocationAPI getHyperspace()
LocationAPI getContainingLocation()
void setFacing(float facing)
Vector2f getLocationInHyperspace()
SectorEntityToken getPrimaryEntity()