Exemple #1
0
 public bool ExecuteOrders()
 {
     if (!Vehicles.ExceptSingle(null).Any())
     {
         return(false);                // fleets with no vehicles can't execute orders
     }
     return(this.ExecuteMobileSpaceObjectOrders());
 }
Exemple #2
0
 /// <summary>
 /// Disposes of the fleet. Does not dispose of the individual ships; they are removed from the fleet instead.
 /// </summary>
 public void Dispose()
 {
     if (IsDisposed)
     {
         return;
     }
     IsDisposed = true;
     foreach (var v in Vehicles.ExceptSingle(null))
     {
         v.Container = null;
     }
     Vehicles.Clear();
     Galaxy.Current.UnassignID(this);
     Sector = null;
     Orders.Clear();
     if (!IsMemory)
     {
         this.UpdateEmpireMemories();
     }
 }
Exemple #3
0
 /// <summary>
 /// Remove any invalid objects from the fleet and any valid subfleets.
 /// If there are no valid objects left, the fleet is disbanded.
 /// Objects that are invalid:
 /// * Ships, etc. not owned by the owner of the fleet
 /// * This fleet (fleets may not contain themselves)
 /// * Space objects that are not located in the same sector as this fleet
 /// * Space objects that are destroyed
 /// </summary>
 public void Validate(ICollection <Fleet> ancestors = null)
 {
     if (ancestors == null)
     {
         ancestors = new List <Fleet>();
     }
     ancestors.Add(this);
     foreach (var sobj in Vehicles.ToArray())
     {
         if (sobj == null || sobj.Owner != Owner || (sobj is Fleet && ancestors.Contains((Fleet)sobj)) || sobj.Sector != Sector || sobj.IsDestroyed)
         {
             Vehicles.Remove(sobj);
         }
         else if (sobj is Fleet)
         {
             ((Fleet)sobj).Validate(ancestors);
         }
     }
     if (!Vehicles.ExceptSingle(null).Any())
     {
         Dispose();
     }
 }