1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 15:52:54 +08:00

Use async difficulty calculation

This commit is contained in:
smoogipoo 2020-08-28 21:45:27 +09:00
parent 1e5e5cae0c
commit 39f8b5eb85

View File

@ -108,6 +108,8 @@ namespace osu.Game.Scoring
ScoringMode.BindValueChanged(onScoringModeChanged, true); ScoringMode.BindValueChanged(onScoringModeChanged, true);
} }
private IBindable<StarDifficulty> difficultyBindable;
private void onScoringModeChanged(ValueChangedEvent<ScoringMode> mode) private void onScoringModeChanged(ValueChangedEvent<ScoringMode> mode)
{ {
int? beatmapMaxCombo = score.Beatmap.MaxCombo; int? beatmapMaxCombo = score.Beatmap.MaxCombo;
@ -121,19 +123,25 @@ namespace osu.Game.Scoring
return; return;
} }
// We can compute the max combo locally. // We can compute the max combo locally after the async beatmap difficulty computation.
beatmapMaxCombo = difficulties().GetDifficulty(score.Beatmap, score.Ruleset, score.Mods).MaxCombo; difficultyBindable = difficulties().GetBindableDifficulty(score.Beatmap, score.Ruleset, score.Mods);
difficultyBindable.BindValueChanged(d => updateScore(d.NewValue.MaxCombo), true);
}
else
updateScore(beatmapMaxCombo.Value);
} }
private void updateScore(int beatmapMaxCombo)
{
var ruleset = score.Ruleset.CreateInstance(); var ruleset = score.Ruleset.CreateInstance();
var scoreProcessor = ruleset.CreateScoreProcessor(); var scoreProcessor = ruleset.CreateScoreProcessor();
scoreProcessor.Mods.Value = score.Mods; scoreProcessor.Mods.Value = score.Mods;
double maxBaseScore = 300 * beatmapMaxCombo.Value; double maxBaseScore = 300 * beatmapMaxCombo;
double maxHighestCombo = beatmapMaxCombo.Value; double maxHighestCombo = beatmapMaxCombo;
Value = Math.Round(scoreProcessor.GetScore(mode.NewValue, maxBaseScore, maxHighestCombo, score.Accuracy, score.MaxCombo / maxHighestCombo, 0)).ToString("N0"); Value = Math.Round(scoreProcessor.GetScore(ScoringMode.Value, maxBaseScore, maxHighestCombo, score.Accuracy, score.MaxCombo / maxHighestCombo, 0)).ToString("N0");
} }
} }
} }