From ce0eb0b26ff5a3ab152f5e9e48f4f991293b990e Mon Sep 17 00:00:00 2001 From: Semyon Rozhkov Date: Wed, 10 Nov 2021 03:53:30 +0300 Subject: [PATCH] Using IUpdatableByPlayfield --- osu.Game.Rulesets.Catch/Mods/CatchModNoScope.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Mods/CatchModNoScope.cs b/osu.Game.Rulesets.Catch/Mods/CatchModNoScope.cs index 7b55150582..b0e374898e 100644 --- a/osu.Game.Rulesets.Catch/Mods/CatchModNoScope.cs +++ b/osu.Game.Rulesets.Catch/Mods/CatchModNoScope.cs @@ -13,7 +13,7 @@ using osu.Game.Utils; namespace osu.Game.Rulesets.Catch.Mods { - public class CatchModNoScope : ModNoScope, IApplicableToBeatmap, IApplicableToDrawableRuleset + public class CatchModNoScope : ModNoScope, IApplicableToBeatmap, IUpdatableByPlayfield { public override string Description => "Where's the catcher?"; @@ -24,15 +24,12 @@ namespace osu.Game.Rulesets.Catch.Mods BananaShowerPeriods = new PeriodTracker(beatmap.HitObjects.OfType().Select(b => new Period(b.StartTime - TRANSITION_DURATION, b.EndTime))); } - public void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset) + public virtual void Update(Playfield playfield) { - var playfield = (CatchPlayfield)drawableRuleset.Playfield; - playfield.OnUpdate += _ => - { - bool shouldAlwaysShowCatcher = IsBreakTime.Value || BananaShowerPeriods.IsInAny(playfield.Clock.CurrentTime); - float targetAlpha = shouldAlwaysShowCatcher ? 1 : ComboBasedAlpha; - playfield.CatcherArea.Alpha = (float)Interpolation.Lerp(playfield.CatcherArea.Alpha, targetAlpha, Math.Clamp(playfield.Time.Elapsed / TRANSITION_DURATION, 0, 1)); - }; + var catchPlayfield = (CatchPlayfield)playfield; + bool shouldAlwaysShowCatcher = IsBreakTime.Value || BananaShowerPeriods.IsInAny(catchPlayfield.Clock.CurrentTime); + float targetAlpha = shouldAlwaysShowCatcher ? 1 : ComboBasedAlpha; + catchPlayfield.CatcherArea.Alpha = (float)Interpolation.Lerp(catchPlayfield.CatcherArea.Alpha, targetAlpha, Math.Clamp(catchPlayfield.Time.Elapsed / TRANSITION_DURATION, 0, 1)); } } }