Skip to content

Commit

Permalink
Cancel fail sound when exiting Gameplay
Browse files Browse the repository at this point in the history
  • Loading branch information
flustix committed Dec 2, 2023
1 parent f65defc commit 1952055
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion fluXis.Game/Screens/Gameplay/GameplaySamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using osu.Framework.Allocation;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Utils;

Expand All @@ -17,6 +18,8 @@ public partial class GameplaySamples : Component
private Sample[] missSamples;
private Sample failSample;

private SampleChannel failChannel;

[BackgroundDependencyLoader]
private void load(SkinManager skins, FluXisConfig config)
{
Expand All @@ -38,5 +41,17 @@ protected override void LoadComplete()
public void Hit() => HitSample?.Play();
public void Restart() => restartSample?.Play();
public void Miss() => missSamples?[RNG.Next(0, missSamples.Length)]?.Play();
public void Fail() => failSample?.Play();

public void Fail() => failChannel = failSample?.Play();
public void CancelFail() => failChannel?.Stop();

protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);

HitSample?.Dispose();
restartSample?.Dispose();
failSample?.Dispose();
missSamples?.ForEach(s => s?.Dispose());
}
}
1 change: 1 addition & 0 deletions fluXis.Game/Screens/Gameplay/GameplayScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ public override bool OnExiting(ScreenExitEvent e)
AudioClock.LowPassFilter.CutoffTo(LowPassFilter.MAX, 500);
ScheduleAfterChildren(() => AudioClock.RateTo(Rate, 500, Easing.InQuint));
backgrounds.StopVideo();
Samples.CancelFail();

return base.OnExiting(e);
}
Expand Down

0 comments on commit 1952055

Please sign in to comment.