From 8edd202b64a935ee8ccb22c2f8192fe2431d6029 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 12 May 2019 23:47:58 +0200 Subject: [PATCH] Move InflictDamage method back to DamageWarhead From TargetDamageWarhead. Saves a few lines and allows warheads that are not TargetDamageWarhead-based to use it. --- OpenRA.Mods.Common/Warheads/DamageWarhead.cs | 9 +++++++-- OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs | 3 +-- OpenRA.Mods.Common/Warheads/TargetDamageWarhead.cs | 6 ------ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/OpenRA.Mods.Common/Warheads/DamageWarhead.cs b/OpenRA.Mods.Common/Warheads/DamageWarhead.cs index b766f8b74b..44ec49744f 100644 --- a/OpenRA.Mods.Common/Warheads/DamageWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/DamageWarhead.cs @@ -51,6 +51,12 @@ namespace OpenRA.Mods.Common.Warheads return Util.ApplyPercentageModifiers(100, armor); } + protected virtual void InflictDamage(Actor victim, Actor firedBy, HitShapeInfo hitshapeInfo, IEnumerable damageModifiers) + { + var damage = Util.ApplyPercentageModifiers(Damage, damageModifiers.Append(DamageVersus(victim, hitshapeInfo))); + victim.InflictDamage(firedBy, new Damage(damage, DamageTypes)); + } + public override void DoImpact(Target target, Actor firedBy, IEnumerable damageModifiers) { // Used by traits or warheads that damage a single actor, rather than a position @@ -68,8 +74,7 @@ namespace OpenRA.Mods.Common.Warheads if (closestActiveShape == null) return; - var damage = Util.ApplyPercentageModifiers(Damage, damageModifiers.Append(DamageVersus(victim, closestActiveShape.Info))); - victim.InflictDamage(firedBy, new Damage(damage, DamageTypes)); + InflictDamage(victim, firedBy, closestActiveShape.Info, damageModifiers); } else if (target.Type != TargetType.Invalid) DoImpact(target.CenterPosition, firedBy, damageModifiers); diff --git a/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs b/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs index 372756a1a8..35a4dfbec8 100644 --- a/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs @@ -65,8 +65,7 @@ namespace OpenRA.Mods.Common.Warheads continue; var localModifiers = damageModifiers.Append(GetDamageFalloff(closestActiveShape.Second.Length)); - var damage = Util.ApplyPercentageModifiers(Damage, localModifiers.Append(DamageVersus(victim, closestActiveShape.First.Info))); - victim.InflictDamage(firedBy, new Damage(damage, DamageTypes)); + InflictDamage(victim, firedBy, closestActiveShape.First.Info, localModifiers); } } diff --git a/OpenRA.Mods.Common/Warheads/TargetDamageWarhead.cs b/OpenRA.Mods.Common/Warheads/TargetDamageWarhead.cs index 92a56bf869..87eb8799ef 100644 --- a/OpenRA.Mods.Common/Warheads/TargetDamageWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/TargetDamageWarhead.cs @@ -48,11 +48,5 @@ namespace OpenRA.Mods.Common.Warheads InflictDamage(victim, firedBy, closestActiveShape.First.Info, damageModifiers); } } - - protected virtual void InflictDamage(Actor victim, Actor firedBy, HitShapeInfo hitshapeInfo, IEnumerable damageModifiers) - { - var damage = Util.ApplyPercentageModifiers(Damage, damageModifiers.Append(DamageVersus(victim, hitshapeInfo))); - victim.InflictDamage(firedBy, new Damage(damage, DamageTypes)); - } } }