Remove passing the warheads from DamageWarhead to AttackInfo.
Added a Damage class to pass damage value and damage(types) instead. This removes a great amount of overhead and longterm opens possibilities to have damagetypes without warheads.
This commit is contained in:
@@ -56,8 +56,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
var warhead = e.Warhead as DamageWarhead;
|
||||
if (e.Damage <= 0 || warhead == null || !warhead.DamageTypes.Overlaps(info.DamageTriggers))
|
||||
if (e.Damage.Value <= 0 || !e.Damage.DamageTypes.Overlaps(info.DamageTriggers))
|
||||
return;
|
||||
|
||||
if (!IsProne)
|
||||
@@ -79,16 +78,15 @@ namespace OpenRA.Mods.Common.Traits
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public int GetDamageModifier(Actor attacker, IWarhead warhead)
|
||||
public int GetDamageModifier(Actor attacker, Damage damage)
|
||||
{
|
||||
if (!IsProne)
|
||||
return 100;
|
||||
|
||||
var damageWh = warhead as DamageWarhead;
|
||||
if (damageWh == null)
|
||||
if (damage.DamageTypes.Count == 0)
|
||||
return 100;
|
||||
|
||||
var modifierPercentages = info.DamageModifiers.Where(x => damageWh.DamageTypes.Contains(x.Key)).Select(x => x.Value);
|
||||
var modifierPercentages = info.DamageModifiers.Where(x => damage.DamageTypes.Contains(x.Key)).Select(x => x.Value);
|
||||
return Util.ApplyPercentageModifiers(100, modifierPercentages);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user