Starsector API
Loading...
Searching...
No Matches
GBIntercept.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.ghosts;
2
3import org.lwjgl.util.vector.Vector2f;
4
5import com.fs.starfarer.api.campaign.SectorEntityToken;
6import com.fs.starfarer.api.util.Misc;
7
8
9public class GBIntercept extends BaseGhostBehavior {
10
12 protected int maxBurn;
13 protected boolean endOnIntercept;
14
15 protected float desiredRange;
16
20
22 super(duration);
23 this.other = other;
24 this.maxBurn = maxBurn;
25 this.endOnIntercept = endOnIntercept;
26 this.desiredRange = desiredRange;
27 }
28
29 @Override
30 public void advance(float amount, SensorGhost ghost) {
32 end();
33 return;
34 }
35 super.advance(amount, ghost);
36
37 float speed = Misc.getSpeedForBurnLevel(maxBurn);
38 Vector2f loc = Misc.getInterceptPoint(ghost.getEntity(), other, speed);
39 if (loc != null) {
40 ghost.moveTo(loc, maxBurn);
41 }
42
43 if (endOnIntercept) {
44 float dist = Misc.getDistance(ghost.getEntity(), other);
45 if (dist < ghost.getEntity().getRadius() + other.getRadius() + desiredRange) {
46 end();
47 return;
48 }
49 }
50 }
51
52
53
54}
55
56
57
58
59
60
61
62
63
64
65
66
67
void advance(float amount, SensorGhost ghost)
GBIntercept(SectorEntityToken other, float duration, int maxBurn, float desiredRange, boolean endOnIntercept)
GBIntercept(SectorEntityToken other, float duration, int maxBurn, boolean endOnIntercept)
static float getDistance(SectorEntityToken from, SectorEntityToken to)
Definition Misc.java:599
static Vector2f getInterceptPoint(CampaignFleetAPI from, SectorEntityToken to)
Definition Misc.java:3921
static float getSpeedForBurnLevel(float burnLevel)
Definition Misc.java:1671
void moveTo(Vector2f dest, float maxBurn)