1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 15:33:21 +08:00

Fix nested hitobjects not updating

This commit is contained in:
smoogipoo 2019-10-18 13:18:41 +09:00
parent b047e05d86
commit 9a896d52bf
2 changed files with 23 additions and 2 deletions

View File

@ -77,6 +77,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// </summary> /// </summary>
public JudgementResult Result { get; private set; } public JudgementResult Result { get; private set; }
private Bindable<double> startTimeBindable;
private Bindable<int> comboIndexBindable; private Bindable<int> comboIndexBindable;
public override bool RemoveWhenNotAlive => false; public override bool RemoveWhenNotAlive => false;
@ -126,7 +127,10 @@ namespace osu.Game.Rulesets.Objects.Drawables
{ {
base.LoadComplete(); base.LoadComplete();
Apply(HitObject); HitObject.DefaultsApplied += onDefaultsApplied;
startTimeBindable = HitObject.StartTimeBindable.GetBoundCopy();
startTimeBindable.BindValueChanged(_ => updateState(ArmedState.Idle, true));
if (HitObject is IHasComboInformation combo) if (HitObject is IHasComboInformation combo)
{ {
@ -135,9 +139,12 @@ namespace osu.Game.Rulesets.Objects.Drawables
} }
updateState(ArmedState.Idle, true); updateState(ArmedState.Idle, true);
onDefaultsApplied();
} }
protected void Apply(HitObject hitObject) private void onDefaultsApplied() => apply(HitObject);
private void apply(HitObject hitObject)
{ {
#pragma warning disable 618 // can be removed 20200417 #pragma warning disable 618 // can be removed 20200417
if (GetType().GetMethod(nameof(AddNested), BindingFlags.NonPublic | BindingFlags.Instance)?.DeclaringType != typeof(DrawableHitObject)) if (GetType().GetMethod(nameof(AddNested), BindingFlags.NonPublic | BindingFlags.Instance)?.DeclaringType != typeof(DrawableHitObject))
@ -493,6 +500,12 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// </summary> /// </summary>
/// <param name="judgement">The <see cref="Judgement"/> that provides the scoring information.</param> /// <param name="judgement">The <see cref="Judgement"/> that provides the scoring information.</param>
protected virtual JudgementResult CreateResult(Judgement judgement) => new JudgementResult(HitObject, judgement); protected virtual JudgementResult CreateResult(Judgement judgement) => new JudgementResult(HitObject, judgement);
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
HitObject.DefaultsApplied -= onDefaultsApplied;
}
} }
public abstract class DrawableHitObject<TObject> : DrawableHitObject public abstract class DrawableHitObject<TObject> : DrawableHitObject

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
@ -28,6 +29,11 @@ namespace osu.Game.Rulesets.Objects
/// </summary> /// </summary>
private const double control_point_leniency = 1; private const double control_point_leniency = 1;
/// <summary>
/// Invoked after <see cref="ApplyDefaults"/> has completed on this <see cref="HitObject"/>.
/// </summary>
public event Action DefaultsApplied;
public readonly Bindable<double> StartTimeBindable = new Bindable<double>(); public readonly Bindable<double> StartTimeBindable = new Bindable<double>();
/// <summary> /// <summary>
@ -113,6 +119,8 @@ namespace osu.Game.Rulesets.Objects
foreach (var h in nestedHitObjects) foreach (var h in nestedHitObjects)
h.ApplyDefaults(controlPointInfo, difficulty); h.ApplyDefaults(controlPointInfo, difficulty);
DefaultsApplied?.Invoke();
} }
protected virtual void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) protected virtual void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)