mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Move judgement result revert logic to Playfield
Previously, some judgement results were not reverted when the source DHO is not alive (e.g. frames skipped in editor). Now, all results are reverted in the exact reverse order.
This commit is contained in:
@ -82,6 +82,9 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
/// <summary>
|
||||
/// Invoked by this or a nested <see cref="DrawableHitObject"/> prior to a <see cref="JudgementResult"/> being reverted.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is only invoked if this <see cref="DrawableHitObject"/> is alive when the result is reverted.
|
||||
/// </remarks>
|
||||
public event Action<DrawableHitObject, JudgementResult> OnRevertResult;
|
||||
|
||||
/// <summary>
|
||||
@ -222,6 +225,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
|
||||
ensureEntryHasResult();
|
||||
|
||||
entry.RevertResult += onRevertResult;
|
||||
|
||||
foreach (var h in HitObject.NestedHitObjects)
|
||||
{
|
||||
var pooledDrawableNested = pooledObjectProvider?.GetPooledDrawableRepresentation(h, this);
|
||||
@ -234,7 +239,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
OnNestedDrawableCreated?.Invoke(drawableNested);
|
||||
|
||||
drawableNested.OnNewResult += onNewResult;
|
||||
drawableNested.OnRevertResult += onRevertResult;
|
||||
drawableNested.ApplyCustomUpdateState += onApplyCustomUpdateState;
|
||||
|
||||
// This is only necessary for non-pooled DHOs. For pooled DHOs, this is handled inside GetPooledDrawableRepresentation().
|
||||
@ -309,7 +313,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
foreach (var obj in nestedHitObjects)
|
||||
{
|
||||
obj.OnNewResult -= onNewResult;
|
||||
obj.OnRevertResult -= onRevertResult;
|
||||
obj.ApplyCustomUpdateState -= onApplyCustomUpdateState;
|
||||
}
|
||||
|
||||
@ -318,6 +321,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
|
||||
HitObject.DefaultsApplied -= onDefaultsApplied;
|
||||
|
||||
entry.RevertResult -= onRevertResult;
|
||||
|
||||
OnFree();
|
||||
|
||||
ParentHitObject = null;
|
||||
@ -366,7 +371,11 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
|
||||
private void onNewResult(DrawableHitObject drawableHitObject, JudgementResult result) => OnNewResult?.Invoke(drawableHitObject, result);
|
||||
|
||||
private void onRevertResult(DrawableHitObject drawableHitObject, JudgementResult result) => OnRevertResult?.Invoke(drawableHitObject, result);
|
||||
private void onRevertResult()
|
||||
{
|
||||
updateState(ArmedState.Idle);
|
||||
OnRevertResult?.Invoke(this, Result);
|
||||
}
|
||||
|
||||
private void onApplyCustomUpdateState(DrawableHitObject drawableHitObject, ArmedState state) => ApplyCustomUpdateState?.Invoke(drawableHitObject, state);
|
||||
|
||||
@ -578,26 +587,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
|
||||
#endregion
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (Result != null && Result.HasResult)
|
||||
{
|
||||
double endTime = HitObject.GetEndTime();
|
||||
|
||||
if (Result.TimeOffset + endTime > Time.Current)
|
||||
{
|
||||
OnRevertResult?.Invoke(this, Result);
|
||||
|
||||
Result.TimeOffset = 0;
|
||||
Result.Type = HitResult.None;
|
||||
|
||||
updateState(ArmedState.Idle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool UpdateSubTreeMasking(Drawable source, RectangleF maskingBounds) => false;
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
|
Reference in New Issue
Block a user