/// <summary> Applies damage to an object that can receive it. </summary> public static int ApplyDamage(IDamageReceiver receiver, int damageAmount) { int newHealthAmount = Math.Max(0, receiver.Health - damageAmount); int damageDone = receiver.Health - newHealthAmount; receiver.Health = newHealthAmount; if (receiver.Health <= 0) { receiver.OnHealthDepleted(); } return(damageDone); }