diff --git a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs index ac1f11e09f..7922510a49 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs @@ -6,9 +6,8 @@ using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Rulesets.Objects; -using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Catch.UI; +using osu.Game.Rulesets.Objects.Drawables; using osuTK; using osuTK.Graphics; @@ -90,22 +89,17 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables ApplyResult(r => r.Type = CheckPosition.Invoke(HitObject) ? r.Judgement.MaxResult : r.Judgement.MinResult); } - protected override void UpdateStateTransforms(ArmedState state) + protected override void UpdateHitStateTransforms(ArmedState state) { - var endTime = HitObject.GetEndTime(); - - using (BeginAbsoluteSequence(endTime, true)) + switch (state) { - switch (state) - { - case ArmedState.Miss: - this.FadeOut(250).RotateTo(Rotation * 2, 250, Easing.Out); - break; + case ArmedState.Miss: + this.FadeOut(250).RotateTo(Rotation * 2, 250, Easing.Out); + break; - case ArmedState.Hit: - this.FadeOut(); - break; - } + case ArmedState.Hit: + this.FadeOut(); + break; } } } diff --git a/osu.Game.Rulesets.Mania/Edit/ManiaBeatSnapGrid.cs b/osu.Game.Rulesets.Mania/Edit/ManiaBeatSnapGrid.cs index 2028cae9a5..afc08dcc96 100644 --- a/osu.Game.Rulesets.Mania/Edit/ManiaBeatSnapGrid.cs +++ b/osu.Game.Rulesets.Mania/Edit/ManiaBeatSnapGrid.cs @@ -204,10 +204,6 @@ namespace osu.Game.Rulesets.Mania.Edit protected override void UpdateInitialTransforms() { // don't perform any fading – we are handling that ourselves. - } - - protected override void UpdateStateTransforms(ArmedState state) - { LifetimeEnd = HitObject.StartTime + visible_range; } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs index 08b5b75f9c..074cbf6bd6 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableBarLine.cs @@ -1,10 +1,9 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osuTK; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; -using osu.Game.Rulesets.Objects.Drawables; +using osuTK; using osuTK.Graphics; namespace osu.Game.Rulesets.Mania.Objects.Drawables @@ -71,6 +70,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { } - protected override void UpdateStateTransforms(ArmedState state) => this.FadeOut(150); + protected override void UpdateStartTimeStateTransforms() => this.FadeOut(150); } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index f6d539c91b..d9d740c145 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -229,12 +229,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables } } - protected override void UpdateStateTransforms(ArmedState state) - { - using (BeginDelayedSequence(HitObject.Duration, true)) - base.UpdateStateTransforms(state); - } - protected override void CheckForResult(bool userTriggered, double timeOffset) { if (Tail.AllJudged) diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteHead.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteHead.cs index cd56b81e10..75dcf0e55e 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteHead.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteHead.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Game.Rulesets.Objects.Drawables; - namespace osu.Game.Rulesets.Mania.Objects.Drawables { /// @@ -19,8 +17,10 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables public void UpdateResult() => base.UpdateResult(true); - protected override void UpdateStateTransforms(ArmedState state) + protected override void UpdateInitialTransforms() { + base.UpdateInitialTransforms(); + // This hitobject should never expire, so this is just a safe maximum. LifetimeEnd = LifetimeStart + 30000; } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs index 27960b3f3a..1550faee50 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableManiaHitObject.cs @@ -118,7 +118,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables Anchor = Origin = e.NewValue == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre; } - protected override void UpdateStateTransforms(ArmedState state) + protected override void UpdateHitStateTransforms(ArmedState state) { switch (state) { diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index 0c26e2b52f..b0c4e3758d 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -151,19 +151,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables ApproachCircle.Expire(true); } - protected override void UpdateStateTransforms(ArmedState state) + protected override void UpdateHitStateTransforms(ArmedState state) { - base.UpdateStateTransforms(state); - Debug.Assert(HitObject.HitWindows != null); switch (state) { case ArmedState.Idle: this.Delay(HitObject.TimePreempt).FadeOut(500); - - Expire(true); - HitArea.HitAction = null; break; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs index c83bdf17d5..208f79f165 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs @@ -69,17 +69,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables protected virtual void Shake(double maximumLength) => shakeContainer.Shake(maximumLength); - protected override void UpdateStateTransforms(ArmedState state) + protected override void UpdateInitialTransforms() { - base.UpdateStateTransforms(state); + base.UpdateInitialTransforms(); - switch (state) - { - case ArmedState.Idle: - // Manually set to reduce the number of future alive objects to a bare minimum. - LifetimeStart = HitObject.StartTime - HitObject.TimePreempt; - break; - } + // Manually set to reduce the number of future alive objects to a bare minimum. + LifetimeStart = HitObject.StartTime - HitObject.TimePreempt; } /// diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs index 8008d87c6d..d8dd0d7471 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs @@ -245,29 +245,31 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables base.PlaySamples(); } - protected override void UpdateStateTransforms(ArmedState state) + protected override void UpdateStartTimeStateTransforms() { - base.UpdateStateTransforms(state); + base.UpdateStartTimeStateTransforms(); Ball.FadeIn(); Ball.ScaleTo(HitObject.Scale); + } - using (BeginDelayedSequence(HitObject.Duration, true)) + protected override void UpdateHitStateTransforms(ArmedState state) + { + base.UpdateHitStateTransforms(state); + + const float fade_out_time = 450; + + // intentionally pile on an extra FadeOut to make it happen much faster. + Ball.FadeOut(fade_out_time / 4, Easing.Out); + + switch (state) { - const float fade_out_time = 450; - - // intentionally pile on an extra FadeOut to make it happen much faster. - Ball.FadeOut(fade_out_time / 4, Easing.Out); - - switch (state) - { - case ArmedState.Hit: - Ball.ScaleTo(HitObject.Scale * 1.4f, fade_out_time, Easing.Out); - break; - } - - this.FadeOut(fade_out_time, Easing.OutQuint); + case ArmedState.Hit: + Ball.ScaleTo(HitObject.Scale * 1.4f, fade_out_time, Easing.Out); + break; } + + this.FadeOut(fade_out_time, Easing.OutQuint); } public Drawable ProxiedLayer => HeadCircle.ProxiedLayer; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderRepeat.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderRepeat.cs index b57bb8dbbf..9c382bd0a7 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderRepeat.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderRepeat.cs @@ -72,9 +72,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables ); } - protected override void UpdateStateTransforms(ArmedState state) + protected override void UpdateHitStateTransforms(ArmedState state) { - base.UpdateStateTransforms(state); + base.UpdateHitStateTransforms(state); switch (state) { diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs index 7e30f4e132..3be5983c57 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs @@ -62,9 +62,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables circlePiece.FadeInFromZero(HitObject.TimeFadeIn); } - protected override void UpdateStateTransforms(ArmedState state) + protected override void UpdateHitStateTransforms(ArmedState state) { - base.UpdateStateTransforms(state); + base.UpdateHitStateTransforms(state); Debug.Assert(HitObject.HitWindows != null); @@ -72,8 +72,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { case ArmedState.Idle: this.Delay(HitObject.TimePreempt).FadeOut(500); - - Expire(true); break; case ArmedState.Miss: diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs index 81d12f3432..2af51ea486 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs @@ -69,9 +69,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables this.ScaleTo(0.5f).ScaleTo(1f, ANIM_DURATION * 4, Easing.OutElasticHalf); } - protected override void UpdateStateTransforms(ArmedState state) + protected override void UpdateHitStateTransforms(ArmedState state) { - base.UpdateStateTransforms(state); + base.UpdateHitStateTransforms(state); switch (state) { diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs index 8dd63018e2..77fbff9c51 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs @@ -141,12 +141,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables } } - protected override void UpdateStateTransforms(ArmedState state) + protected override void UpdateHitStateTransforms(ArmedState state) { - base.UpdateStateTransforms(state); + base.UpdateHitStateTransforms(state); - using (BeginDelayedSequence(HitObject.Duration, true)) - this.FadeOut(160); + this.FadeOut(160); // skin change does a rewind of transforms, which will stop the spinning sound from playing if it's currently in playback. isSpinning?.TriggerChange(); diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs index 1e08e921a6..aadcc420df 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableBarLine.cs @@ -58,6 +58,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables }); } - protected override void UpdateStateTransforms(ArmedState state) => this.FadeOut(150); + protected override void UpdateHitStateTransforms(ArmedState state) => this.FadeOut(150); } } diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs index 8f268dc1c7..c596fa2c7c 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRoll.cs @@ -135,13 +135,13 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables ApplyResult(r => r.Type = r.Judgement.MinResult); } - protected override void UpdateStateTransforms(ArmedState state) + protected override void UpdateHitStateTransforms(ArmedState state) { switch (state) { case ArmedState.Hit: case ArmedState.Miss: - this.Delay(HitObject.Duration).FadeOut(100); + this.FadeOut(100); break; } } diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs index 9d7dcc7218..bf44a80037 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableDrumRollTick.cs @@ -43,7 +43,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables ApplyResult(r => r.Type = r.Judgement.MaxResult); } - protected override void UpdateStateTransforms(ArmedState state) + protected override void UpdateHitStateTransforms(ArmedState state) { switch (state) { diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs index bb42240f25..4a3759794b 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs @@ -193,7 +193,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables pressHandledThisFrame = false; } - protected override void UpdateStateTransforms(ArmedState state) + protected override void UpdateHitStateTransforms(ArmedState state) { Debug.Assert(HitObject.HitWindows != null); diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs index 8ee4a5db71..ff0a27023d 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableSwell.cs @@ -215,15 +215,15 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables } } - protected override void UpdateInitialTransforms() + protected override void UpdateStartTimeStateTransforms() { - base.UpdateInitialTransforms(); + base.UpdateStartTimeStateTransforms(); - using (BeginAbsoluteSequence(HitObject.StartTime - ring_appear_offset, true)) + using (BeginDelayedSequence(-ring_appear_offset, true)) targetRing.ScaleTo(target_ring_scale, 400, Easing.OutQuint); } - protected override void UpdateStateTransforms(ArmedState state) + protected override void UpdateHitStateTransforms(ArmedState state) { const double transition_duration = 300; @@ -235,12 +235,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables case ArmedState.Miss: case ArmedState.Hit: - using (BeginDelayedSequence(HitObject.Duration, true)) - { - this.FadeOut(transition_duration, Easing.Out); - bodyContainer.ScaleTo(1.4f, transition_duration); - } - + this.FadeOut(transition_duration, Easing.Out); + bodyContainer.ScaleTo(1.4f, transition_duration); break; } } diff --git a/osu.Game/Rulesets/Judgements/JudgementResult.cs b/osu.Game/Rulesets/Judgements/JudgementResult.cs index 3a35fd4433..e3b2501cdc 100644 --- a/osu.Game/Rulesets/Judgements/JudgementResult.cs +++ b/osu.Game/Rulesets/Judgements/JudgementResult.cs @@ -36,6 +36,12 @@ namespace osu.Game.Rulesets.Judgements /// public double TimeOffset { get; internal set; } + /// + /// The absolute time at which this occurred. + /// Equal to the (end) time of the + . + /// + public double TimeAbsolute => HitObject.GetEndTime() + TimeOffset; + /// /// The combo prior to this occurring. /// diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index cd31e468af..c7e2e0638c 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -255,17 +255,20 @@ namespace osu.Game.Rulesets.Objects.Drawables base.ClearTransformsAfter(double.MinValue, true); using (BeginAbsoluteSequence(transformTime, true)) - { UpdateInitialTransforms(); - var judgementOffset = Result?.TimeOffset ?? 0; + using (BeginAbsoluteSequence(StateUpdateTime, true)) + UpdateStartTimeStateTransforms(); - using (BeginDelayedSequence(InitialLifetimeOffset + judgementOffset, true)) - { - UpdateStateTransforms(newState); - state.Value = newState; - } - } +#pragma warning disable 618 + using (BeginAbsoluteSequence(StateUpdateTime + (Result?.TimeOffset ?? 0), true)) + UpdateStateTransforms(newState); +#pragma warning restore 618 + + using (BeginAbsoluteSequence(HitStateUpdateTime, true)) + UpdateHitStateTransforms(newState); + + state.Value = newState; if (LifetimeEnd == double.MaxValue && (state.Value != ArmedState.Idle || HitObject.HitWindows == null)) Expire(); @@ -297,10 +300,30 @@ namespace osu.Game.Rulesets.Objects.Drawables /// In the case of a non-idle , and if was not set during this call, will be invoked. /// /// The new armed state. + [Obsolete("Use UpdateStartTimeStateTransforms and UpdateHitStateTransforms instead")] // Can be removed 20210504 protected virtual void UpdateStateTransforms(ArmedState state) { } + /// + /// Apply passive transforms at the 's StartTime. + /// This is called each time changes. + /// Previous states are automatically cleared. + /// + protected virtual void UpdateStartTimeStateTransforms() + { + } + + /// + /// Apply transforms based on the current . This call is offset by (HitObject.EndTime + Result.Offset), equivalent to when the user hit the object. + /// If was not set during this call, will be invoked. + /// Previous states are automatically cleared. + /// + /// The new armed state. + protected virtual void UpdateHitStateTransforms(ArmedState state) + { + } + public override void ClearTransformsAfter(double time, bool propagateChildren = false, string targetMember = null) { // Parent calls to this should be blocked for safety, as we are manually handling this in updateState. @@ -454,6 +477,18 @@ namespace osu.Game.Rulesets.Objects.Drawables /// protected virtual double InitialLifetimeOffset => 10000; + /// + /// The time at which state transforms should be applied that line up to 's StartTime. + /// This is used to offset calls to . + /// + public double StateUpdateTime => HitObject.StartTime; + + /// + /// The time at which judgement dependent state transforms should be applied. This is equivalent of the (end) time of the object, in addition to any judgement offset. + /// This is used to offset calls to . + /// + public double HitStateUpdateTime => Result?.TimeAbsolute ?? HitObject.GetEndTime(); + /// /// Will be called at least once after this has become not alive. ///