private void OnDamaged(float damage) { Model.Health -= damage; if (Model.Health <= 0) { Model.Health = 0; Died.SafeRaise(this); ApplyState <TankDiedState>(); } Model.SetChanges(); }
private void OnDamaged(float damagedHealth) { var currentHealth = Model.Health; float newHealth = Mathf.Clamp(currentHealth - damagedHealth, 0f, int.MaxValue); Model.Health = newHealth; Model.SetChanges(); if (!(this as ITank).IsAlive) { Died.SafeRaise(this); ApplyState <TankDiedState>(); } }