1package com.fs.starfarer.api.impl.campaign.entities;
3import java.util.ArrayList;
8import org.lwjgl.util.vector.Vector2f;
10import com.fs.starfarer.api.Global;
11import com.fs.starfarer.api.Script;
12import com.fs.starfarer.api.campaign.CampaignEngineLayers;
13import com.fs.starfarer.api.campaign.SectorEntityToken;
14import com.fs.starfarer.api.campaign.SectorEntityToken.VisibilityLevel;
15import com.fs.starfarer.api.combat.ViewportAPI;
16import com.fs.starfarer.api.impl.campaign.BaseCustomEntityPlugin;
17import com.fs.starfarer.api.impl.campaign.ids.Pings;
18import com.fs.starfarer.api.impl.campaign.ids.Tags;
19import com.fs.starfarer.api.util.CampaignEngineGlowIndividualEngine;
20import com.fs.starfarer.api.util.CampaignEngineGlowUtil;
21import com.fs.starfarer.api.util.CampaignEntityMovementUtil;
22import com.fs.starfarer.api.util.Misc;
40 public static enum ProbeActionType {
49 public static class GenericProbeParams {
50 public float maxBurn = 20f;
51 public float burnAccel = 5f;
52 public float maxTurnRate = 120f;
53 public float turnAccel = 120f;
55 public Color fringe =
new Color(255, 100, 0, 255);
56 public Color flame =
new Color(255, 165, 100, 255);
57 public Color core =
new Color(255, 255, 255, 255);
58 public float engineGlowShiftRate = 2f;
59 public float engineGlowLength = 100f;
60 public float engineGlowWidth = 15f;
61 public float engineGlowGlowSize = 100f;
62 public float engineGlowTexSpanMult = 0.1f;
64 protected List<ProbeAction> actions =
new ArrayList<>();
66 public void travelTo(Vector2f location) {
67 ProbeAction a =
new ProbeAction(ProbeActionType.TRAVEL);
68 a.location = location;
72 ProbeAction a =
new ProbeAction(ProbeActionType.TRAVEL);
76 public void travelInDir(
float dir,
float duration) {
77 ProbeAction a =
new ProbeAction(ProbeActionType.TRAVEL);
79 a.duration = duration;
84 ProbeAction a =
new ProbeAction(ProbeActionType.ASSUME_ORBIT);
87 a.duration = duration;
91 public void emitPing(String pingId) {
92 ProbeAction a =
new ProbeAction(ProbeActionType.EMIT_PING);
96 public void performAction(
Script action) {
97 ProbeAction a =
new ProbeAction(ProbeActionType.PERFORM_ACTION);
101 public void wait(
float duration) {
102 ProbeAction a =
new ProbeAction(ProbeActionType.WAIT);
103 a.duration = duration;
106 public void stop(
float duration) {
107 ProbeAction a =
new ProbeAction(ProbeActionType.STOP);
108 a.duration = duration;
114 public static class ProbeAction {
115 public ProbeActionType type;
117 public Vector2f location;
120 public float duration;
121 public String pingId;
123 public ProbeAction(ProbeActionType type) {
134 super.init(
entity, pluginParams);
135 this.params = (GenericProbeParams) pluginParams;
139 Object readResolve() {
142 params.engineGlowShiftRate);
179 ProbeAction curr =
params.actions.get(0);
180 ProbeAction next =
null;
181 if (
params.actions.size() > 1) next =
params.actions.get(1);
183 if (curr.type == ProbeActionType.TRAVEL) {
184 if (curr.location ==
null && curr.target ==
null) {
186 curr.duration -= amount;
187 if (curr.duration <= 0) {
191 Vector2f loc = curr.location;
195 if (next !=
null && next.type == ProbeActionType.ASSUME_ORBIT) {
198 away.scale(next.target.
getRadius() + next.radius * 0.8f);
199 loc = Vector2f.add(loc, away,
new Vector2f());
204 if (curr.target !=
null) checkDist += curr.target.
getRadius();
205 if (next !=
null && next.type == ProbeActionType.ASSUME_ORBIT) {
207 checkDist += next.radius;
209 if (dist < checkDist) {
214 }
else if (curr.type == ProbeActionType.ASSUME_ORBIT) {
219 float orbitDays = orbitRadius / (10f + (float) Math.random() * 5f);
223 curr.duration -= amount;
224 if (curr.duration <= 0) {
227 }
else if (curr.type == ProbeActionType.EMIT_PING) {
229 if (level != VisibilityLevel.NONE) {
233 }
else if (curr.type == ProbeActionType.STOP || curr.type == ProbeActionType.WAIT) {
234 if (curr.type == ProbeActionType.STOP) {
237 curr.duration -= amount;
238 if (curr.duration <= 0) {
241 }
else if (curr.type == ProbeActionType.PERFORM_ACTION) {
254 if (alphaMult <= 0f)
return;
static SectorAPI getSector()
CampaignEngineGlowUtil getEngineGlow()
CampaignEngineGlowUtil engineGlow
CampaignEntityMovementUtil movement
CampaignEntityMovementUtil getMovement()
void render(CampaignEngineLayers layer, ViewportAPI viewport)
void advance(float amount)
GenericProbeParams params
void init(SectorEntityToken entity, Object pluginParams)
static final String REMOTE_SURVEY
void setFlameTexSpanMult(float flameTexSpanMult)
void addEngine(CampaignEngineGlowIndividualEngine engine)
void advance(float amount)
void render(float alphaMult)
void moveInDirection(float dir)
void advance(float amount)
void moveToLocation(Vector2f loc)
void setEngineGlow(EngineGlowControls engineGlow)
static Vector2f getUnitVectorAtDegreeAngle(float degrees)
static void fadeAndExpire(SectorEntityToken entity)
static float getDistance(SectorEntityToken from, SectorEntityToken to)
static float getSpeedForBurnLevel(float burnLevel)
static float getAngleInDegrees(Vector2f v)
EveryFrameScript addPing(SectorEntityToken entity, String pingType)
float getSensorContactFaderBrightness()
boolean isInCurrentLocation()
void setCircularOrbit(SectorEntityToken focus, float angle, float orbitRadius, float orbitDays)
float getSensorFaderBrightness()
VisibilityLevel getVisibilityLevelToPlayerFleet()
SectorEntityToken getOrbitFocus()
boolean hasTag(String tag)