public override void FindNewTarget(IEnumerable <IGameObject> objs) { List <Ship> shipList1 = new List <Ship>(); List <Ship> shipList2 = new List <Ship>(); foreach (IGameObject gameObject in objs) { if (gameObject is Ship) { Ship ship = gameObject as Ship; if (ship != this.m_VonNeumannBerserker && Ship.IsActiveShip(ship) && (ship.IsDetected(this.m_VonNeumannBerserker.Player) && ship.Player != this.m_VonNeumannBerserker.Player)) { shipList1.Add(ship); } } } foreach (VonNeumannDiscControl disc in this.m_Discs) { if (VonNeumannDiscControl.DiscTypeIsAttacker(disc.DiscType)) { shipList2.Add(disc.GetShip()); } } if (shipList1.Count == 0) { return; } if (!this.m_DiscsActivated) { this.m_State = VonNeumannBerserkerStates.ACTIVATINGDISCS; } foreach (VonNeumannDiscControl disc in this.m_Discs) { if (Ship.IsActiveShip(disc.GetShip()) && disc.RequestingNewTarget()) { Vector3 position = disc.GetShip().Position; float num = float.MaxValue; Ship ship1 = (Ship)null; foreach (Ship ship2 in VonNeumannDiscControl.DiscTypeIsAttacker(disc.DiscType) ? shipList1 : shipList2) { if (ship2 != disc.GetShip()) { float lengthSquared = (ship2.Position - position).LengthSquared; if ((double)lengthSquared < (double)num) { ship1 = ship2; num = lengthSquared; } } } if (ship1 != null) { disc.SetTarget((IGameObject)ship1); } } } }
private void ThinkSeek() { if (this.m_Target == null) { return; } float num = VonNeumannDiscControl.DiscTypeIsAttacker(this.m_DiscType) ? Math.Max(100f, CombatAI.GetMinPointBlankWeaponRange(this.m_Disc, false)) : 400f; if (this.m_Disc.CombatStance != CombatStance.PURSUE) { this.m_Disc.SetCombatStance(CombatStance.PURSUE); } this.m_Disc.Maneuvering.PostSetProp("SetStanceTarget", (object)this.m_Target.ObjectID, (object)num); this.m_State = VonNeumannDiscStates.TRACK; }
public override void FindNewTarget(IEnumerable <IGameObject> objs) { if (this.m_ParentBerserker == null) { return; } float num = float.MaxValue; IGameObject target = (IGameObject)null; foreach (IGameObject gameObject in objs) { if (gameObject is Ship) { Ship ship = gameObject as Ship; if (VonNeumannDiscControl.DiscTypeIsAttacker(this.m_DiscType)) { if (ship.Player == this.m_Disc.Player) { continue; } } else if (ship.Player != this.m_Disc.Player) { continue; } if (ship.Active && Ship.IsActiveShip(ship) && ship.IsDetected(this.m_Disc.Player)) { float lengthSquared = (ship.Position - this.m_Disc.Position).LengthSquared; if ((double)lengthSquared < (double)num) { target = (IGameObject)ship; num = lengthSquared; } } } } this.SetTarget(target); }
public VonNeumannDiscControl(App game, Ship ship) { this.m_Game = game; this.m_Disc = ship; this.m_DiscType = VonNeumannDiscControl.DiscTypeFromMissionSection(ship.Sections.FirstOrDefault <Section>((Func <Section, bool>)(x => x.ShipSectionAsset.Type == ShipSectionType.Mission))); }