From fe11f328e604e06acb4708ab59cf31f516da27c4 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 17 Mar 2017 02:00:06 +0900 Subject: [PATCH] Cleanups. --- osu.Game/Modes/ScoreProcessor.cs | 45 ++++++++++++++------------------ 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/osu.Game/Modes/ScoreProcessor.cs b/osu.Game/Modes/ScoreProcessor.cs index c78d9c4e1a..6234af9c5f 100644 --- a/osu.Game/Modes/ScoreProcessor.cs +++ b/osu.Game/Modes/ScoreProcessor.cs @@ -14,7 +14,7 @@ namespace osu.Game.Modes public abstract class ScoreProcessor { /// - /// Invoked when the score is in a failing state. + /// Invoked when the score is in a failed state. /// public event Action Failed; @@ -46,7 +46,12 @@ namespace osu.Game.Modes /// /// Whether the score is in a failed state. /// - public virtual bool HasFailed { get; } + public virtual bool HasFailed => false; + + /// + /// Whether this ScoreProcessor has already triggered the failed state. + /// + private bool alreadyFailed; protected ScoreProcessor() { @@ -74,13 +79,22 @@ namespace osu.Game.Modes Health.Value = 0; Combo.Value = 0; HighestCombo.Value = 0; + + alreadyFailed = false; } /// - /// Notifies subscribers that the score is in a failed state. + /// Checks if the score is in a failed state and notifies subscribers. + /// + /// This can only ever notify subscribers once. + /// /// - protected void TriggerFailed() + protected void UpdateFailed() { + if (alreadyFailed || !HasFailed) + return; + + alreadyFailed = true; Failed?.Invoke(); } } @@ -96,11 +110,6 @@ namespace osu.Game.Modes public override bool HasFailed => Health.Value == Health.MinValue; - /// - /// Whether this ScoreProcessor has already failed. - /// - private bool alreadyFailed; - protected ScoreProcessor() { } @@ -108,6 +117,7 @@ namespace osu.Game.Modes protected ScoreProcessor(HitRenderer hitRenderer) { Judgements.Capacity = hitRenderer.Beatmap.HitObjects.Count; + hitRenderer.OnJudgement += addJudgement; ComputeTargets(hitRenderer.Beatmap); @@ -133,27 +143,12 @@ namespace osu.Game.Modes judgement.ComboAtHit = (ulong)Combo.Value; - updateFailed(); - } - - /// - /// Checks if the score is in a failing state. - /// - /// Whether the score is in a failing state. - private void updateFailed() - { - if (alreadyFailed || !HasFailed) - return; - - alreadyFailed = true; - TriggerFailed(); + UpdateFailed(); } protected override void Reset() { Judgements.Clear(); - - alreadyFailed = false; } ///