Starsector API
Loading...
Searching...
No Matches
GBITooClose.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;
11
12 public GBITooClose(float delay, SectorEntityToken to, float distThreshold) {
13 this(delay, to, distThreshold, null);
14 }
15 public GBITooClose(float delay, SectorEntityToken to, float distThreshold, SharedTrigger trigger) {
16 super(delay);
17 this.distThreshold = distThreshold;
18 this.to = to;
19 this.trigger = trigger;
20 }
21
22 @Override
23 public boolean shouldInterruptBehavior(SensorGhost ghost, GhostBehavior behavior) {
24 if (hasDelayRemaining()) return false;
25
26 float dist = Misc.getDistance(to, ghost.getEntity());
27 dist -= to.getRadius();
28 dist -= ghost.getEntity().getRadius();
29
30 boolean inRange = dist < distThreshold;
31 if (inRange && trigger != null) {
32 trigger.set(true);
33 }
34 return inRange || (trigger != null && trigger.isSet());
35 }
36
37
38}
GBITooClose(float delay, SectorEntityToken to, float distThreshold)
GBITooClose(float delay, SectorEntityToken to, float distThreshold, SharedTrigger trigger)
boolean shouldInterruptBehavior(SensorGhost ghost, GhostBehavior behavior)