public ScoutTrailShipControl( App game, TacticalObjective to, CombatAI commanderAI, ScoutShipControl scoutShip) : base(game, to, commanderAI) { this.m_Type = ShipControlType.ScoutTrail; this.m_ScoutShip = scoutShip; }
private void AssignShipsToObjective() { if (this.m_Ships.Count == 0) { return; } if (this.m_Objective is ScoutObjective) { Ship bestScout = CombatAI.FindBestScout(this.m_Ships); if (bestScout == null) { this.m_RequestedObjectiveType = ObjectiveType.PATROL; } else { ScoutShipControl scoutShip = new ScoutShipControl(this.m_Game, this.m_Objective, this.m_CommanderAI, bestScout.SensorRange * 0.75f); scoutShip.AddShip(bestScout, false); if (this.m_Type == TaskGroupType.Civilian) { foreach (Ship ship in this.m_Ships) { if (ship != bestScout) { scoutShip.AddShip(ship, false); } } this.m_ShipControls.Add((TaskGroupShipControl)scoutShip); } else { ScoutTrailShipControl trailShipControl = new ScoutTrailShipControl(this.m_Game, this.m_Objective, this.m_CommanderAI, scoutShip); foreach (Ship ship in this.m_Ships) { if (ship != bestScout) { trailShipControl.AddShip(ship, false); } } this.m_ShipControls.Add((TaskGroupShipControl)scoutShip); this.m_ShipControls.Add((TaskGroupShipControl)trailShipControl); } } } else if (this.m_Objective is PatrolObjective) { PatrolShipControl patrolShipControl; if (this.m_Type == TaskGroupType.Police) { patrolShipControl = new PatrolShipControl(this.m_Game, this.m_Objective, this.m_CommanderAI, this.m_PatrolType, Vector3.UnitZ, this.m_Game.AssetDatabase.PolicePatrolRadius, this.m_CommanderAI.AIRandom.CoinToss(0.5)); } else { Vector3 dir = -this.m_Objective.GetObjectiveLocation(); if ((double)dir.LengthSquared > 0.0) { double num = (double)dir.Normalize(); } else { dir = -Vector3.UnitZ; } bool clockwise = this.m_Type != TaskGroupType.Freighter && this.m_CommanderAI.AIRandom.CoinToss(0.5); patrolShipControl = new PatrolShipControl(this.m_Game, this.m_Objective, this.m_CommanderAI, this.m_PatrolType, dir, 10000f, clockwise); } foreach (Ship ship in this.m_Ships) { patrolShipControl.AddShip(ship, false); } this.m_ShipControls.Add((TaskGroupShipControl)patrolShipControl); } else if (this.m_Objective is AttackGroupObjective) { this.AssignShipsToAttackObjective(); } else if (this.m_Objective is AttackPlanetObjective) { AttackPlanetShipControl planetShipControl = new AttackPlanetShipControl(this.m_Game, this.m_Objective, this.m_CommanderAI); foreach (Ship ship in this.m_Ships) { planetShipControl.AddShip(ship, false); } this.m_ShipControls.Add((TaskGroupShipControl)planetShipControl); } else if (this.m_Objective is DefendPlanetObjective) { this.AssignShipsToDefendObjective(); } else if (this.m_Objective is EvadeEnemyObjective) { EvadeEnemyObjective objective = this.m_Objective as EvadeEnemyObjective; if (objective.EvadePatrolObjective != null) { Vector3 safePatrolDirection = objective.GetSafePatrolDirection(this.GetBaseGroupPosition()); PatrolShipControl patrolShipControl = new PatrolShipControl(this.m_Game, (TacticalObjective)objective.EvadePatrolObjective, this.m_CommanderAI, PatrolType.Circular, safePatrolDirection, 10000f, this.m_CommanderAI.AIRandom.CoinToss(0.5)); foreach (Ship ship in this.m_Ships) { patrolShipControl.AddShip(ship, false); } this.m_ShipControls.Add((TaskGroupShipControl)patrolShipControl); } else { this.m_RequestedObjectiveType = ObjectiveType.PATROL; } } else if (this.m_Objective is RetreatObjective) { RetreatShipControl retreatShipControl = new RetreatShipControl(this.m_Game, this.m_Objective, this.m_CommanderAI, this.m_Type != TaskGroupType.Freighter); foreach (Ship ship in this.m_Ships) { retreatShipControl.AddShip(ship, false); } this.m_ShipControls.Add((TaskGroupShipControl)retreatShipControl); } else if (this.m_Objective is BoardTargetObjective) { float val1 = float.MaxValue; foreach (Ship ship in this.m_Ships) { val1 = Math.Min(val1, CombatAI.GetAveEffectiveWeaponRange(ship, false)); } PursueShipControl pursueShipControl = new PursueShipControl(this.m_Game, this.m_Objective, this.m_CommanderAI, val1 * 0.75f); foreach (Ship ship in this.m_Ships) { pursueShipControl.AddShip(ship, false); } this.m_ShipControls.Add((TaskGroupShipControl)pursueShipControl); } else { if (!(this.m_Objective is FollowTaskGroupObjective)) { return; } SupportGroupShipControl groupShipControl = new SupportGroupShipControl(this.m_Game, this.m_Objective, this.m_CommanderAI, (TaskGroupShipControl)null); foreach (Ship ship in this.m_Ships) { groupShipControl.AddShip(ship, false); } this.m_ShipControls.Add((TaskGroupShipControl)groupShipControl); } }