public override void ForceFlee()
 {
     if (this.m_State != VonNeumannChildStates.INITFLEE && this.m_State != VonNeumannChildStates.FLEE)
     {
         this.m_State = VonNeumannChildStates.INITFLEE;
     }
     this.ClearBeam();
 }
 private void ThinkInitFlee()
 {
     if (this.m_VonNeumannChild.CombatStance != CombatStance.NO_STANCE)
     {
         this.m_VonNeumannChild.SetCombatStance(CombatStance.NO_STANCE);
     }
     this.m_VonNeumannChild.Maneuvering.PostSetProp("SetStanceTarget", (object)0, (object)0.0f);
     this.m_State = VonNeumannChildStates.FLEE;
 }
 private void ThinkTrack()
 {
     if (this.m_Target == null)
     {
         this.m_State = VonNeumannChildStates.INITFLEE;
     }
     else
     {
         float   num1      = 0.0f;
         float   val2      = 0.0f;
         Vector3 vector3_1 = Vector3.Zero;
         if (this.m_Target is Ship)
         {
             Ship target = this.m_Target as Ship;
             vector3_1 = target.Position;
             num1      = target.ShipSphere.radius;
         }
         else if (this.m_Target is StellarBody)
         {
             StellarBody target = this.m_Target as StellarBody;
             vector3_1 = target.Parameters.Position;
             num1      = target.Parameters.Radius;
             val2      = 750f;
         }
         WeaponBank bankWithWeaponTrait = this.m_VonNeumannChild.GetWeaponBankWithWeaponTrait(WeaponEnums.WeaponTraits.Disintegrating);
         if (bankWithWeaponTrait != null)
         {
             this.m_ApproachRange = Math.Max(bankWithWeaponTrait.Weapon.RangeTable.Effective.Range, 100f);
             bankWithWeaponTrait.PostSetProp("DisableAllTurrets", true);
         }
         else
         {
             this.m_ApproachRange = Math.Max(100f, CombatAI.GetMinEffectiveWeaponRange(this.m_VonNeumannChild, false));
         }
         this.m_ApproachRange  = Math.Max(this.m_ApproachRange, val2);
         this.m_ApproachRange += num1;
         Vector3 vector3_2 = vector3_1;
         Vector3 vector3_3 = this.m_VonNeumannChild.Position - vector3_2;
         double  num2      = (double)vector3_3.Normalize();
         Vector3 targetPos = vector3_2 + vector3_3 * this.m_ApproachRange;
         Vector3 look      = vector3_3 * -1f;
         this.m_VonNeumannChild.Maneuvering.PostAddGoal(targetPos, look);
         float lengthSquared = (this.m_VonNeumannChild.Position - targetPos).LengthSquared;
         float num3          = this.m_ApproachRange + 200f;
         if ((double)lengthSquared >= (double)num3 * (double)num3)
         {
             return;
         }
         this.m_State = VonNeumannChildStates.INITCOLLECT;
     }
 }
 public override void Initialize()
 {
     this.m_Target        = (IGameObject)null;
     this.m_VonNeumannMom = (VonNeumannMomControl)null;
     this.m_State         = VonNeumannChildStates.SEEK;
     this.m_Vanished      = false;
     this.m_RUStore       = 0;
     this.m_Beam          = (VonNeumannDisintegrationBeam)null;
     this.m_ApproachRange = 1000f;
     this.m_BeamWeapon    = this.m_Game.AssetDatabase.Weapons.FirstOrDefault <LogicalWeapon>((Func <LogicalWeapon, bool>)(x => ((IEnumerable <WeaponEnums.WeaponTraits>)x.Traits).Any <WeaponEnums.WeaponTraits>((Func <WeaponEnums.WeaponTraits, bool>)(k => k == WeaponEnums.WeaponTraits.Disintegrating))));
     if (this.m_BeamWeapon == null)
     {
         return;
     }
     this.m_BeamWeapon.AddGameObjectReference();
 }
 private void ThinkReturn()
 {
     if (this.m_VonNeumannMom != null)
     {
         Vector3 vector3   = this.m_VonNeumannChild.Position - this.m_VonNeumannMom.GetShip().Position;
         double  num       = (double)vector3.Normalize();
         Vector3 targetPos = this.m_VonNeumannMom.GetShip().Position + vector3 * this.m_ApproachRange;
         this.m_VonNeumannChild.Maneuvering.PostAddGoal(targetPos, -vector3);
         if ((double)(targetPos - this.m_VonNeumannChild.Position).LengthSquared >= 40000.0)
         {
             return;
         }
         this.m_State = VonNeumannChildStates.EMIT;
     }
     else
     {
         this.m_State = VonNeumannChildStates.INITFLEE;
     }
 }
 private void ThinkCollect()
 {
     if (this.m_Beam != null && !this.m_Beam.Active && this.m_Beam.ObjectStatus == GameObjectStatus.Ready)
     {
         this.m_Beam.Active = true;
     }
     if (this.m_Beam == null)
     {
         this.m_State = VonNeumannChildStates.SEEK;
     }
     else
     {
         if (!this.m_Beam.Finished)
         {
             return;
         }
         if (this.m_Beam.Succeeded)
         {
             this.m_RUStore += this.m_Beam.Resources;
         }
         if (this.m_Target is StellarBody)
         {
             PlanetInfo planetInfo = this.m_Game.GameDatabase.GetPlanetInfo((this.m_Target as StellarBody).Parameters.OrbitalID);
             if (planetInfo != null)
             {
                 planetInfo.Resources = Math.Max(planetInfo.Resources - this.m_Beam.Resources, 0);
                 this.m_Game.GameDatabase.UpdatePlanet(planetInfo);
             }
         }
         this.m_Target = (IGameObject)null;
         if (this.m_VonNeumannChild.CombatStance != CombatStance.NO_STANCE)
         {
             this.m_VonNeumannChild.SetCombatStance(CombatStance.NO_STANCE);
         }
         this.m_VonNeumannChild.Maneuvering.PostSetProp("SetStanceTarget", (object)0, (object)0.0f);
         this.m_State = this.m_RUStore >= this.m_Game.AssetDatabase.GlobalVonNeumannData.ChildRUCarryCap ? (this.m_VonNeumannMom == null ? VonNeumannChildStates.INITFLEE : VonNeumannChildStates.RETURN) : VonNeumannChildStates.SEEK;
         this.ClearBeam();
     }
 }
 private void ThinkSeek()
 {
     if (this.m_Target == null)
     {
         if (this.m_VonNeumannMom != null)
         {
             if (this.m_RUStore <= 0)
             {
                 return;
             }
             this.m_State = VonNeumannChildStates.RETURN;
         }
         else
         {
             this.m_State = VonNeumannChildStates.INITFLEE;
         }
     }
     else
     {
         this.m_State = VonNeumannChildStates.TRACK;
     }
 }
 private void ThinkFlee()
 {
     if (this.m_VonNeumannMom != null && !this.m_VonNeumannMom.Vanished)
     {
         if (this.m_VonNeumannChild.CombatStance != CombatStance.PURSUE)
         {
             this.m_VonNeumannChild.SetCombatStance(CombatStance.PURSUE);
         }
         this.m_VonNeumannChild.Maneuvering.PostSetProp("SetStanceTarget", (object)this.m_VonNeumannMom.GetShip().ObjectID, (object)this.m_ApproachRange);
     }
     else
     {
         if (this.m_VonNeumannChild.CombatStance != CombatStance.RETREAT)
         {
             this.m_VonNeumannChild.SetCombatStance(CombatStance.RETREAT);
         }
         if (!this.m_VonNeumannChild.HasRetreated)
         {
             return;
         }
         this.m_State = VonNeumannChildStates.VANISH;
     }
 }
 private void ThinkEmiting()
 {
     if (this.m_Beam != null && !this.m_Beam.Active && this.m_Beam.ObjectStatus == GameObjectStatus.Ready)
     {
         this.m_Beam.Active = true;
     }
     if (this.m_VonNeumannMom == null)
     {
         this.m_State = VonNeumannChildStates.INITFLEE;
         this.ClearBeam();
     }
     else
     {
         if (!this.m_Beam.Finished)
         {
             return;
         }
         this.ClearBeam();
         this.m_VonNeumannMom.SubmitResources(this.m_RUStore);
         this.m_RUStore = 0;
         this.m_State   = VonNeumannChildStates.SEEK;
     }
 }
 private void ThinkEmit()
 {
     this.SpawnBeam((IGameObject)this.m_VonNeumannMom.GetShip(), false);
     this.m_State = VonNeumannChildStates.EMITTING;
 }
 private void ThinkInitCollect()
 {
     this.SpawnBeam(this.m_Target, true);
     this.m_State = VonNeumannChildStates.COLLECT;
 }