// -------------------------------------------------------------------------------------------- private void OnDamaged(Destructible.DamageEventInfo info) { if (!_visible) { SetVisible(true); } float startAmount = _slider.value; float endAmount = info.currentHealth / Destructible.MaxHealth; _sliderAnimation?.Stop(); _sliderAnimation = new TofuAnimation() .Value01(_sliderAnimTime, EEaseType.Linear, (float newValue) => { _slider.value = Mathf.LerpUnclamped(startAmount, endAmount, newValue); }) .WaitUntil(() => { return(_fadeAnimation == null); }) .Then() .Execute(() => { if (PlayerActor.MoveMode == PlayerActor.EMoveMode.FreeMove) { if (this) // check if we've been destroyed first { SetVisible(false); } } }) .Then() .Execute(() => { _sliderAnimation = null; }) .Play(); }