Using IUpdatableByPlayfield

This commit is contained in:
Semyon Rozhkov 2021-11-10 03:53:30 +03:00
parent 64bc8da14c
commit ce0eb0b26f
1 changed files with 6 additions and 9 deletions

View File

@ -13,7 +13,7 @@
namespace osu.Game.Rulesets.Catch.Mods
{
public class CatchModNoScope : ModNoScope, IApplicableToBeatmap, IApplicableToDrawableRuleset<CatchHitObject>
public class CatchModNoScope : ModNoScope, IApplicableToBeatmap, IUpdatableByPlayfield
{
public override string Description => "Where's the catcher?";
@ -24,15 +24,12 @@ public void ApplyToBeatmap(IBeatmap beatmap)
BananaShowerPeriods = new PeriodTracker(beatmap.HitObjects.OfType<BananaShower>().Select(b => new Period(b.StartTime - TRANSITION_DURATION, b.EndTime)));
}
public void ApplyToDrawableRuleset(DrawableRuleset<CatchHitObject> 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));
}
}
}