From 2394e7ff783b0e733f072c698f77215337ffcc27 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 17 Mar 2017 01:36:30 +0900 Subject: [PATCH] Make CheckFailed not actually trigger internal things, and make private. --- osu.Game/Modes/ScoreProcessor.cs | 46 +++++++++++++++----------------- osu.Game/Screens/Play/Player.cs | 9 ++----- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/osu.Game/Modes/ScoreProcessor.cs b/osu.Game/Modes/ScoreProcessor.cs index 297b9a98bc..c78d9c4e1a 100644 --- a/osu.Game/Modes/ScoreProcessor.cs +++ b/osu.Game/Modes/ScoreProcessor.cs @@ -43,6 +43,11 @@ namespace osu.Game.Modes /// public readonly BindableInt HighestCombo = new BindableInt(); + /// + /// Whether the score is in a failed state. + /// + public virtual bool HasFailed { get; } + protected ScoreProcessor() { Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); }; @@ -78,12 +83,6 @@ namespace osu.Game.Modes { Failed?.Invoke(); } - - /// - /// Checks if the score is in a failing state. - /// - /// Whether the score is in a failing state. - public abstract bool CheckFailed(); } public abstract class ScoreProcessor : ScoreProcessor @@ -95,15 +94,12 @@ namespace osu.Game.Modes /// protected readonly List Judgements = new List(); - /// - /// Whether the score is in a failable state. - /// - protected virtual bool IsFailable => Health.Value == Health.MinValue; + public override bool HasFailed => Health.Value == Health.MinValue; /// /// Whether this ScoreProcessor has already failed. /// - private bool hasFailed; + private bool alreadyFailed; protected ScoreProcessor() { @@ -119,17 +115,6 @@ namespace osu.Game.Modes Reset(); } - public override bool CheckFailed() - { - if (!hasFailed && IsFailable) - { - hasFailed = true; - TriggerFailed(); - } - - return hasFailed; - } - /// /// Computes target scoring values for this ScoreProcessor. This is equivalent to performing an auto-play of the score to find the values. /// @@ -148,14 +133,27 @@ namespace osu.Game.Modes judgement.ComboAtHit = (ulong)Combo.Value; - CheckFailed(); + 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(); } protected override void Reset() { Judgements.Clear(); - hasFailed = false; + alreadyFailed = false; } /// diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index ec8cbb1438..1bde2b004e 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -239,14 +239,9 @@ namespace osu.Game.Screens.Play private void onCompletion() { - // Force a final check to see if the player has failed - // Some game modes (e.g. taiko) fail at the end of the map - if (scoreProcessor.CheckFailed()) - { - // If failed, onFail will be invoked which will push a new screen. - // Let's not push the completion screen in this case + // Only show the completion screen if the player hasn't failed + if (scoreProcessor.HasFailed) return; - } Delay(1000); Schedule(delegate