Make ScoreProcessor.Rank read-only

This commit is contained in:
Dean Herbert 2024-01-04 16:42:05 +09:00
parent 0bbc27e380
commit 705f25e4b9
No known key found for this signature in database
5 changed files with 11 additions and 14 deletions

View File

@ -56,9 +56,6 @@ namespace osu.Game.Rulesets.Mods
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
Combo.BindTo(scoreProcessor.Combo);
// Default value of ScoreProcessor's Rank in Flashlight Mod should be SS+
scoreProcessor.Rank.Value = ScoreRank.XH;
}
public ScoreRank AdjustRank(ScoreRank rank, double accuracy)

View File

@ -17,8 +17,6 @@ namespace osu.Game.Rulesets.Mods
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
// Default value of ScoreProcessor's Rank in Hidden Mod should be SS+
scoreProcessor.Rank.Value = ScoreRank.XH;
}
public ScoreRank AdjustRank(ScoreRank rank, double accuracy)

View File

@ -86,7 +86,9 @@ namespace osu.Game.Rulesets.Scoring
/// <summary>
/// The current rank.
/// </summary>
public readonly Bindable<ScoreRank> Rank = new Bindable<ScoreRank>(ScoreRank.X);
public IBindable<ScoreRank> Rank => rank;
private readonly Bindable<ScoreRank> rank = new Bindable<ScoreRank>(ScoreRank.X);
/// <summary>
/// The highest combo achieved by this score.
@ -186,9 +188,9 @@ namespace osu.Game.Rulesets.Scoring
Combo.ValueChanged += combo => HighestCombo.Value = Math.Max(HighestCombo.Value, combo.NewValue);
Accuracy.ValueChanged += accuracy =>
{
Rank.Value = RankFromAccuracy(accuracy.NewValue);
rank.Value = RankFromAccuracy(accuracy.NewValue);
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
Rank.Value = mod.AdjustRank(Rank.Value, accuracy.NewValue);
rank.Value = mod.AdjustRank(Rank.Value, accuracy.NewValue);
};
Mods.ValueChanged += mods =>
@ -411,8 +413,8 @@ namespace osu.Game.Rulesets.Scoring
TotalScore.Value = 0;
Accuracy.Value = 1;
Combo.Value = 0;
Rank.Disabled = false;
Rank.Value = ScoreRank.X;
rank.Disabled = false;
rank.Value = ScoreRank.X;
HighestCombo.Value = 0;
}
@ -448,7 +450,7 @@ namespace osu.Game.Rulesets.Scoring
return;
score.Passed = false;
Rank.Value = ScoreRank.F;
rank.Value = ScoreRank.F;
PopulateScore(score);
}

View File

@ -4,12 +4,14 @@
#nullable disable
using System.Collections.Generic;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Beatmaps.Timing;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Screens.Play.Break;
namespace osu.Game.Screens.Play
@ -113,7 +115,7 @@ namespace osu.Game.Screens.Play
if (scoreProcessor != null)
{
info.AccuracyDisplay.Current.BindTo(scoreProcessor.Accuracy);
info.GradeDisplay.Current.BindTo(scoreProcessor.Rank);
((IBindable<ScoreRank>)info.GradeDisplay.Current).BindTo(scoreProcessor.Rank);
}
}

View File

@ -801,8 +801,6 @@ namespace osu.Game.Screens.Play
// This player instance may already be in the process of exiting.
return;
Debug.Assert(ScoreProcessor.Rank.Value != ScoreRank.F);
this.Push(CreateResults(prepareScoreForDisplayTask.GetResultSafely()));
}, Time.Current + delay, 50);