From 04e05d9aedc06c692c0580fea9dd4a23f151c417 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 13 Nov 2010 14:59:33 +1300 Subject: [PATCH] remove the default impl of QueueAttack; implement it in AttackFrontal and AttackLeap --- OpenRA.Mods.RA/AttackBase.cs | 11 +---------- OpenRA.Mods.RA/AttackFrontal.cs | 11 +++++++++++ OpenRA.Mods.RA/AttackLeap.cs | 13 +++++++++++++ 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/OpenRA.Mods.RA/AttackBase.cs b/OpenRA.Mods.RA/AttackBase.cs index 5307de4e11..039a88f1e8 100644 --- a/OpenRA.Mods.RA/AttackBase.cs +++ b/OpenRA.Mods.RA/AttackBase.cs @@ -181,16 +181,7 @@ namespace OpenRA.Mods.RA return (order.OrderString == "Attack") ? "Attack" : null; } - protected virtual void QueueAttack(Actor self, Target newTarget) - { - var weapon = ChooseWeaponForTarget(newTarget); - - if (weapon != null) - self.QueueActivity( - new Activities.Attack( - newTarget, - Math.Max(0, (int)weapon.Info.Range))); - } + protected abstract void QueueAttack(Actor self, Target newTarget); public bool HasAnyValidWeapons(Target t) { return Weapons.Any(w => w.IsValidAgainst(self.World, t)); } public float GetMaximumRange() { return Weapons.Max(w => w.Info.Range); } diff --git a/OpenRA.Mods.RA/AttackFrontal.cs b/OpenRA.Mods.RA/AttackFrontal.cs index 877bdf105f..62ea298c09 100644 --- a/OpenRA.Mods.RA/AttackFrontal.cs +++ b/OpenRA.Mods.RA/AttackFrontal.cs @@ -39,5 +39,16 @@ namespace OpenRA.Mods.RA return true; } + + protected override void QueueAttack(Actor self, Target newTarget) + { + var weapon = ChooseWeaponForTarget(newTarget); + + if (weapon != null) + self.QueueActivity( + new Activities.Attack( + newTarget, + Math.Max(0, (int)weapon.Info.Range))); + } } } diff --git a/OpenRA.Mods.RA/AttackLeap.cs b/OpenRA.Mods.RA/AttackLeap.cs index 23ba4a296e..c206f79929 100644 --- a/OpenRA.Mods.RA/AttackLeap.cs +++ b/OpenRA.Mods.RA/AttackLeap.cs @@ -9,6 +9,8 @@ #endregion using OpenRA.Mods.RA.Activities; +using System; +using OpenRA.Traits; namespace OpenRA.Mods.RA { @@ -37,5 +39,16 @@ namespace OpenRA.Mods.RA self.CancelActivity(); self.QueueActivity(new Leap(self, target)); } + + protected override void QueueAttack(Actor self, Target newTarget) + { + var weapon = ChooseWeaponForTarget(newTarget); + + if (weapon != null) + self.QueueActivity( + new Activities.Attack( + newTarget, + Math.Max(0, (int)weapon.Info.Range))); + } } }