From 72c18fbdfe8f91798a1adf16ca1f92ecbc593ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 15 Mar 2021 20:48:19 +0100 Subject: [PATCH] Restructure explosion animation to avoid resetting transforms on free --- osu.Game.Rulesets.Taiko/UI/HitExplosion.cs | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/UI/HitExplosion.cs b/osu.Game.Rulesets.Taiko/UI/HitExplosion.cs index bdebe9da17..8f5e9e54ab 100644 --- a/osu.Game.Rulesets.Taiko/UI/HitExplosion.cs +++ b/osu.Game.Rulesets.Taiko/UI/HitExplosion.cs @@ -25,6 +25,8 @@ internal class HitExplosion : PoolableDrawable private readonly HitResult result; + private double? secondHitTime; + [CanBeNull] public DrawableHitObject JudgedObject; @@ -61,6 +63,7 @@ private void load() public void Apply([CanBeNull] DrawableHitObject drawableHitObject) { JudgedObject = drawableHitObject; + secondHitTime = null; } protected override void PrepareForUse() @@ -69,16 +72,6 @@ protected override void PrepareForUse() runAnimation(); } - protected override void FreeAfterUse() - { - base.FreeAfterUse(); - - // clean up transforms on free instead of on prepare as is usually the case - // to avoid potentially overriding the effects of VisualiseSecondHit() in the case it is called before PrepareForUse(). - ApplyTransformsAt(double.MinValue, true); - ClearTransforms(true); - } - private void runAnimation() { if (JudgedObject?.Result == null) @@ -88,9 +81,21 @@ private void runAnimation() LifetimeStart = resultTime; + ApplyTransformsAt(double.MinValue, true); + ClearTransforms(true); + using (BeginAbsoluteSequence(resultTime)) (skinnable.Drawable as IAnimatableHitExplosion)?.Animate(JudgedObject); + if (secondHitTime != null) + { + using (BeginAbsoluteSequence(secondHitTime.Value)) + { + this.ResizeTo(new Vector2(TaikoStrongableHitObject.DEFAULT_STRONG_SIZE), 50); + (skinnable.Drawable as IAnimatableHitExplosion)?.AnimateSecondHit(); + } + } + LifetimeEnd = skinnable.Drawable.LatestTransformEndTime; } @@ -113,11 +118,8 @@ private static TaikoSkinComponents getComponentName(HitResult result) public void VisualiseSecondHit(JudgementResult judgementResult) { - using (BeginAbsoluteSequence(judgementResult.TimeAbsolute)) - { - this.ResizeTo(new Vector2(TaikoStrongableHitObject.DEFAULT_STRONG_SIZE), 50); - (skinnable.Drawable as IAnimatableHitExplosion)?.AnimateSecondHit(); - } + secondHitTime = judgementResult.TimeAbsolute; + runAnimation(); } } }