1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 12:45:09 +08:00

Add new method handling hit state specifically

Until now UpdateStateTransforms was applying results offsets to
StartTime. This didn't cover the case of a HitObject with duration,
where the call would be made with `StartTime + hitOffset` rather than
`EndTime + hitOffset`.

To resolve this, a new method has been added which should be used to
handle hit-specific state transforms.
This commit is contained in:
Dean Herbert 2020-11-04 16:04:15 +09:00
parent c4076cad4b
commit 7f30140b7e
2 changed files with 36 additions and 7 deletions

View File

@ -36,6 +36,12 @@ namespace osu.Game.Rulesets.Judgements
/// </summary>
public double TimeOffset { get; internal set; }
/// <summary>
/// The absolute time at which this <see cref="JudgementResult"/> occurred.
/// Equal to the (end) time of the <see cref="HitObject"/> + <see cref="TimeOffset"/>.
/// </summary>
public double TimeAbsolute => HitObject.GetEndTime() + TimeOffset;
/// <summary>
/// The combo prior to this <see cref="JudgementResult"/> occurring.
/// </summary>

View File

@ -255,18 +255,19 @@ 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))
UpdateStateTransforms(newState);
using (BeginDelayedSequence(InitialLifetimeOffset + judgementOffset, true))
{
UpdateStateTransforms(newState);
state.Value = newState;
}
if (newState != ArmedState.Idle)
{
using (BeginAbsoluteSequence(HitStateUpdateTime, true))
UpdateHitStateTransforms(newState);
}
state.Value = newState;
if (LifetimeEnd == double.MaxValue && (state.Value != ArmedState.Idle || HitObject.HitWindows == null))
Expire();
@ -301,6 +302,16 @@ namespace osu.Game.Rulesets.Objects.Drawables
{
}
/// <summary>
/// Apply transforms based on the current <see cref="ArmedState"/>. This call is offset by <see cref="HitStateUpdateTime"/> (HitObject.EndTime + Result.Offset), equivalent to when the user hit the object.
/// This method is only called on <see cref="ArmedState.Hit"/> or <see cref="ArmedState.Miss"/>.
/// Previous states are automatically cleared.
/// </summary>
/// <param name="state">The new armed state.</param>
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 +465,18 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// </remarks>
protected virtual double InitialLifetimeOffset => 10000;
/// <summary>
/// The time at which state transforms should be applied that line up to <see cref="HitObject"/>'s StartTime.
/// This is used to offset calls to <see cref="UpdateStateTransforms"/>.
/// </summary>
public double StateUpdateTime => HitObject.StartTime;
/// <summary>
/// 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 <see cref="UpdateHitStateTransforms"/>.
/// </summary>
public double HitStateUpdateTime => Result?.TimeAbsolute ?? HitObject.GetEndTime();
/// <summary>
/// Will be called at least once after this <see cref="DrawableHitObject"/> has become not alive.
/// </summary>