Move InflictDamage method back to DamageWarhead

From TargetDamageWarhead.
Saves a few lines and allows warheads that are not
TargetDamageWarhead-based to use it.
This commit is contained in:
reaperrr
2019-05-12 23:47:58 +02:00
committed by reaperrr
parent 07de3ba5e0
commit 8edd202b64
3 changed files with 8 additions and 10 deletions

View File

@@ -51,6 +51,12 @@ namespace OpenRA.Mods.Common.Warheads
return Util.ApplyPercentageModifiers(100, armor); return Util.ApplyPercentageModifiers(100, armor);
} }
protected virtual void InflictDamage(Actor victim, Actor firedBy, HitShapeInfo hitshapeInfo, IEnumerable<int> 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<int> damageModifiers) public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)
{ {
// Used by traits or warheads that damage a single actor, rather than a position // 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) if (closestActiveShape == null)
return; return;
var damage = Util.ApplyPercentageModifiers(Damage, damageModifiers.Append(DamageVersus(victim, closestActiveShape.Info))); InflictDamage(victim, firedBy, closestActiveShape.Info, damageModifiers);
victim.InflictDamage(firedBy, new Damage(damage, DamageTypes));
} }
else if (target.Type != TargetType.Invalid) else if (target.Type != TargetType.Invalid)
DoImpact(target.CenterPosition, firedBy, damageModifiers); DoImpact(target.CenterPosition, firedBy, damageModifiers);

View File

@@ -65,8 +65,7 @@ namespace OpenRA.Mods.Common.Warheads
continue; continue;
var localModifiers = damageModifiers.Append(GetDamageFalloff(closestActiveShape.Second.Length)); var localModifiers = damageModifiers.Append(GetDamageFalloff(closestActiveShape.Second.Length));
var damage = Util.ApplyPercentageModifiers(Damage, localModifiers.Append(DamageVersus(victim, closestActiveShape.First.Info))); InflictDamage(victim, firedBy, closestActiveShape.First.Info, localModifiers);
victim.InflictDamage(firedBy, new Damage(damage, DamageTypes));
} }
} }

View File

@@ -48,11 +48,5 @@ namespace OpenRA.Mods.Common.Warheads
InflictDamage(victim, firedBy, closestActiveShape.First.Info, damageModifiers); InflictDamage(victim, firedBy, closestActiveShape.First.Info, damageModifiers);
} }
} }
protected virtual void InflictDamage(Actor victim, Actor firedBy, HitShapeInfo hitshapeInfo, IEnumerable<int> damageModifiers)
{
var damage = Util.ApplyPercentageModifiers(Damage, damageModifiers.Append(DamageVersus(victim, hitshapeInfo)));
victim.InflictDamage(firedBy, new Damage(damage, DamageTypes));
}
} }
} }