From 0b1fef38af1660d6c17c87bdb0c94cff9770cfb0 Mon Sep 17 00:00:00 2001 From: Henry Lin Date: Sat, 5 Feb 2022 21:36:34 +0800 Subject: [PATCH] Use the playable beatmap provided in `CreateStatisticsForScore` --- osu.Game.Rulesets.Mania/ManiaRuleset.cs | 2 +- osu.Game.Rulesets.Osu/OsuRuleset.cs | 2 +- osu.Game.Rulesets.Taiko/TaikoRuleset.cs | 2 +- .../PerformanceBreakdownCalculator.cs | 17 ++++++++--------- .../Statistics/PerformanceBreakdownChart.cs | 9 ++++----- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/osu.Game.Rulesets.Mania/ManiaRuleset.cs b/osu.Game.Rulesets.Mania/ManiaRuleset.cs index aa9b4d5f1d..9027b71069 100644 --- a/osu.Game.Rulesets.Mania/ManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/ManiaRuleset.cs @@ -381,7 +381,7 @@ public override StatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatma { Columns = new[] { - new StatisticItem("Performance Breakdown", () => new PerformanceBreakdownChart(score) + new StatisticItem("Performance Breakdown", () => new PerformanceBreakdownChart(score, playableBeatmap) { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y diff --git a/osu.Game.Rulesets.Osu/OsuRuleset.cs b/osu.Game.Rulesets.Osu/OsuRuleset.cs index 769e83ec00..68e91e42a7 100644 --- a/osu.Game.Rulesets.Osu/OsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs @@ -301,7 +301,7 @@ public override StatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatma { Columns = new[] { - new StatisticItem("Performance Breakdown", () => new PerformanceBreakdownChart(score) + new StatisticItem("Performance Breakdown", () => new PerformanceBreakdownChart(score, playableBeatmap) { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y diff --git a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs index 37e959f8b4..ddc594a70a 100644 --- a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs @@ -224,7 +224,7 @@ public override StatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatma { Columns = new[] { - new StatisticItem("Performance Breakdown", () => new PerformanceBreakdownChart(score) + new StatisticItem("Performance Breakdown", () => new PerformanceBreakdownChart(score, playableBeatmap) { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y diff --git a/osu.Game/Rulesets/Difficulty/PerformanceBreakdownCalculator.cs b/osu.Game/Rulesets/Difficulty/PerformanceBreakdownCalculator.cs index 46342b237c..d68c2edb40 100644 --- a/osu.Game/Rulesets/Difficulty/PerformanceBreakdownCalculator.cs +++ b/osu.Game/Rulesets/Difficulty/PerformanceBreakdownCalculator.cs @@ -16,13 +16,13 @@ namespace osu.Game.Rulesets.Difficulty { public class PerformanceBreakdownCalculator { - private readonly BeatmapManager beatmapManager; + private readonly IBeatmap playableBeatmap; private readonly BeatmapDifficultyCache difficultyCache; private readonly ScorePerformanceCache performanceCache; - public PerformanceBreakdownCalculator(BeatmapManager beatmapManager, BeatmapDifficultyCache difficultyCache, ScorePerformanceCache performanceCache) + public PerformanceBreakdownCalculator(IBeatmap playableBeatmap, BeatmapDifficultyCache difficultyCache, ScorePerformanceCache performanceCache) { - this.beatmapManager = beatmapManager; + this.playableBeatmap = playableBeatmap; this.difficultyCache = difficultyCache; this.performanceCache = performanceCache; } @@ -46,14 +46,13 @@ private Task getPerfectPerformance(ScoreInfo score, Cance return Task.Run(async () => { Ruleset ruleset = score.Ruleset.CreateInstance(); - IBeatmap beatmap = beatmapManager.GetWorkingBeatmap(score.BeatmapInfo).GetPlayableBeatmap(score.Ruleset, score.Mods); ScoreInfo perfectPlay = score.DeepClone(); perfectPlay.Accuracy = 1; perfectPlay.Passed = true; // calculate max combo var difficulty = await difficultyCache.GetDifficultyAsync( - beatmap.BeatmapInfo, + playableBeatmap.BeatmapInfo, score.Ruleset, score.Mods, cancellationToken @@ -65,10 +64,10 @@ private Task getPerfectPerformance(ScoreInfo score, Cance perfectPlay.MaxCombo = difficulty.Value.MaxCombo; // create statistics assuming all hit objects have perfect hit result - var statistics = beatmap.HitObjects - .SelectMany(getPerfectHitResults) - .GroupBy(hr => hr, (hr, list) => (hitResult: hr, count: list.Count())) - .ToDictionary(pair => pair.hitResult, pair => pair.count); + var statistics = playableBeatmap.HitObjects + .SelectMany(getPerfectHitResults) + .GroupBy(hr => hr, (hr, list) => (hitResult: hr, count: list.Count())) + .ToDictionary(pair => pair.hitResult, pair => pair.count); perfectPlay.Statistics = statistics; // calculate total score diff --git a/osu.Game/Screens/Ranking/Statistics/PerformanceBreakdownChart.cs b/osu.Game/Screens/Ranking/Statistics/PerformanceBreakdownChart.cs index b58974eb96..fb9c93f0e6 100644 --- a/osu.Game/Screens/Ranking/Statistics/PerformanceBreakdownChart.cs +++ b/osu.Game/Screens/Ranking/Statistics/PerformanceBreakdownChart.cs @@ -26,6 +26,7 @@ namespace osu.Game.Screens.Ranking.Statistics public class PerformanceBreakdownChart : Container { private readonly ScoreInfo score; + private readonly IBeatmap playableBeatmap; private Drawable spinner; private Drawable content; @@ -41,12 +42,10 @@ public class PerformanceBreakdownChart : Container [Resolved] private BeatmapDifficultyCache difficultyCache { get; set; } - [Resolved] - private BeatmapManager beatmapManager { get; set; } - - public PerformanceBreakdownChart(ScoreInfo score) + public PerformanceBreakdownChart(ScoreInfo score, IBeatmap playableBeatmap) { this.score = score; + this.playableBeatmap = playableBeatmap; } [BackgroundDependencyLoader] @@ -146,7 +145,7 @@ private void load() spinner.Show(); - new PerformanceBreakdownCalculator(beatmapManager, difficultyCache, performanceCache) + new PerformanceBreakdownCalculator(playableBeatmap, difficultyCache, performanceCache) .CalculateAsync(score, cancellationTokenSource.Token) .ContinueWith(t => Schedule(() => setPerformanceValue(t.GetResultSafely()))); }