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
11 protected SectorEntityToken other;
12 protected int maxBurn;
13 protected boolean endOnIntercept;
14
15 protected float desiredRange;
16
17 public GBIntercept(SectorEntityToken other, float duration, int maxBurn, boolean endOnIntercept) {
19 }
20
21 public GBIntercept(SectorEntityToken other, float duration, int maxBurn, float desiredRange, boolean endOnIntercept) {
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) {
31 if (other.getContainingLocation() != ghost.getEntity().getContainingLocation() || !other.isAlive()) {
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)
void moveTo(Vector2f dest, float maxBurn)