mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Simplify with an early exit for null sample
This commit is contained in:
parent
73ab1b2b21
commit
625eb78a11
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user