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 009/** 010 * Direction to go in is fixed when behavior starts. 011 */ 012public class GBGoAwayFromFixed extends BaseGhostBehavior { 013 014 protected boolean dirSet = false; 015 protected float dir; 016 protected SectorEntityToken from; 017 protected int maxBurn; 018 019 public GBGoAwayFromFixed(float duration, SectorEntityToken from, int maxBurn) { 020 super(duration); 021 this.from = from; 022 this.maxBurn = maxBurn; 023 } 024 025 026 027 @Override 028 public void advance(float amount, SensorGhost ghost) { 029 if (from.getContainingLocation() != ghost.getEntity().getContainingLocation() || !from.isAlive()) { 030 end(); 031 return; 032 } 033 super.advance(amount, ghost); 034 035 if (!dirSet) { 036 dir = Misc.getAngleInDegrees(from.getLocation(), ghost.getEntity().getLocation()); 037 dirSet = true; 038 } 039 040 Vector2f loc = Misc.getUnitVectorAtDegreeAngle(dir); 041 loc.scale(10000f); 042 Vector2f.add(loc, ghost.getEntity().getLocation(), loc); 043 ghost.moveTo(loc, maxBurn); 044 045 } 046 047 048 049} 050 051 052 053 054 055 056 057 058 059 060 061 062