1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 04:02:59 +08:00

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;

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Audio;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps.Timing;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Rulesets.Objects;
@ -59,6 +60,11 @@ namespace osu.Game.Rulesets.Mods
private int? firstBeat;
public NightcoreBeatContainer()
{
Divisor = 2;
}
[BackgroundDependencyLoader]
private void load()
{
@ -71,10 +77,15 @@ namespace osu.Game.Rulesets.Mods
};
}
private const int segment_bar_length = 4;
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes)
{
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
int beatsPerBar = (int)timingPoint.TimeSignature;
int segmentLength = beatsPerBar * Divisor * segment_bar_length;
if (!IsBeatSyncedWithTrack)
{
firstBeat = null;
@ -82,25 +93,49 @@ namespace osu.Game.Rulesets.Mods
}
if (!firstBeat.HasValue || beatIndex < firstBeat)
firstBeat = Math.Max(0, (beatIndex / 16 + 1) * 16);
firstBeat = Math.Max(0, (beatIndex / segmentLength + 1) * segmentLength);
if (beatIndex >= firstBeat)
{
if (beatIndex % 16 == 0 && (beatIndex > firstBeat || !effectPoint.OmitFirstBarLine))
if (beatIndex % segmentLength == 0 && (beatIndex > firstBeat || !effectPoint.OmitFirstBarLine))
finishSample?.Play();
switch (beatIndex % (int)timingPoint.TimeSignature)
switch (timingPoint.TimeSignature)
{
case 0:
kickSample?.Play();
case TimeSignatures.SimpleTriple:
switch (beatIndex % 6)
{
case 0:
kickSample?.Play();
break;
case 3:
clapSample?.Play();
break;
default:
hatSample?.Play();
break;
}
break;
case 2:
clapSample?.Play();
break;
case TimeSignatures.SimpleQuadruple:
switch (beatIndex % 4)
{
case 0:
kickSample?.Play();
break;
case 2:
clapSample?.Play();
break;
default:
hatSample?.Play();
break;
}
default:
hatSample?.Play();
break;
}
}