diff --git a/OpenRA.Mods.Common/Activities/Attack.cs b/OpenRA.Mods.Common/Activities/Attack.cs index 40d71f7533..6aeee68d30 100644 --- a/OpenRA.Mods.Common/Activities/Attack.cs +++ b/OpenRA.Mods.Common/Activities/Attack.cs @@ -10,6 +10,7 @@ #endregion using System; +using System.Collections.Generic; using System.Linq; using OpenRA.Activities; using OpenRA.Mods.Common.Traits; @@ -200,8 +201,16 @@ namespace OpenRA.Mods.Common.Activities } attackStatus |= AttackStatus.Attacking; - attack.DoAttack(self, target, armaments); + DoAttack(self, attack, armaments); + return AttackStatus.Attacking; } + + protected virtual void DoAttack(Actor self, AttackFrontal attack, IEnumerable armaments) + { + if (!attack.IsTraitPaused) + foreach (var a in armaments) + a.CheckFire(self, facing, target); + } } } diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs index 0845e6be4b..66a4263185 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs @@ -122,12 +122,12 @@ namespace OpenRA.Mods.Common.Traits return true; } - public virtual void DoAttack(Actor self, Target target, IEnumerable armaments = null) + public virtual void DoAttack(Actor self, Target target) { - if (armaments == null && !CanAttack(self, target)) + if (!CanAttack(self, target)) return; - foreach (var a in armaments ?? Armaments) + foreach (var a in Armaments) a.CheckFire(self, facing, target); } @@ -350,7 +350,7 @@ namespace OpenRA.Mods.Common.Traits public void AttackTarget(Target target, bool queued, bool allowMove, bool forceAttack = false) { - if (IsTraitDisabled || IsTraitPaused) + if (IsTraitDisabled) return; if (!target.IsValidFor(self)) diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackGarrisoned.cs b/OpenRA.Mods.Common/Traits/Attack/AttackGarrisoned.cs index f286ce4e3f..2069105d60 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackGarrisoned.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackGarrisoned.cs @@ -142,7 +142,7 @@ namespace OpenRA.Mods.Common.Traits return coords.Value.LocalToWorld(p.Offset.Rotate(bodyOrientation)); } - public override void DoAttack(Actor self, Target target, IEnumerable armaments = null) + public override void DoAttack(Actor self, Target target) { if (!CanAttack(self, target)) return; diff --git a/OpenRA.Mods.D2k/Traits/AttackSwallow.cs b/OpenRA.Mods.D2k/Traits/AttackSwallow.cs index a4589937df..fe18d5b5f5 100644 --- a/OpenRA.Mods.D2k/Traits/AttackSwallow.cs +++ b/OpenRA.Mods.D2k/Traits/AttackSwallow.cs @@ -50,7 +50,7 @@ namespace OpenRA.Mods.D2k.Traits Info = info; } - public override void DoAttack(Actor self, Target target, IEnumerable armaments = null) + public override void DoAttack(Actor self, Target target) { // This is so that the worm does not launch an attack against a target that has reached solid rock if (target.Type != TargetType.Actor || !CanAttack(self, target)) @@ -86,6 +86,11 @@ namespace OpenRA.Mods.D2k.Traits targetIsHiddenActor = false; return target; } + + protected override void DoAttack(Actor self, AttackFrontal attack, IEnumerable armaments) + { + attack.DoAttack(self, target); + } } } }