Add support for simple triple time

This commit is contained in:
Dean Herbert
2019-12-16 19:16:54 +09:00
parent 210fecc951
commit 72404bff9a
2 changed files with 56 additions and 14 deletions

View File

@ -33,6 +33,11 @@ namespace osu.Game.Graphics.Containers
/// </summary>
public double TimeSinceLastBeat { get; private set; }
/// <summary>
/// How many baets per beatlength to trigger. Defaults to 1.
/// </summary>
public int Divisor { get; set; } = 1;
/// <summary>
/// Default length of a beat in milliseconds. Used whenever there is no beatmap or track playing.
/// </summary>
@ -82,17 +87,19 @@ namespace osu.Game.Graphics.Containers
effectPoint = defaultEffect;
}
int beatIndex = (int)((currentTrackTime - timingPoint.Time) / timingPoint.BeatLength);
double beatLength = timingPoint.BeatLength / Divisor;
int beatIndex = (int)((currentTrackTime - timingPoint.Time) / beatLength);
// The beats before the start of the first control point are off by 1, this should do the trick
if (currentTrackTime < timingPoint.Time)
beatIndex--;
TimeUntilNextBeat = (timingPoint.Time - currentTrackTime) % timingPoint.BeatLength;
TimeUntilNextBeat = (timingPoint.Time - currentTrackTime) % beatLength;
if (TimeUntilNextBeat < 0)
TimeUntilNextBeat += timingPoint.BeatLength;
TimeUntilNextBeat += beatLength;
TimeSinceLastBeat = timingPoint.BeatLength - TimeUntilNextBeat;
TimeSinceLastBeat = beatLength - TimeUntilNextBeat;
if (timingPoint.Equals(lastTimingPoint) && beatIndex == lastBeat)
return;