1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:07:25 +08:00

Simplify with an early exit for null sample

This commit is contained in:
Dean Herbert 2021-02-10 17:59:52 +09:00
parent 73ab1b2b21
commit 625eb78a11

View File

@ -48,9 +48,12 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnHover(HoverEvent e)
{
if (sampleHover == null)
return false;
bool enoughTimePassedSinceLastPlayback = !lastPlaybackTime.Value.HasValue || Time.Current - lastPlaybackTime.Value >= HoverDebounceTime;
if (enoughTimePassedSinceLastPlayback && sampleHover != null)
if (enoughTimePassedSinceLastPlayback)
{
sampleHover.Frequency.Value = 0.96 + RNG.NextDouble(0.08);
sampleHover.Play();
@ -58,7 +61,7 @@ namespace osu.Game.Graphics.UserInterface
lastPlaybackTime.Value = Time.Current;
}
return base.OnHover(e);
return false;
}
}