Move low pass fail effect to FailAnimation

This commit is contained in:
Dean Herbert 2021-10-08 12:27:04 +09:00
parent a924b982eb
commit 436ead421a
2 changed files with 9 additions and 7 deletions

View File

@ -10,7 +10,9 @@ using osu.Framework.Allocation;
using osu.Framework.Audio.Sample;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Utils;
using osu.Game.Audio.Effects;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects.Drawables;
using osuTK;
@ -22,7 +24,7 @@ namespace osu.Game.Screens.Play
/// Manage the animation to be applied when a player fails.
/// Single file; automatically disposed after use.
/// </summary>
public class FailAnimation : Component
public class FailAnimation : CompositeDrawable
{
public Action OnComplete;
@ -32,6 +34,8 @@ namespace osu.Game.Screens.Play
private Track track;
private AudioFilter failLowPassFilter;
private const float duration = 2500;
private Sample failSample;
@ -46,6 +50,8 @@ namespace osu.Game.Screens.Play
{
track = beatmap.Value.Track;
failSample = audio.Samples.Get(@"Gameplay/failsound");
AddInternal(failLowPassFilter = new AudioFilter(audio.TrackMixer));
}
private bool started;
@ -68,6 +74,8 @@ namespace osu.Game.Screens.Play
Expire();
});
failLowPassFilter.CutoffTo(300, duration, Easing.OutCubic);
track.AddAdjustment(AdjustableProperty.Frequency, trackFreq);
applyToPlayfield(drawableRuleset.Playfield);

View File

@ -15,7 +15,6 @@ using osu.Framework.Input.Events;
using osu.Framework.Logging;
using osu.Framework.Screens;
using osu.Framework.Threading;
using osu.Game.Audio.Effects;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics.Containers;
@ -215,7 +214,6 @@ namespace osu.Game.Screens.Play
InternalChild = GameplayClockContainer = CreateGameplayClockContainer(Beatmap.Value, DrawableRuleset.GameplayStartTime);
AddInternal(screenSuspension = new ScreenSuspensionHandler(GameplayClockContainer));
AddInternal(failLowPassFilter = new AudioFilter(audio.TrackMixer));
Score = CreateScore(playableBeatmap);
@ -770,8 +768,6 @@ namespace osu.Game.Screens.Play
private FailAnimation failAnimation;
private AudioFilter failLowPassFilter;
private bool onFail()
{
if (!CheckModsAllowFailure())
@ -786,7 +782,6 @@ namespace osu.Game.Screens.Play
if (PauseOverlay.State.Value == Visibility.Visible)
PauseOverlay.Hide();
failLowPassFilter.CutoffTo(300, 2500, Easing.OutCubic);
failAnimation.Start();
if (GameplayState.Mods.OfType<IApplicableFailOverride>().Any(m => m.RestartOnFail))
@ -799,7 +794,6 @@ namespace osu.Game.Screens.Play
private void onFailComplete()
{
GameplayClockContainer.Stop();
failLowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF);
FailOverlay.Retries = RestartCount;
FailOverlay.Show();