Skip to content

Commit

Permalink
Fix "nightcore" mod playing hat samples when it historically didn't
Browse files Browse the repository at this point in the history
Addresses ppy#29671.
  • Loading branch information
peppy committed Sep 30, 2024
1 parent 7d756d0 commit 1c2689d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions osu.Game/Rulesets/Mods/ModNightcore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,26 @@ public abstract partial class ModNightcore<TObject> : ModNightcore, IApplicableT
{
public void ApplyToDrawableRuleset(DrawableRuleset<TObject> drawableRuleset)
{
drawableRuleset.Overlays.Add(new NightcoreBeatContainer());
// (in a perfect world) tick rates other than 2 imply there isn't a regular offbeat, so offbeat hats would stand out.
// only enable them if tick rate is a multiple of 2.
bool playHats = drawableRuleset.Beatmap.Difficulty.SliderTickRate == 2;

drawableRuleset.Overlays.Add(new NightcoreBeatContainer(playHats));
}

public partial class NightcoreBeatContainer : BeatSyncedContainer
{
private readonly bool playHats;
private PausableSkinnableSound? hatSample;
private PausableSkinnableSound? clapSample;
private PausableSkinnableSound? kickSample;
private PausableSkinnableSound? finishSample;

private int? firstBeat;

public NightcoreBeatContainer()
public NightcoreBeatContainer(bool playHats = true)
{
this.playHats = playHats;
Divisor = 2;
}

Expand Down Expand Up @@ -141,7 +147,8 @@ private void playBeatFor(int beatIndex, TimeSignature signature)
break;

default:
hatSample?.Play();
if (playHats)
hatSample?.Play();
break;
}

Expand All @@ -159,7 +166,8 @@ private void playBeatFor(int beatIndex, TimeSignature signature)
break;

default:
hatSample?.Play();
if (playHats)
hatSample?.Play();
break;
}

Expand Down

0 comments on commit 1c2689d

Please sign in to comment.