From ba998035a891bfdfaa4ccf14cbccf2c1d9590bdd Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 10 May 2017 17:53:51 +0900 Subject: [PATCH] More concrete way to determine whether all hit objects have been judged. --- .../Objects/Drawables/DrawableHitObject.cs | 17 ++++++++++++----- osu.Game/Rulesets/UI/HitRenderer.cs | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 21eca346c4..f443b5e279 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -12,6 +12,7 @@ using Container = osu.Framework.Graphics.Containers.Container; using osu.Game.Rulesets.Objects.Types; using OpenTK.Graphics; using osu.Game.Audio; +using System.Linq; namespace osu.Game.Rulesets.Objects.Drawables { @@ -24,6 +25,11 @@ namespace osu.Game.Rulesets.Objects.Drawables public TJudgement Judgement; + /// + /// Whether this hit object has been judged. + /// + public virtual bool Judged => (Judgement?.Result ?? HitResult.None) != HitResult.None; + protected abstract TJudgement CreateJudgement(); protected abstract void UpdateState(ArmedState state); @@ -90,6 +96,11 @@ namespace osu.Game.Rulesets.Objects.Drawables /// public virtual Color4 AccentColour { get; set; } + /// + /// Whether this hit object and all of its nested hit objects have been judged. + /// + public sealed override bool Judged => base.Judged && NestedHitObjects.All(h => h.Judged); + protected DrawableHitObject(TObject hitObject) { HitObject = hitObject; @@ -172,15 +183,11 @@ namespace osu.Game.Rulesets.Objects.Drawables } } - private List> nestedHitObjects; - + private List> nestedHitObjects = new List>(); protected IEnumerable> NestedHitObjects => nestedHitObjects; protected void AddNested(DrawableHitObject h) { - if (nestedHitObjects == null) - nestedHitObjects = new List>(); - h.OnJudgement += d => OnJudgement?.Invoke(d); nestedHitObjects.Add(h); } diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index 8ee67df95a..bae8c5e75b 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -188,7 +188,7 @@ namespace osu.Game.Rulesets.UI public sealed override bool ProvidingUserCursor => !HasReplayLoaded && Playfield.ProvidingUserCursor; protected override Container Content => content; - protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result != HitResult.None); + protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judged); /// /// The playfield.