From 38f2a27f537e12d9deef306e327715983afecb33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 22 Nov 2022 20:34:43 +0100 Subject: [PATCH] Split animation logic to its own method Also add a guard, to bypass all of it if the foreground layer is not in fact animatable. --- .../Skinning/Legacy/LegacyCirclePiece.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyCirclePiece.cs b/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyCirclePiece.cs index 2a260b8cb3..c8dc29f444 100644 --- a/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyCirclePiece.cs +++ b/osu.Game.Rulesets.Taiko/Skinning/Legacy/LegacyCirclePiece.cs @@ -26,7 +26,6 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy private Bindable currentCombo { get; } = new BindableInt(); private int animationFrame; - private int multiplier; private double beatLength; // required for editor blueprints (not sure why these circle pieces are zero size). @@ -94,6 +93,14 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy foreach (var c in InternalChildren) c.Scale = new Vector2(DrawHeight / 128); + if (foregroundLayer is IFramedAnimation animatableForegroundLayer) + animateForegroundLayer(animatableForegroundLayer); + } + + private void animateForegroundLayer(IFramedAnimation animatableForegroundLayer) + { + int multiplier; + if (currentCombo.Value >= 150) { multiplier = 2; @@ -104,7 +111,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy } else { - (foregroundLayer as IFramedAnimation)?.GotoFrame(0); + animatableForegroundLayer.GotoFrame(0); return; } @@ -114,7 +121,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy animationFrame = Time.Current % ((beatLength * 2) / multiplier) >= beatLength / multiplier ? 0 : 1; - (foregroundLayer as IFramedAnimation)?.GotoFrame(animationFrame); + animatableForegroundLayer.GotoFrame(animationFrame); } }