diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index a300eeab31..45ef2553b5 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); @@ -86,6 +92,11 @@ namespace osu.Game.Rulesets.Objects.Drawables /// public Color4 AccentColour { get; protected 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) ?? true); + protected DrawableHitObject(TObject hitObject) { HitObject = hitObject; @@ -97,7 +108,7 @@ namespace osu.Game.Rulesets.Objects.Drawables /// Whether a hit was processed. protected bool UpdateJudgement(bool userTriggered) { - IPartialJudgement partial = Judgement as IPartialJudgement; + var partial = Judgement as IPartialJudgement; // Never re-process non-partial hits if (Judgement.Result != HitResult.None && partial == null) @@ -169,7 +180,6 @@ namespace osu.Game.Rulesets.Objects.Drawables } private List> nestedHitObjects; - protected IEnumerable> NestedHitObjects => nestedHitObjects; protected void AddNested(DrawableHitObject h) diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index 8ee67df95a..3ec5c353a0 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -187,17 +187,19 @@ 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); + public override IEnumerable Objects => Beatmap.HitObjects; + + protected override bool AllObjectsJudged => drawableObjects.All(h => h.Judged); /// /// The playfield. /// protected Playfield Playfield; + protected override Container Content => content; private readonly Container content; - public override IEnumerable Objects => Beatmap.HitObjects; + private readonly List> drawableObjects = new List>(); protected HitRenderer(WorkingBeatmap beatmap) : base(beatmap) @@ -224,6 +226,8 @@ namespace osu.Game.Rulesets.UI private void loadObjects() { + drawableObjects.Capacity = Beatmap.HitObjects.Count; + foreach (TObject h in Beatmap.HitObjects) { var drawableObject = GetVisualRepresentation(h); @@ -233,6 +237,7 @@ namespace osu.Game.Rulesets.UI drawableObject.OnJudgement += onJudgement; + drawableObjects.Add(drawableObject); Playfield.Add(drawableObject); } diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index 0586c0385a..612569a9ae 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.UI /// /// The HitObjects contained in this Playfield. /// - public HitObjectContainer> HitObjects; + protected HitObjectContainer> HitObjects; internal Container ScaledContent;