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);
}
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)
{
// 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);

View File

@@ -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);
}
}

View File

@@ -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<int> damageModifiers)
{
var damage = Util.ApplyPercentageModifiers(Damage, damageModifiers.Append(DamageVersus(victim, hitshapeInfo)));
victim.InflictDamage(firedBy, new Damage(damage, DamageTypes));
}
}
}