DamageableSystem cleanup & performance improvements (#20820)

This commit is contained in:
Leon Friedrich
2023-10-09 03:27:41 +11:00
committed by GitHub
parent 70246ae10e
commit 364c9b7f0a
12 changed files with 135 additions and 77 deletions

View File

@@ -495,7 +495,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
var modifiedDamage = DamageSpecifier.ApplyModifierSets(damage + hitEvent.BonusDamage + attackedEvent.BonusDamage, hitEvent.ModifiersList);
var damageResult = Damageable.TryChangeDamage(target, modifiedDamage, origin:user);
if (damageResult != null && damageResult.Total > FixedPoint2.Zero)
if (damageResult != null && damageResult.Any())
{
// If the target has stamina and is taking blunt damage, they should also take stamina damage based on their blunt to stamina factor
if (damageResult.DamageDict.TryGetValue("Blunt", out var bluntDamage))
@@ -522,7 +522,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
{
Audio.PlayPredicted(hitEvent.HitSoundOverride, meleeUid, user);
}
else if (GetDamage(meleeUid, user, component).Total.Equals(FixedPoint2.Zero) && component.HitSound != null)
else if (!GetDamage(meleeUid, user, component).Any() && component.HitSound != null)
{
Audio.PlayPredicted(component.HitSound, meleeUid, user);
}