Remove RearmBuildings from Aircraft and Minelayer

In favor of using Rearmable trait.
This commit is contained in:
reaperrr
2018-09-27 17:50:35 +02:00
committed by Paul Chote
parent 2485029452
commit 8f1d8a67cc
19 changed files with 191 additions and 69 deletions

View File

@@ -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());
}
}
}