mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 01:27:20 +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)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
|
if (sampleHover == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
bool enoughTimePassedSinceLastPlayback = !lastPlaybackTime.Value.HasValue || Time.Current - lastPlaybackTime.Value >= HoverDebounceTime;
|
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.Frequency.Value = 0.96 + RNG.NextDouble(0.08);
|
||||||
sampleHover.Play();
|
sampleHover.Play();
|
||||||
@ -58,7 +61,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
lastPlaybackTime.Value = Time.Current;
|
lastPlaybackTime.Value = Time.Current;
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.OnHover(e);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user