Starsector API
Loading...
Searching...
No Matches
GBGoAwayFromFixed.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
13
14 protected boolean dirSet = false;
15 protected float dir;
16 protected SectorEntityToken from;
17 protected int maxBurn;
18
19 public GBGoAwayFromFixed(float duration, SectorEntityToken from, int maxBurn) {
20 super(duration);
21 this.from = from;
22 this.maxBurn = maxBurn;
23 }
24
25
26
27 @Override
28 public void advance(float amount, SensorGhost ghost) {
29 if (from.getContainingLocation() != ghost.getEntity().getContainingLocation() || !from.isAlive()) {
30 end();
31 return;
32 }
33 super.advance(amount, ghost);
34
35 if (!dirSet) {
36 dir = Misc.getAngleInDegrees(from.getLocation(), ghost.getEntity().getLocation());
37 dirSet = true;
38 }
39
40 Vector2f loc = Misc.getUnitVectorAtDegreeAngle(dir);
41 loc.scale(10000f);
42 Vector2f.add(loc, ghost.getEntity().getLocation(), loc);
43 ghost.moveTo(loc, maxBurn);
44
45 }
46
47
48
49}
50
51
52
53
54
55
56
57
58
59
60
61
62
GBGoAwayFromFixed(float duration, SectorEntityToken from, int maxBurn)
void moveTo(Vector2f dest, float maxBurn)