/// <summary> /// Suffer X amount of damage. If health is empty, call the virtual OnDeath event. /// </summary> /// <param name="damage">Amount of damage to suffer.</param> public void SufferDamage(float damage) { Health -= damage; OnUpdateHealthEvent?.Invoke(Health / MaxHealth); if (Health <= 0) { StatusEffectScheduler.Instance(_actor.Guid).AddStatusEffect(new StatusEffectSystem.Status(_actor, 1f, StatusEffectManager.GetStatusEffectData(Constant.DEATH))); } }
/// <summary> /// Increase the health value by X. The health value is capped at maximum health of the actor. /// </summary> /// <param name="value">Amount of health to increase.</param> public void IncreaseHealth(float value) { if (!_actor.Dead) { Health += value; if (Health > MaxHealth) { Health = MaxHealth; } OnUpdateHealthEvent?.Invoke(Health / MaxHealth); } }