diff --git a/OpenRA.Mods.RA/Attack/AttackBase.cs b/OpenRA.Mods.RA/Attack/AttackBase.cs index ffe81448d9..dad546da64 100644 --- a/OpenRA.Mods.RA/Attack/AttackBase.cs +++ b/OpenRA.Mods.RA/Attack/AttackBase.cs @@ -20,6 +20,9 @@ namespace OpenRA.Mods.RA { public abstract class AttackBaseInfo : ITraitInfo { + [Desc("Armament names")] + public readonly string[] Armaments = { "primary", "secondary" }; + public readonly string Cursor = "attack"; public readonly string OutsideRangeCursor = "attackoutsiderange"; @@ -29,21 +32,24 @@ namespace OpenRA.Mods.RA public abstract class AttackBase : IIssueOrder, IResolveOrder, IOrderVoice, ISync { [Sync] public bool IsAttacking { get; internal set; } + public IEnumerable Armaments { get { return GetArmaments(); } } + protected Lazy facing; + protected Lazy building; + protected Func> GetArmaments; readonly Actor self; readonly AttackBaseInfo info; - protected Lazy facing; - Lazy> armaments; - protected IEnumerable Armaments { get { return armaments.Value; } } - protected Lazy building; - public AttackBase(Actor self, AttackBaseInfo info) { this.self = self; this.info = info; - armaments = Lazy.New(() => self.TraitsImplementing()); + var armaments = Lazy.New(() => self.TraitsImplementing() + .Where(a => info.Armaments.Contains(a.Info.Name))); + + GetArmaments = () => armaments.Value; + facing = Lazy.New(() => self.TraitOrDefault()); building = Lazy.New(() => self.TraitOrDefault()); } diff --git a/mods/cnc/rules/aircraft.yaml b/mods/cnc/rules/aircraft.yaml index 788ed31441..7275430174 100644 --- a/mods/cnc/rules/aircraft.yaml +++ b/mods/cnc/rules/aircraft.yaml @@ -197,6 +197,7 @@ A10: RenderUnit: WithShadow: AttackBomber: + Armaments: gun, bombs Guns: gun Bombs: bombs Armament@GUNS: