Refactored Health usage to IHealth.

This commit is contained in:
Andre Mohren
2018-09-27 02:02:08 +02:00
committed by reaperrr
parent 83cd7cf485
commit 640078a2b1
30 changed files with 68 additions and 61 deletions

View File

@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Warheads
if (!AffectsParent && victim == firedBy)
continue;
if (!victim.Info.HasTraitInfo<HealthInfo>())
if (!victim.Info.HasTraitInfo<IHealthInfo>())
continue;
// If the impact position is within any HitShape, we have a direct hit

View File

@@ -43,12 +43,12 @@ namespace OpenRA.Mods.Common.Warheads
if (!IsValidAgainst(victim, firedBy))
return;
var healthInfo = victim.Info.TraitInfoOrDefault<HealthInfo>();
var healthInfo = victim.Info.TraitInfoOrDefault<IHealthInfo>();
if (healthInfo == null)
return;
// Damage is measured as a percentage of the target health
var damage = Util.ApplyPercentageModifiers(healthInfo.HP, damageModifiers.Append(Damage, DamageVersus(victim)));
var damage = Util.ApplyPercentageModifiers(healthInfo.MaxHP, damageModifiers.Append(Damage, DamageVersus(victim)));
victim.InflictDamage(firedBy, new Damage(damage, DamageTypes));
}
}

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Warheads
foreach (var victim in hitActors)
{
// Cannot be damaged without a Health trait
var healthInfo = victim.Info.TraitInfoOrDefault<HealthInfo>();
var healthInfo = victim.Info.TraitInfoOrDefault<IHealthInfo>();
if (healthInfo == null)
continue;