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

Fix incorrect TimeUntilNextBeat and add TimeSinceLastBeat

This commit is contained in:
Thomas Müller 2017-07-10 12:07:38 +03:00
parent dfb484cfbb
commit d9b362489b

View File

@ -28,6 +28,11 @@ namespace osu.Game.Graphics.Containers
/// </summary> /// </summary>
public double TimeUntilNextBeat { get; private set; } public double TimeUntilNextBeat { get; private set; }
/// <summary>
/// The time in milliseconds since the last beat
/// </summary>
public double TimeSinceLastBeat { get; private set; }
protected override void Update() protected override void Update()
{ {
if (Beatmap.Value?.Track == null) if (Beatmap.Value?.Track == null)
@ -48,11 +53,15 @@ namespace osu.Game.Graphics.Containers
beatIndex--; beatIndex--;
TimeUntilNextBeat = (timingPoint.Time - currentTrackTime) % timingPoint.BeatLength; TimeUntilNextBeat = (timingPoint.Time - currentTrackTime) % timingPoint.BeatLength;
if (TimeUntilNextBeat < 0)
TimeUntilNextBeat += timingPoint.BeatLength;
TimeSinceLastBeat = timingPoint.BeatLength - TimeUntilNextBeat;
if (timingPoint == lastTimingPoint && beatIndex == lastBeat) if (timingPoint == lastTimingPoint && beatIndex == lastBeat)
return; return;
using (BeginDelayedSequence(TimeUntilNextBeat, true)) using (BeginDelayedSequence(-TimeSinceLastBeat, true))
OnNewBeat(beatIndex, timingPoint, effectPoint, Beatmap.Value.Track.CurrentAmplitudes); OnNewBeat(beatIndex, timingPoint, effectPoint, Beatmap.Value.Track.CurrentAmplitudes);
lastBeat = beatIndex; lastBeat = beatIndex;