public FollowTaskGroupObjective(TaskGroup tg) { this.m_ObjectiveType = ObjectiveType.DEFEND_TARGET; this.m_TargetTaskGroup = tg; this.m_RequestTaskGroup = false; this.m_TaskGroups = new List <TaskGroup>(); }
public void UpdateTaskGroupType() { int num1 = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; int num6 = 0; int num7 = 0; foreach (Ship ship in this.m_Ships) { if (ship.IsPolice) { ++num1; } else { switch (TaskGroup.GetTaskTypeFromShip(ship)) { case TaskGroupType.Passive: ++num4; continue; case TaskGroupType.Civilian: ++num5; continue; case TaskGroupType.Freighter: ++num2; continue; case TaskGroupType.UnArmed: ++num6; continue; case TaskGroupType.PlanetAssault: ++num7; continue; default: ++num3; continue; } } } this.m_Type = num1 <= 0 ? (num2 <= 0 ? (num6 <= 0 ? (!this.m_CommanderAI.IsEncounterCombat ? (num7 <= 0 ? (this.m_Ships.Count != 2 || num3 == this.m_Ships.Count || (num5 == this.m_Ships.Count || num4 == this.m_Ships.Count) ? (num5 <= num4 || num5 <= num3 ? (num3 <= num4 || num3 <= num5 ? TaskGroupType.Passive : (num5 <= num4 || num5 <= num3 / 5 ? TaskGroupType.Aggressive : TaskGroupType.Passive)) : (num3 > num4 ? TaskGroupType.Passive : TaskGroupType.Civilian)) : (num5 > 0 ? TaskGroupType.Passive : TaskGroupType.Aggressive)) : TaskGroupType.PlanetAssault) : TaskGroupType.Aggressive) : TaskGroupType.UnArmed) : TaskGroupType.Freighter) : TaskGroupType.Police; if (this.m_Type == TaskGroupType.Passive && (this.m_CommanderAI.GetAIType() == OverallAIType.PIRATE || this.m_CommanderAI.GetAIType() == OverallAIType.SLAVER)) { this.m_Type = TaskGroupType.Aggressive; } if (this.m_Type == TaskGroupType.Civilian || this.m_Type == TaskGroupType.Freighter || this.m_Type == TaskGroupType.Police) { this.m_PatrolType = PatrolType.Orbit; } else { this.m_PatrolType = PatrolType.Circular; } }
public TaskGroup(App game, CombatAI commandAI) { this.m_Game = game; this.m_CommanderAI = commandAI; this.m_Objective = (TacticalObjective)null; this.m_Orders = TaskGroupOrders.None; this.m_Type = TaskGroupType.Aggressive; this.m_bIsPlayerOrder = false; this.m_bIsInContactWithEnemy = false; this.m_EnemyGroupInContact = (EnemyGroup)null; this.m_Ships = new List <Ship>(); this.m_Targets = new List <Ship>(); this.m_ShipControls = new List <TaskGroupShipControl>(); this.m_TargetGroup = (EnemyGroup)null; this.m_TargetTaskGroup = (TaskGroup)null; this.m_PatrolType = PatrolType.Circular; this.m_RequestedObjectiveType = ObjectiveType.NO_OBJECTIVE; this.m_NumShipTypes = new int[14]; for (int index = 0; index < 14; ++index) { this.m_NumShipTypes[index] = 0; } this.m_GroupSpeed = 0.0f; this.m_RequestRefreshShipControls = false; this.m_ChangeAttackTime = 4800; this.m_CurrentChangeAttackDelay = this.m_ChangeAttackTime; }
public virtual void Shutdown() { this.m_TargetTaskGroup = (TaskGroup)null; this.m_TargetEnemyGroup = (EnemyGroup)null; this.m_PoliceOwner = (Ship)null; this.m_Planet = (StellarBody)null; this.m_TaskGroups.Clear(); }
public virtual void RemoveTaskGroup(TaskGroup group) { if (!this.m_TaskGroups.Contains(group)) { return; } this.m_TaskGroups.Remove(group); group.Objective = (TacticalObjective)null; this.m_CurrentResources = this.CurrentResources(); }
public void ResetRetreatPosition(TaskGroup tg) { if (tg == null) { return; } float length = this.m_Destination.Length; this.m_Destination = Vector3.Normalize(tg.GetBaseGroupPosition()) * length; }
public Vector3 GetPatrolDirection(TaskGroup tg) { int index = 0; foreach (TaskGroup taskGroup in this.m_TaskGroups) { if (taskGroup != tg) { ++index; } else { break; } } return(this.GetPatrolDirection(index)); }
public override void AssignResources(TaskGroup group) { base.AssignResources(group); }
public virtual void AssignResources(TaskGroup group) { this.m_TaskGroups.Add(group); group.Objective = this; this.m_CurrentResources = this.CurrentResources(); }
private TaskGroupShipControl CreateFlankAttackGroups( List <Ship> ships, Vector3 attackVec) { float num = 0.0f; foreach (Ship ship in ships) { num += CombatAI.GetMinEffectiveWeaponRange(ship, false); } float minDist = num / (float)ships.Count * 0.75f; float desiredDist = minDist + 500f; FlankShipControl flankShipControl = new FlankShipControl(this.m_Game, this.m_Objective, this.m_CommanderAI, attackVec, minDist, desiredDist); foreach (Ship ship in ships) { flankShipControl.AddShip(ship, (this.m_Type == TaskGroupType.Aggressive || this.m_Type == TaskGroupType.Passive) && TaskGroup.GetTaskTypeFromShip(ship) == TaskGroupType.Civilian); } return((TaskGroupShipControl)flankShipControl); }
private TaskGroupShipControl CreateFlyByAttackGroup(List <Ship> ships) { float num = 0.0f; foreach (Ship ship in ships) { num += CombatAI.GetMinEffectiveWeaponRange(ship, false); } FlyByShipControl flyByShipControl = new FlyByShipControl(this.m_Game, this.m_Objective, this.m_CommanderAI, Math.Max(num / (float)ships.Count * 0.75f, 1000f)); foreach (Ship ship in ships) { flyByShipControl.AddShip(ship, (this.m_Type == TaskGroupType.Aggressive || this.m_Type == TaskGroupType.Passive) && TaskGroup.GetTaskTypeFromShip(ship) == TaskGroupType.Civilian); } return((TaskGroupShipControl)flyByShipControl); }
private TaskGroupShipControl CreateSupportGroup( List <Ship> ships, TaskGroupShipControl supportGroup) { SupportGroupShipControl groupShipControl = new SupportGroupShipControl(this.m_Game, this.m_Objective, this.m_CommanderAI, supportGroup); foreach (Ship ship in ships) { groupShipControl.AddShip(ship, (this.m_Type == TaskGroupType.Aggressive || this.m_Type == TaskGroupType.Passive) && TaskGroup.GetTaskTypeFromShip(ship) == TaskGroupType.Civilian); } return((TaskGroupShipControl)groupShipControl); }
private TaskGroupShipControl CreatePursueAttackGroup(List <Ship> ships) { float val1_1 = float.MaxValue; float val1_2 = float.MaxValue; foreach (Ship ship in ships) { val1_1 = Math.Min(val1_1, CombatAI.GetAveEffectiveWeaponRange(ship, false)); val1_2 = Math.Min(val1_2, ship.SensorRange); } PursueShipControl pursueShipControl = new PursueShipControl(this.m_Game, this.m_Objective, this.m_CommanderAI, Math.Min(val1_1 * 0.75f, val1_2 * 0.75f)); foreach (Ship ship in ships) { pursueShipControl.AddShip(ship, (this.m_Type == TaskGroupType.Aggressive || this.m_Type == TaskGroupType.Passive) && TaskGroup.GetTaskTypeFromShip(ship) == TaskGroupType.Civilian); } return((TaskGroupShipControl)pursueShipControl); }
private TaskGroupShipControl CreateStandOffAttackGroup(List <Ship> ships) { float num1 = 0.0f; float val1 = float.MaxValue; foreach (Ship ship in ships) { num1 += CombatAI.GetMinEffectiveWeaponRange(ship, false); val1 = Math.Min(val1, ship.SensorRange); } float num2 = num1 / (float)ships.Count; float num3 = val1 * 0.75f; float minDist = num2 * 0.75f; float desiredDist = minDist + 500f; if ((double)desiredDist > (double)num3) { desiredDist = num3; minDist = 0.75f * desiredDist; } else if ((double)minDist >= (double)desiredDist) { minDist = desiredDist * 0.75f; } StandOffShipControl standOffShipControl = new StandOffShipControl(this.m_Game, this.m_Objective, this.m_CommanderAI, minDist, desiredDist); foreach (Ship ship in ships) { standOffShipControl.AddShip(ship, (this.m_Type == TaskGroupType.Aggressive || this.m_Type == TaskGroupType.Passive) && TaskGroup.GetTaskTypeFromShip(ship) == TaskGroupType.Civilian); } return((TaskGroupShipControl)standOffShipControl); }
public static EnemyGroupData GetEnemyGroupData( CombatAI ai, EnemyGroup eg, List <StellarBody> planets) { EnemyGroupData enemyGroupData = new EnemyGroupData(); enemyGroupData.DistanceFromColony = 0.0f; enemyGroupData.NumAggressive = 0; enemyGroupData.NumCivilian = 0; enemyGroupData.NumPassive = 0; enemyGroupData.NumUnarmed = 0; enemyGroupData.IsAttackingPlanetOrStation = false; enemyGroupData.IsEncounter = false; enemyGroupData.IsFreighter = false; enemyGroupData.IsStation = false; foreach (Ship ship in eg.m_Ships) { if (ship.ShipRole == ShipRole.FREIGHTER) { enemyGroupData.IsFreighter = true; } if (TaskGroup.IsValidTaskGroupShip(ship)) { switch (TaskGroup.GetTaskTypeFromShip(ship)) { case TaskGroupType.Aggressive: case TaskGroupType.Police: case TaskGroupType.BoardingGroup: case TaskGroupType.FollowGroup: case TaskGroupType.PlanetAssault: ++enemyGroupData.NumAggressive; break; case TaskGroupType.Passive: ++enemyGroupData.NumPassive; break; case TaskGroupType.Civilian: ++enemyGroupData.NumCivilian; break; case TaskGroupType.UnArmed: ++enemyGroupData.NumUnarmed; break; } } else if (ship.ShipClass == ShipClass.Station) { enemyGroupData.IsStation = true; } if (ship.Target != null && !enemyGroupData.IsAttackingPlanetOrStation) { if (ship.Target is Ship) { Ship target = ship.Target as Ship; enemyGroupData.IsAttackingPlanetOrStation = target.Player == ai.m_Player && target.ShipClass == ShipClass.Station; } else if (ship.Target is StellarBody && (ship.Target as StellarBody).Parameters.ColonyPlayerID == ai.m_Player.ID) { enemyGroupData.IsAttackingPlanetOrStation = true; } } enemyGroupData.IsEncounter = enemyGroupData.IsEncounter || ai.IsEncounterPlayer(ship.Player.ID); foreach (StellarBody planet in planets) { if (planet.Parameters.ColonyPlayerID == ai.m_Player.ID) { float lengthSquared = (planet.Parameters.Position - ship.Position).LengthSquared; if ((double)enemyGroupData.DistanceFromColony == 0.0 || (double)lengthSquared < (double)enemyGroupData.DistanceFromColony) { enemyGroupData.DistanceFromColony = lengthSquared; } } } } if ((double)enemyGroupData.DistanceFromColony > 0.0) { enemyGroupData.DistanceFromColony = (float)Math.Sqrt((double)enemyGroupData.DistanceFromColony); } return(enemyGroupData); }