mirror of https://github.com/ppy/osu
Remove legacy DrawableHitObject state management
This commit is contained in:
parent
c0b09ece64
commit
c06db5a54a
|
@ -221,18 +221,6 @@ private void addNested(DrawableHitObject hitObject)
|
|||
/// </summary>
|
||||
public event Action<DrawableHitObject, ArmedState> ApplyCustomUpdateState;
|
||||
|
||||
#pragma warning disable 618 // (legacy state management) - can be removed 20200227
|
||||
|
||||
/// <summary>
|
||||
/// Enables automatic transform management of this hitobject. Implementation of transforms should be done in <see cref="UpdateInitialTransforms"/> and <see cref="UpdateStateTransforms"/> only. Rewinding and removing previous states is done automatically.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Going forward, this is the preferred way of implementing <see cref="DrawableHitObject"/>s. Previous functionality
|
||||
/// is offered as a compatibility layer until all rulesets have been migrated across.
|
||||
/// </remarks>
|
||||
[Obsolete("Use UpdateInitialTransforms()/UpdateStateTransforms() instead")] // can be removed 20200227
|
||||
protected virtual bool UseTransformStateManagement => true;
|
||||
|
||||
protected override void ClearInternal(bool disposeChildren = true) => throw new InvalidOperationException($"Should never clear a {nameof(DrawableHitObject)}");
|
||||
|
||||
private void updateState(ArmedState newState, bool force = false)
|
||||
|
@ -240,35 +228,28 @@ private void updateState(ArmedState newState, bool force = false)
|
|||
if (State.Value == newState && !force)
|
||||
return;
|
||||
|
||||
if (UseTransformStateManagement)
|
||||
LifetimeEnd = double.MaxValue;
|
||||
|
||||
double transformTime = HitObject.StartTime - InitialLifetimeOffset;
|
||||
|
||||
base.ApplyTransformsAt(double.MinValue, true);
|
||||
base.ClearTransformsAfter(double.MinValue, true);
|
||||
|
||||
using (BeginAbsoluteSequence(transformTime, true))
|
||||
{
|
||||
LifetimeEnd = double.MaxValue;
|
||||
UpdateInitialTransforms();
|
||||
|
||||
double transformTime = HitObject.StartTime - InitialLifetimeOffset;
|
||||
var judgementOffset = Result?.TimeOffset ?? 0;
|
||||
|
||||
base.ApplyTransformsAt(double.MinValue, true);
|
||||
base.ClearTransformsAfter(double.MinValue, true);
|
||||
|
||||
using (BeginAbsoluteSequence(transformTime, true))
|
||||
using (BeginDelayedSequence(InitialLifetimeOffset + judgementOffset, true))
|
||||
{
|
||||
UpdateInitialTransforms();
|
||||
|
||||
var judgementOffset = Result?.TimeOffset ?? 0;
|
||||
|
||||
using (BeginDelayedSequence(InitialLifetimeOffset + judgementOffset, true))
|
||||
{
|
||||
UpdateStateTransforms(newState);
|
||||
state.Value = newState;
|
||||
}
|
||||
UpdateStateTransforms(newState);
|
||||
state.Value = newState;
|
||||
}
|
||||
|
||||
if (state.Value != ArmedState.Idle && LifetimeEnd == double.MaxValue || HitObject.HitWindows == null)
|
||||
Expire();
|
||||
}
|
||||
else
|
||||
state.Value = newState;
|
||||
|
||||
UpdateState(newState);
|
||||
if (state.Value != ArmedState.Idle && LifetimeEnd == double.MaxValue || HitObject.HitWindows == null)
|
||||
Expire();
|
||||
|
||||
// apply any custom state overrides
|
||||
ApplyCustomUpdateState?.Invoke(this, newState);
|
||||
|
@ -303,30 +284,14 @@ protected virtual void UpdateStateTransforms(ArmedState state)
|
|||
|
||||
public override void ClearTransformsAfter(double time, bool propagateChildren = false, string targetMember = null)
|
||||
{
|
||||
// When we are using automatic state management, parent calls to this should be blocked for safety.
|
||||
if (!UseTransformStateManagement)
|
||||
base.ClearTransformsAfter(time, propagateChildren, targetMember);
|
||||
// Parent calls to this should be blocked for safety, as we are manually handling this in updateState.
|
||||
}
|
||||
|
||||
public override void ApplyTransformsAt(double time, bool propagateChildren = false)
|
||||
{
|
||||
// When we are using automatic state management, parent calls to this should be blocked for safety.
|
||||
if (!UseTransformStateManagement)
|
||||
base.ApplyTransformsAt(time, propagateChildren);
|
||||
// Parent calls to this should be blocked for safety, as we are manually handling this in updateState.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Legacy method to handle state changes.
|
||||
/// Should generally not be used when <see cref="UseTransformStateManagement"/> is true; use <see cref="UpdateStateTransforms"/> instead.
|
||||
/// </summary>
|
||||
/// <param name="state">The new armed state.</param>
|
||||
[Obsolete("Use UpdateInitialTransforms()/UpdateStateTransforms() instead")] // can be removed 20200227
|
||||
protected virtual void UpdateState(ArmedState state)
|
||||
{
|
||||
}
|
||||
|
||||
#pragma warning restore 618
|
||||
|
||||
#endregion
|
||||
|
||||
protected sealed override void SkinChanged(ISkinSource skin, bool allowFallback)
|
||||
|
|
Loading…
Reference in New Issue