From cd4643593fdaeb87d3618c6930b4acd4dfb9172f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 16 Feb 2020 11:58:41 +0900 Subject: [PATCH] Fix transform mod not being applied correctly --- osu.Game.Rulesets.Osu/Mods/OsuModTransform.cs | 42 ++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModTransform.cs b/osu.Game.Rulesets.Osu/Mods/OsuModTransform.cs index cc664ae72e..e14c024fd0 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModTransform.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModTransform.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects; +using osu.Game.Rulesets.Osu.Objects.Drawables; using osuTK; namespace osu.Game.Rulesets.Osu.Mods @@ -27,26 +28,39 @@ namespace osu.Game.Rulesets.Osu.Mods public void ApplyToDrawableHitObjects(IEnumerable drawables) { foreach (var drawable in drawables) + drawable.ApplyCustomUpdateState += applyTransform; + } + + private void applyTransform(DrawableHitObject drawable, ArmedState state) + { + switch (drawable) { - var hitObject = (OsuHitObject)drawable.HitObject; + case DrawableSliderHead _: + case DrawableSliderTail _: + case DrawableSliderTick _: + return; - float appearDistance = (float)(hitObject.TimePreempt - hitObject.TimeFadeIn) / 2; + default: + var hitObject = (OsuHitObject)drawable.HitObject; - Vector2 originalPosition = drawable.Position; - Vector2 appearOffset = new Vector2(MathF.Cos(theta), MathF.Sin(theta)) * appearDistance; + float appearDistance = (float)(hitObject.TimePreempt - hitObject.TimeFadeIn) / 2; - //the - 1 and + 1 prevents the hit objects to appear in the wrong position. - double appearTime = hitObject.StartTime - hitObject.TimePreempt - 1; - double moveDuration = hitObject.TimePreempt + 1; + Vector2 originalPosition = drawable.Position; + Vector2 appearOffset = new Vector2(MathF.Cos(theta), MathF.Sin(theta)) * appearDistance; - using (drawable.BeginAbsoluteSequence(appearTime, true)) - { - drawable - .MoveToOffset(appearOffset) - .MoveTo(originalPosition, moveDuration, Easing.InOutSine); - } + //the - 1 and + 1 prevents the hit objects to appear in the wrong position. + double appearTime = hitObject.StartTime - hitObject.TimePreempt - 1; + double moveDuration = hitObject.TimePreempt + 1; - theta += (float)hitObject.TimeFadeIn / 1000; + using (drawable.BeginAbsoluteSequence(appearTime, true)) + { + drawable + .MoveToOffset(appearOffset) + .MoveTo(originalPosition, moveDuration, Easing.InOutSine); + } + + theta += (float)hitObject.TimeFadeIn / 1000; + break; } } }