From 5bab53b04ce53325aab9991f2b811034580ef957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 10 May 2020 17:05:30 +0200 Subject: [PATCH] Centralise trail visibility state management --- osu.Game.Rulesets.Catch/UI/Catcher.cs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/osu.Game.Rulesets.Catch/UI/Catcher.cs b/osu.Game.Rulesets.Catch/UI/Catcher.cs index 558555af96..9cce46d730 100644 --- a/osu.Game.Rulesets.Catch/UI/Catcher.cs +++ b/osu.Game.Rulesets.Catch/UI/Catcher.cs @@ -74,7 +74,7 @@ protected set dashing = value; - trails.DisplayTrail = value || HyperDashing; + updateTrailVisibility(); } } @@ -255,10 +255,7 @@ public void SetHyperDashState(double modifier = 1, float targetPosition = -1) hyperDashDirection = 0; if (wasHyperDashing) - { - updateCatcherColour(false); - trails.DisplayTrail &= Dashing; - } + runHyperDashStateTransition(false); } else { @@ -268,16 +265,18 @@ public void SetHyperDashState(double modifier = 1, float targetPosition = -1) if (!wasHyperDashing) { - updateCatcherColour(true); - - trails.DisplayTrail = true; trails.DisplayEndGlow(); + runHyperDashStateTransition(true); } } } - private void updateCatcherColour(bool hyperDashing) + private void runHyperDashStateTransition(bool hyperDashing) { + trails.HyperDashTrailsColour = hyperDashColour; + trails.EndGlowSpritesColour = hyperDashEndGlowColour; + updateTrailVisibility(); + if (hyperDashing) { this.FadeColour(hyperDashColour, HYPER_DASH_TRANSITION_DURATION, Easing.OutQuint); @@ -288,11 +287,10 @@ private void updateCatcherColour(bool hyperDashing) this.FadeColour(Color4.White, HYPER_DASH_TRANSITION_DURATION, Easing.OutQuint); this.FadeTo(1f, HYPER_DASH_TRANSITION_DURATION, Easing.OutQuint); } - - trails.HyperDashTrailsColour = hyperDashColour; - trails.EndGlowSpritesColour = hyperDashEndGlowColour; } + private void updateTrailVisibility() => trails.DisplayTrail = Dashing || HyperDashing; + public bool OnPressed(CatchAction action) { switch (action) @@ -393,7 +391,7 @@ protected override void SkinChanged(ISkinSource skin, bool allowFallback) skin.GetConfig(CatchSkinColour.HyperDashAfterImage)?.Value ?? hyperDashColour; - updateCatcherColour(HyperDashing); + runHyperDashStateTransition(HyperDashing); } protected override void Update()