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 GBITowardsEntity extends BaseGhostBehaviorInterrupt {
007
008        protected SectorEntityToken from;
009        protected SectorEntityToken to;
010        
011        public GBITowardsEntity(float delay, SectorEntityToken from, SectorEntityToken to) {
012                super(delay);
013                this.from = from;
014                this.to = to;
015        }
016
017        @Override
018        public boolean shouldInterruptBehavior(SensorGhost ghost, GhostBehavior behavior) {
019                if (hasDelayRemaining()) return false;
020                
021                float grace = 15f;
022                float angle = Misc.getAngleInDegrees(from.getLocation(), ghost.getEntity().getLocation());
023                float facing = Misc.getAngleInDegrees(from.getLocation(), to.getLocation());
024                
025                return Misc.getAngleDiff(angle, facing) < grace;
026        }
027
028        
029}