Remove RearmBuildings from Aircraft and Minelayer
In favor of using Rearmable trait.
This commit is contained in:
@@ -20,6 +20,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
readonly Aircraft aircraft;
|
||||
readonly RepairableInfo repairableInfo;
|
||||
readonly Rearmable rearmable;
|
||||
readonly bool alwaysLand;
|
||||
readonly bool abortOnResupply;
|
||||
Actor dest;
|
||||
@@ -28,6 +29,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
aircraft = self.Trait<Aircraft>();
|
||||
repairableInfo = self.Info.TraitInfoOrDefault<RepairableInfo>();
|
||||
rearmable = self.TraitOrDefault<Rearmable>();
|
||||
this.alwaysLand = alwaysLand;
|
||||
this.abortOnResupply = abortOnResupply;
|
||||
this.dest = dest;
|
||||
@@ -35,9 +37,11 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
public Actor ChooseResupplier(Actor self, bool unreservedOnly)
|
||||
{
|
||||
var rearmBuildings = aircraft.Info.RearmBuildings;
|
||||
if (rearmable == null)
|
||||
return null;
|
||||
|
||||
return self.World.Actors.Where(a => a.Owner == self.Owner
|
||||
&& rearmBuildings.Contains(a.Info.Name)
|
||||
&& rearmable.Info.RearmActors.Contains(a.Info.Name)
|
||||
&& (!unreservedOnly || !Reservable.IsReserved(a)))
|
||||
.ClosestTo(self);
|
||||
}
|
||||
@@ -119,8 +123,8 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (repairableInfo != null && repairableInfo.RepairBuildings.Contains(dest.Info.Name) && self.GetDamageState() != DamageState.Undamaged)
|
||||
return true;
|
||||
|
||||
return aircraft.Info.RearmBuildings.Contains(dest.Info.Name) && self.TraitsImplementing<AmmoPool>()
|
||||
.Any(p => !p.AutoReloads && !p.FullAmmo());
|
||||
return rearmable != null && rearmable.Info.RearmActors.Contains(dest.Info.Name)
|
||||
&& rearmable.RearmableAmmoPools.Any(p => !p.FullAmmo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user