Make CheckFailed not actually trigger internal things, and make private.

This commit is contained in:
smoogipooo 2017-03-17 01:36:30 +09:00
parent 52c1cd407c
commit 2394e7ff78
2 changed files with 24 additions and 31 deletions

View File

@ -43,6 +43,11 @@ namespace osu.Game.Modes
/// </summary> /// </summary>
public readonly BindableInt HighestCombo = new BindableInt(); public readonly BindableInt HighestCombo = new BindableInt();
/// <summary>
/// Whether the score is in a failed state.
/// </summary>
public virtual bool HasFailed { get; }
protected ScoreProcessor() protected ScoreProcessor()
{ {
Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); }; Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); };
@ -78,12 +83,6 @@ namespace osu.Game.Modes
{ {
Failed?.Invoke(); Failed?.Invoke();
} }
/// <summary>
/// Checks if the score is in a failing state.
/// </summary>
/// <returns>Whether the score is in a failing state.</returns>
public abstract bool CheckFailed();
} }
public abstract class ScoreProcessor<TObject, TJudgement> : ScoreProcessor public abstract class ScoreProcessor<TObject, TJudgement> : ScoreProcessor
@ -95,15 +94,12 @@ namespace osu.Game.Modes
/// </summary> /// </summary>
protected readonly List<TJudgement> Judgements = new List<TJudgement>(); protected readonly List<TJudgement> Judgements = new List<TJudgement>();
/// <summary> public override bool HasFailed => Health.Value == Health.MinValue;
/// Whether the score is in a failable state.
/// </summary>
protected virtual bool IsFailable => Health.Value == Health.MinValue;
/// <summary> /// <summary>
/// Whether this ScoreProcessor has already failed. /// Whether this ScoreProcessor has already failed.
/// </summary> /// </summary>
private bool hasFailed; private bool alreadyFailed;
protected ScoreProcessor() protected ScoreProcessor()
{ {
@ -119,17 +115,6 @@ namespace osu.Game.Modes
Reset(); Reset();
} }
public override bool CheckFailed()
{
if (!hasFailed && IsFailable)
{
hasFailed = true;
TriggerFailed();
}
return hasFailed;
}
/// <summary> /// <summary>
/// Computes target scoring values for this ScoreProcessor. This is equivalent to performing an auto-play of the score to find the values. /// Computes target scoring values for this ScoreProcessor. This is equivalent to performing an auto-play of the score to find the values.
/// </summary> /// </summary>
@ -148,14 +133,27 @@ namespace osu.Game.Modes
judgement.ComboAtHit = (ulong)Combo.Value; judgement.ComboAtHit = (ulong)Combo.Value;
CheckFailed(); updateFailed();
}
/// <summary>
/// Checks if the score is in a failing state.
/// </summary>
/// <returns>Whether the score is in a failing state.</returns>
private void updateFailed()
{
if (alreadyFailed || !HasFailed)
return;
alreadyFailed = true;
TriggerFailed();
} }
protected override void Reset() protected override void Reset()
{ {
Judgements.Clear(); Judgements.Clear();
hasFailed = false; alreadyFailed = false;
} }
/// <summary> /// <summary>

View File

@ -239,14 +239,9 @@ namespace osu.Game.Screens.Play
private void onCompletion() private void onCompletion()
{ {
// Force a final check to see if the player has failed // Only show the completion screen if the player hasn't failed
// Some game modes (e.g. taiko) fail at the end of the map if (scoreProcessor.HasFailed)
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
return; return;
}
Delay(1000); Delay(1000);
Schedule(delegate Schedule(delegate