1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 10:22:56 +08:00

FIx mania playfield playing the wrong/duplicated sounds

Fixes #2266.
This commit is contained in:
smoogipoo 2018-03-29 16:13:05 +09:00
parent 187a025d36
commit bb7618eb0c

View File

@ -262,21 +262,13 @@ namespace osu.Game.Rulesets.Mania.UI
public bool OnPressed(ManiaAction action) public bool OnPressed(ManiaAction action)
{ {
// Play the sounds of the next hitobject if (action != Action)
if (HitObjects.AliveObjects.Any()) return false;
{
// If there are alive hitobjects, we can abuse the fact that AliveObjects are sorted by time (see: Add())
HitObjects.AliveObjects.First().PlaySamples();
}
else
{
// If not, we do a slow search - we might want to do a BinarySearch here if this becomes problematic
// We fallback to LastOrDefault() if we're beyond the last note in the map
var hitObject = HitObjects.Objects.FirstOrDefault(h => h.HitObject.StartTime > Time.Current) ?? HitObjects.Objects.LastOrDefault();
hitObject?.PlaySamples();
}
return false; var hitObject = HitObjects.Objects.LastOrDefault(h => h.HitObject.StartTime > Time.Current) ?? HitObjects.Objects.FirstOrDefault();
hitObject?.PlaySamples();
return true;
} }
public bool OnReleased(ManiaAction action) => false; public bool OnReleased(ManiaAction action) => false;