001package com.fs.starfarer.api.impl.campaign.ghosts;
002
003import com.fs.starfarer.api.campaign.SectorEntityToken;
004import com.fs.starfarer.api.util.Misc;
005
006public class GBITooCloseToOther extends BaseGhostBehaviorInterrupt {
007
008        protected float distThreshold;
009        protected SectorEntityToken to;
010        protected SectorEntityToken other;
011        
012        public GBITooCloseToOther(float delay, SectorEntityToken to, SectorEntityToken other, float distThreshold) {
013                super(delay);
014                this.distThreshold = distThreshold;
015                this.to = to;
016                this.other = other;
017        }
018
019        @Override
020        public boolean shouldInterruptBehavior(SensorGhost ghost, GhostBehavior behavior) {
021                if (hasDelayRemaining()) return false;
022                
023                float dist = Misc.getDistance(to, other);
024                dist -= to.getRadius();
025                dist -= other.getRadius();
026                
027                boolean inRange = dist < distThreshold;
028                return inRange;
029        }
030
031        
032}