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

@@ -32,19 +32,23 @@ namespace OpenRA.Mods.Common.Traits
public virtual object Create(ActorInitializer init) { return new Repairable(init.Self, this); }
}
class Repairable : IIssueOrder, IResolveOrder, IOrderVoice
class Repairable : IIssueOrder, IResolveOrder, IOrderVoice, INotifyCreated
{
public readonly RepairableInfo Info;
readonly IHealth health;
readonly IMove movement;
readonly AmmoPool[] ammoPools;
Rearmable rearmable;
public Repairable(Actor self, RepairableInfo info)
{
Info = info;
health = self.Trait<IHealth>();
movement = self.Trait<IMove>();
ammoPools = self.TraitsImplementing<AmmoPool>().ToArray();
}
void INotifyCreated.Created(Actor self)
{
rearmable = self.TraitOrDefault<Rearmable>();
}
public IEnumerable<IOrderTargeter> Orders
@@ -70,7 +74,7 @@ namespace OpenRA.Mods.Common.Traits
bool CanRearmAt(Actor target)
{
return Info.RepairBuildings.Contains(target.Info.Name);
return rearmable != null && rearmable.Info.RearmActors.Contains(target.Info.Name);
}
bool CanRepair()
@@ -80,7 +84,7 @@ namespace OpenRA.Mods.Common.Traits
bool CanRearm()
{
return ammoPools.Any(x => !x.AutoReloads && !x.FullAmmo());
return rearmable != null && rearmable.RearmableAmmoPools.Any(p => !p.FullAmmo());
}
public string VoicePhraseForOrder(Actor self, Order order)