001package com.fs.starfarer.api.impl.campaign.ghosts;
002
003import org.lwjgl.util.vector.Vector2f;
004
005import com.fs.starfarer.api.campaign.SectorEntityToken;
006import com.fs.starfarer.api.util.Misc;
007
008
009public class GBGoAwayFrom extends BaseGhostBehavior {
010        
011        protected SectorEntityToken from;
012        protected int maxBurn;
013        
014        public GBGoAwayFrom(float duration, SectorEntityToken from, int maxBurn) {
015                super(duration);
016                this.from = from;
017                this.maxBurn = maxBurn;
018        }
019
020
021
022        @Override
023        public void advance(float amount, SensorGhost ghost) {
024                if (from.getContainingLocation() != ghost.getEntity().getContainingLocation() || !from.isAlive()) {
025                        end();
026                        return;
027                }
028                super.advance(amount, ghost);
029                
030                Vector2f loc = Misc.getUnitVectorAtDegreeAngle(Misc.getAngleInDegrees(from.getLocation(), ghost.getEntity().getLocation()));
031                loc.scale(10000f);
032                Vector2f.add(loc, ghost.getEntity().getLocation(), loc);
033                ghost.moveTo(loc, maxBurn);
034                
035        }
036        
037        
038        
039}
040
041
042
043
044
045
046
047
048
049
050
051
052