1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 14:17:26 +08:00

More concrete method to determine if all hit objects have been judged.

Covers the case where nested hit objects are involved.
This commit is contained in:
smoogipooo 2017-05-11 14:48:08 +09:00
parent 6445bea864
commit 2d2d1beddd
2 changed files with 13 additions and 3 deletions

View File

@ -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;
/// <summary>
/// Whether this hit object has been judged.
/// </summary>
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
/// </summary>
public Color4 AccentColour { get; protected set; }
/// <summary>
/// Whether this hit object and all of its nested hit objects have been judged.
/// </summary>
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
/// <returns>Whether a hit was processed.</returns>
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<DrawableHitObject<TObject, TJudgement>> nestedHitObjects;
protected IEnumerable<DrawableHitObject<TObject, TJudgement>> NestedHitObjects => nestedHitObjects;
protected void AddNested(DrawableHitObject<TObject, TJudgement> h)

View File

@ -189,7 +189,7 @@ namespace osu.Game.Rulesets.UI
public override IEnumerable<HitObject> Objects => Beatmap.HitObjects;
protected override bool AllObjectsJudged => drawableObjects.All(h => h.Judgement.Result != HitResult.None);
protected override bool AllObjectsJudged => drawableObjects.All(h => h.Judged);
/// <summary>
/// The playfield.