mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 08:13:15 +08:00
Fix initial animation not playing correctly
This commit is contained in:
parent
80892f3167
commit
9c7e555237
@ -36,6 +36,8 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
private BindableNumber<double> health = null!;
|
private BindableNumber<double> health = null!;
|
||||||
|
|
||||||
|
protected bool InitialAnimationPlaying => initialIncrease != null;
|
||||||
|
|
||||||
private ScheduledDelegate? initialIncrease;
|
private ScheduledDelegate? initialIncrease;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -64,25 +66,35 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
// this probably shouldn't be operating on `this.`
|
// this probably shouldn't be operating on `this.`
|
||||||
showHealthBar.BindValueChanged(healthBar => this.FadeTo(healthBar.NewValue ? 1 : 0, HUDOverlay.FADE_DURATION, HUDOverlay.FADE_EASING), true);
|
showHealthBar.BindValueChanged(healthBar => this.FadeTo(healthBar.NewValue ? 1 : 0, HUDOverlay.FADE_DURATION, HUDOverlay.FADE_EASING), true);
|
||||||
|
|
||||||
|
initialHealthValue = health.Value;
|
||||||
|
|
||||||
if (PlayInitialIncreaseAnimation)
|
if (PlayInitialIncreaseAnimation)
|
||||||
startInitialAnimation();
|
startInitialAnimation();
|
||||||
else
|
else
|
||||||
Current.Value = health.Value;
|
Current.Value = health.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double lastValue;
|
||||||
|
private double initialHealthValue;
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
// Health changes every frame in draining situations.
|
if (!InitialAnimationPlaying || health.Value != initialHealthValue)
|
||||||
// Manually handle value changes to avoid bindable event flow overhead.
|
|
||||||
if (!Precision.AlmostEquals(health.Value, Current.Value, 0.001f))
|
|
||||||
{
|
{
|
||||||
|
Current.Value = health.Value;
|
||||||
|
|
||||||
if (initialIncrease != null)
|
if (initialIncrease != null)
|
||||||
FinishInitialAnimation(Current.Value);
|
FinishInitialAnimation(Current.Value);
|
||||||
|
}
|
||||||
|
|
||||||
HealthChanged(Current.Value > health.Value);
|
// Health changes every frame in draining situations.
|
||||||
Current.Value = health.Value;
|
// Manually handle value changes to avoid bindable event flow overhead.
|
||||||
|
if (!Precision.AlmostEquals(lastValue, Current.Value, 0.001f))
|
||||||
|
{
|
||||||
|
HealthChanged(Current.Value > lastValue);
|
||||||
|
lastValue = Current.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user