Starsector API
Loading...
Searching...
No Matches
GBITooCloseToOther.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.ghosts;
2
3import com.fs.starfarer.api.campaign.SectorEntityToken;
4import com.fs.starfarer.api.util.Misc;
5
7
8 protected float distThreshold;
9 protected SectorEntityToken to;
10 protected SectorEntityToken other;
11
12 public GBITooCloseToOther(float delay, SectorEntityToken to, SectorEntityToken other, float distThreshold) {
13 super(delay);
14 this.distThreshold = distThreshold;
15 this.to = to;
16 this.other = other;
17 }
18
19 @Override
20 public boolean shouldInterruptBehavior(SensorGhost ghost, GhostBehavior behavior) {
21 if (hasDelayRemaining()) return false;
22
23 float dist = Misc.getDistance(to, other);
24 dist -= to.getRadius();
25 dist -= other.getRadius();
26
27 boolean inRange = dist < distThreshold;
28 return inRange;
29 }
30
31
32}
GBITooCloseToOther(float delay, SectorEntityToken to, SectorEntityToken other, float distThreshold)
boolean shouldInterruptBehavior(SensorGhost ghost, GhostBehavior behavior)