From 3fff7f4b7e9a5921be5928752840e59531090de4 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 14 Mar 2022 15:51:10 +0900 Subject: [PATCH] Require ScoreProcessor to receive ruleset --- .../Scoring/PippidonScoreProcessor.cs | 11 ----------- .../TestSceneComboCounter.cs | 2 +- osu.Game.Rulesets.Catch/CatchRuleset.cs | 2 +- .../Scoring/CatchScoreProcessor.cs | 5 +++++ osu.Game.Rulesets.Mania/ManiaRuleset.cs | 2 +- .../Scoring/ManiaScoreProcessor.cs | 5 +++++ osu.Game.Rulesets.Osu/OsuRuleset.cs | 2 +- .../Scoring/OsuScoreProcessor.cs | 5 +++++ .../Skinning/TestSceneDrawableTaikoMascot.cs | 2 +- .../Scoring/TaikoScoreProcessor.cs | 5 +++++ osu.Game.Rulesets.Taiko/TaikoRuleset.cs | 2 +- .../Gameplay/TestSceneScoreProcessor.cs | 6 +++--- .../Rulesets/Scoring/ScoreProcessorTest.cs | 3 ++- .../Gameplay/TestSceneBeatmapSkinFallbacks.cs | 2 +- .../Visual/Gameplay/TestSceneHUDOverlay.cs | 3 ++- .../Visual/Gameplay/TestSceneHitErrorMeter.cs | 5 +++++ .../TestScenePerformancePointsCounter.cs | 2 +- .../TestSceneSkinEditorMultipleSkins.cs | 2 +- .../TestSceneSkinnableAccuracyCounter.cs | 3 ++- .../Gameplay/TestSceneSkinnableComboCounter.cs | 3 ++- .../Gameplay/TestSceneSkinnableHUDOverlay.cs | 2 +- .../Gameplay/TestSceneSkinnableScoreCounter.cs | 3 ++- .../Gameplay/TestSceneUnstableRateCounter.cs | 6 ++++++ .../TestSceneMultiSpectatorLeaderboard.cs | 2 +- .../TestSceneMultiplayerGameplayLeaderboard.cs | 2 +- ...SceneMultiplayerGameplayLeaderboardTeams.cs | 2 +- osu.Game/Rulesets/Ruleset.cs | 2 +- osu.Game/Rulesets/Scoring/ScoreProcessor.cs | 11 +++++++---- .../Play/HUD/PerformancePointsCounter.cs | 12 ++++++------ .../Skinning/Editor/SkinComponentToolbox.cs | 18 +++++++++++++++++- 30 files changed, 88 insertions(+), 44 deletions(-) delete mode 100644 Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon/Scoring/PippidonScoreProcessor.cs diff --git a/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon/Scoring/PippidonScoreProcessor.cs b/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon/Scoring/PippidonScoreProcessor.cs deleted file mode 100644 index 1c4fe698c2..0000000000 --- a/Templates/Rulesets/ruleset-example/osu.Game.Rulesets.Pippidon/Scoring/PippidonScoreProcessor.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using osu.Game.Rulesets.Scoring; - -namespace osu.Game.Rulesets.Pippidon.Scoring -{ - public class PippidonScoreProcessor : ScoreProcessor - { - } -} diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneComboCounter.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneComboCounter.cs index 064a84cb98..b720ab1e97 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneComboCounter.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneComboCounter.cs @@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Catch.Tests [SetUp] public void SetUp() => Schedule(() => { - scoreProcessor = new ScoreProcessor(); + scoreProcessor = new ScoreProcessor(new CatchRuleset()); SetContents(_ => new CatchComboDisplay { diff --git a/osu.Game.Rulesets.Catch/CatchRuleset.cs b/osu.Game.Rulesets.Catch/CatchRuleset.cs index 3a7efb6263..45198fa0ca 100644 --- a/osu.Game.Rulesets.Catch/CatchRuleset.cs +++ b/osu.Game.Rulesets.Catch/CatchRuleset.cs @@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Catch { public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList mods = null) => new DrawableCatchRuleset(this, beatmap, mods); - public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor(); + public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor(this); public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new CatchBeatmapConverter(beatmap, this); diff --git a/osu.Game.Rulesets.Catch/Scoring/CatchScoreProcessor.cs b/osu.Game.Rulesets.Catch/Scoring/CatchScoreProcessor.cs index 9cd03dc869..2c183f5d94 100644 --- a/osu.Game.Rulesets.Catch/Scoring/CatchScoreProcessor.cs +++ b/osu.Game.Rulesets.Catch/Scoring/CatchScoreProcessor.cs @@ -7,6 +7,11 @@ namespace osu.Game.Rulesets.Catch.Scoring { public class CatchScoreProcessor : ScoreProcessor { + public CatchScoreProcessor(Ruleset ruleset) + : base(ruleset) + { + } + protected override double ClassicScoreMultiplier => 28; } } diff --git a/osu.Game.Rulesets.Mania/ManiaRuleset.cs b/osu.Game.Rulesets.Mania/ManiaRuleset.cs index d04ef69dd2..92c77f405b 100644 --- a/osu.Game.Rulesets.Mania/ManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/ManiaRuleset.cs @@ -47,7 +47,7 @@ namespace osu.Game.Rulesets.Mania public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList mods = null) => new DrawableManiaRuleset(this, beatmap, mods); - public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(); + public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this); public override HealthProcessor CreateHealthProcessor(double drainStartTime) => new ManiaHealthProcessor(drainStartTime, 0.5); diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index e0b19d87e8..0ffee809fc 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -7,6 +7,11 @@ namespace osu.Game.Rulesets.Mania.Scoring { internal class ManiaScoreProcessor : ScoreProcessor { + public ManiaScoreProcessor(Ruleset ruleset) + : base(ruleset) + { + } + protected override double DefaultAccuracyPortion => 0.99; protected override double DefaultComboPortion => 0.01; diff --git a/osu.Game.Rulesets.Osu/OsuRuleset.cs b/osu.Game.Rulesets.Osu/OsuRuleset.cs index 92b90339f9..87ffe8983f 100644 --- a/osu.Game.Rulesets.Osu/OsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs @@ -43,7 +43,7 @@ namespace osu.Game.Rulesets.Osu { public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList mods = null) => new DrawableOsuRuleset(this, beatmap, mods); - public override ScoreProcessor CreateScoreProcessor() => new OsuScoreProcessor(); + public override ScoreProcessor CreateScoreProcessor() => new OsuScoreProcessor(this); public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new OsuBeatmapConverter(beatmap, this); diff --git a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs index df38f0204a..e397fea0ed 100644 --- a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs +++ b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs @@ -11,6 +11,11 @@ namespace osu.Game.Rulesets.Osu.Scoring { public class OsuScoreProcessor : ScoreProcessor { + public OsuScoreProcessor(Ruleset ruleset) + : base(ruleset) + { + } + protected override double ClassicScoreMultiplier => 36; protected override HitEvent CreateHitEvent(JudgementResult result) diff --git a/osu.Game.Rulesets.Taiko.Tests/Skinning/TestSceneDrawableTaikoMascot.cs b/osu.Game.Rulesets.Taiko.Tests/Skinning/TestSceneDrawableTaikoMascot.cs index 920a7cd1a1..b7e1c9586a 100644 --- a/osu.Game.Rulesets.Taiko.Tests/Skinning/TestSceneDrawableTaikoMascot.cs +++ b/osu.Game.Rulesets.Taiko.Tests/Skinning/TestSceneDrawableTaikoMascot.cs @@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning [SetUp] public void SetUp() { - scoreProcessor = new TaikoScoreProcessor(); + scoreProcessor = new TaikoScoreProcessor(new TaikoRuleset()); } [Test] diff --git a/osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs b/osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs index 849b9c14bd..ddf6587022 100644 --- a/osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs +++ b/osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs @@ -7,6 +7,11 @@ namespace osu.Game.Rulesets.Taiko.Scoring { internal class TaikoScoreProcessor : ScoreProcessor { + public TaikoScoreProcessor(Ruleset ruleset) + : base(ruleset) + { + } + protected override double DefaultAccuracyPortion => 0.75; protected override double DefaultComboPortion => 0.25; diff --git a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs index 8934b64ca5..a3a2858bd5 100644 --- a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs @@ -36,7 +36,7 @@ namespace osu.Game.Rulesets.Taiko { public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList mods = null) => new DrawableTaikoRuleset(this, beatmap, mods); - public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(); + public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(this); public override HealthProcessor CreateHealthProcessor(double drainStartTime) => new TaikoHealthProcessor(); diff --git a/osu.Game.Tests/Gameplay/TestSceneScoreProcessor.cs b/osu.Game.Tests/Gameplay/TestSceneScoreProcessor.cs index 70ba868de6..9c307341bd 100644 --- a/osu.Game.Tests/Gameplay/TestSceneScoreProcessor.cs +++ b/osu.Game.Tests/Gameplay/TestSceneScoreProcessor.cs @@ -25,7 +25,7 @@ namespace osu.Game.Tests.Gameplay { var beatmap = new Beatmap { HitObjects = { new HitObject() } }; - var scoreProcessor = new ScoreProcessor(); + var scoreProcessor = new ScoreProcessor(new OsuRuleset()); scoreProcessor.ApplyBeatmap(beatmap); // Apply a miss judgement @@ -39,7 +39,7 @@ namespace osu.Game.Tests.Gameplay { var beatmap = new Beatmap { HitObjects = { new HitObject() } }; - var scoreProcessor = new ScoreProcessor(); + var scoreProcessor = new ScoreProcessor(new OsuRuleset()); scoreProcessor.ApplyBeatmap(beatmap); // Apply a judgement @@ -53,7 +53,7 @@ namespace osu.Game.Tests.Gameplay { var beatmap = new Beatmap { HitObjects = { new HitCircle() } }; - var scoreProcessor = new ScoreProcessor(); + var scoreProcessor = new ScoreProcessor(new OsuRuleset()); scoreProcessor.ApplyBeatmap(beatmap); scoreProcessor.ApplyResult(new JudgementResult(beatmap.HitObjects[0], new TestJudgement(HitResult.Great)) { Type = HitResult.Great }); diff --git a/osu.Game.Tests/Rulesets/Scoring/ScoreProcessorTest.cs b/osu.Game.Tests/Rulesets/Scoring/ScoreProcessorTest.cs index 2a19d51c9d..5c01950bea 100644 --- a/osu.Game.Tests/Rulesets/Scoring/ScoreProcessorTest.cs +++ b/osu.Game.Tests/Rulesets/Scoring/ScoreProcessorTest.cs @@ -10,6 +10,7 @@ using osu.Game.Rulesets.Difficulty; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects; +using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Scoring; @@ -27,7 +28,7 @@ namespace osu.Game.Tests.Rulesets.Scoring [SetUp] public void SetUp() { - scoreProcessor = new ScoreProcessor(); + scoreProcessor = new ScoreProcessor(new OsuRuleset()); beatmap = new TestBeatmap(new RulesetInfo()) { HitObjects = new List diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs index c5f56cae9e..c5ea9e6204 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneBeatmapSkinFallbacks.cs @@ -32,7 +32,7 @@ namespace osu.Game.Tests.Visual.Gameplay private SkinManager skinManager { get; set; } [Cached] - private ScoreProcessor scoreProcessor = new ScoreProcessor(); + private ScoreProcessor scoreProcessor = new ScoreProcessor(new OsuRuleset()); [Cached(typeof(HealthProcessor))] private HealthProcessor healthProcessor = new DrainingHealthProcessor(0); diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs index 4b54cd3510..505f73159f 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneHUDOverlay.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Testing; using osu.Game.Configuration; using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Play; using osu.Game.Skinning; @@ -24,7 +25,7 @@ namespace osu.Game.Tests.Visual.Gameplay private HUDOverlay hudOverlay; [Cached] - private ScoreProcessor scoreProcessor = new ScoreProcessor(); + private ScoreProcessor scoreProcessor = new ScoreProcessor(new OsuRuleset()); [Cached(typeof(HealthProcessor))] private HealthProcessor healthProcessor = new DrainingHealthProcessor(0); diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs index c1260f0231..ab9758a2ee 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneHitErrorMeter.cs @@ -273,6 +273,11 @@ namespace osu.Game.Tests.Visual.Gameplay private class TestScoreProcessor : ScoreProcessor { + public TestScoreProcessor() + : base(new OsuRuleset()) + { + } + public void Reset() => base.Reset(false); } } diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePerformancePointsCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePerformancePointsCounter.cs index 84c7f611af..aefe0db36a 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePerformancePointsCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePerformancePointsCounter.cs @@ -45,7 +45,7 @@ namespace osu.Game.Tests.Visual.Gameplay gameplayState = new GameplayState(beatmap, ruleset); gameplayState.LastJudgementResult.BindTo(lastJudgementResult); - scoreProcessor = new ScoreProcessor(); + scoreProcessor = new ScoreProcessor(ruleset); Child = dependencyContainer = new DependencyProvidingContainer { diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorMultipleSkins.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorMultipleSkins.cs index 856747ad19..8f33f6fac5 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorMultipleSkins.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinEditorMultipleSkins.cs @@ -17,7 +17,7 @@ namespace osu.Game.Tests.Visual.Gameplay public class TestSceneSkinEditorMultipleSkins : SkinnableTestScene { [Cached] - private readonly ScoreProcessor scoreProcessor = new ScoreProcessor(); + private readonly ScoreProcessor scoreProcessor = new ScoreProcessor(new OsuRuleset()); [Cached(typeof(HealthProcessor))] private HealthProcessor healthProcessor = new DrainingHealthProcessor(0); diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableAccuracyCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableAccuracyCounter.cs index 80eb887894..9c713b4616 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableAccuracyCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableAccuracyCounter.cs @@ -5,6 +5,7 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Testing; +using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Play.HUD; using osu.Game.Skinning; @@ -14,7 +15,7 @@ namespace osu.Game.Tests.Visual.Gameplay public class TestSceneSkinnableAccuracyCounter : SkinnableHUDComponentTestScene { [Cached] - private ScoreProcessor scoreProcessor = new ScoreProcessor(); + private ScoreProcessor scoreProcessor = new ScoreProcessor(new OsuRuleset()); protected override Drawable CreateDefaultImplementation() => new DefaultAccuracyCounter(); protected override Drawable CreateLegacyImplementation() => new LegacyAccuracyCounter(); diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableComboCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableComboCounter.cs index bd1fe050af..f507172931 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableComboCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableComboCounter.cs @@ -5,6 +5,7 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Testing; +using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Play.HUD; @@ -13,7 +14,7 @@ namespace osu.Game.Tests.Visual.Gameplay public class TestSceneSkinnableComboCounter : SkinnableHUDComponentTestScene { [Cached] - private ScoreProcessor scoreProcessor = new ScoreProcessor(); + private ScoreProcessor scoreProcessor = new ScoreProcessor(new OsuRuleset()); protected override Drawable CreateDefaultImplementation() => new DefaultComboCounter(); protected override Drawable CreateLegacyImplementation() => new LegacyComboCounter(); diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHUDOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHUDOverlay.cs index 3074a91dc6..cdf349ff7f 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHUDOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableHUDOverlay.cs @@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual.Gameplay private HUDOverlay hudOverlay; [Cached] - private ScoreProcessor scoreProcessor = new ScoreProcessor(); + private ScoreProcessor scoreProcessor = new ScoreProcessor(new OsuRuleset()); [Cached(typeof(HealthProcessor))] private HealthProcessor healthProcessor = new DrainingHealthProcessor(0); diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableScoreCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableScoreCounter.cs index 1700886263..a871e37ad4 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableScoreCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableScoreCounter.cs @@ -4,6 +4,7 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Scoring; using osu.Game.Screens.Play.HUD; using osu.Game.Skinning; @@ -13,7 +14,7 @@ namespace osu.Game.Tests.Visual.Gameplay public class TestSceneSkinnableScoreCounter : SkinnableHUDComponentTestScene { [Cached] - private ScoreProcessor scoreProcessor = new ScoreProcessor(); + private ScoreProcessor scoreProcessor = new ScoreProcessor(new OsuRuleset()); protected override Drawable CreateDefaultImplementation() => new DefaultScoreCounter(); protected override Drawable CreateLegacyImplementation() => new LegacyScoreCounter(); diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneUnstableRateCounter.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneUnstableRateCounter.cs index be20799479..ca8ecd490d 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneUnstableRateCounter.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneUnstableRateCounter.cs @@ -6,6 +6,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Testing; using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Scoring; using osu.Game.Rulesets.Scoring; @@ -102,6 +103,11 @@ namespace osu.Game.Tests.Visual.Gameplay private class TestScoreProcessor : ScoreProcessor { + public TestScoreProcessor() + : base(new OsuRuleset()) + { + } + public void Reset() => base.Reset(false); } } diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiSpectatorLeaderboard.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiSpectatorLeaderboard.cs index f57a54d84c..0cc1257a07 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiSpectatorLeaderboard.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiSpectatorLeaderboard.cs @@ -43,7 +43,7 @@ namespace osu.Game.Tests.Visual.Multiplayer { Beatmap.Value = CreateWorkingBeatmap(Ruleset.Value); var playable = Beatmap.Value.GetPlayableBeatmap(Ruleset.Value); - var scoreProcessor = new OsuScoreProcessor(); + var scoreProcessor = new OsuScoreProcessor(Ruleset.Value.CreateInstance()); scoreProcessor.ApplyBeatmap(playable); LoadComponentAsync(leaderboard = new MultiSpectatorLeaderboard(Ruleset.Value, scoreProcessor, clocks.Keys.Select(id => new MultiplayerRoomUser(id)).ToArray()) diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboard.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboard.cs index bcd4474876..0edc56f5d3 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboard.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboard.cs @@ -64,7 +64,7 @@ namespace osu.Game.Tests.Visual.Multiplayer Children = new Drawable[] { - scoreProcessor = new OsuScoreProcessor(), + scoreProcessor = new OsuScoreProcessor(Ruleset.Value.CreateInstance()), }; scoreProcessor.ApplyBeatmap(playableBeatmap); diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboardTeams.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboardTeams.cs index 7f5aced925..60a5785b31 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboardTeams.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerGameplayLeaderboardTeams.cs @@ -75,7 +75,7 @@ namespace osu.Game.Tests.Visual.Multiplayer Children = new Drawable[] { - scoreProcessor = new OsuScoreProcessor(), + scoreProcessor = new OsuScoreProcessor(Ruleset.Value.CreateInstance()), }; scoreProcessor.ApplyBeatmap(playableBeatmap); diff --git a/osu.Game/Rulesets/Ruleset.cs b/osu.Game/Rulesets/Ruleset.cs index d5926386e8..b7c6132bdb 100644 --- a/osu.Game/Rulesets/Ruleset.cs +++ b/osu.Game/Rulesets/Ruleset.cs @@ -201,7 +201,7 @@ namespace osu.Game.Rulesets /// Creates a for this . /// /// The score processor. - public virtual ScoreProcessor CreateScoreProcessor() => new ScoreProcessor(); + public virtual ScoreProcessor CreateScoreProcessor() => new ScoreProcessor(this); /// /// Creates a for this . diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs index a7fe8b354b..b982c6ece2 100644 --- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs +++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs @@ -84,6 +84,7 @@ namespace osu.Game.Rulesets.Scoring /// protected virtual double ClassicScoreMultiplier => 36; + private readonly Ruleset ruleset; private readonly double accuracyPortion; private readonly double comboPortion; @@ -116,8 +117,10 @@ namespace osu.Game.Rulesets.Scoring private double scoreMultiplier = 1; - public ScoreProcessor() + public ScoreProcessor(Ruleset ruleset) { + this.ruleset = ruleset; + accuracyPortion = DefaultAccuracyPortion; comboPortion = DefaultComboPortion; @@ -255,7 +258,7 @@ namespace osu.Game.Rulesets.Scoring /// The total score in the given . public double ComputeFinalScore(ScoringMode mode, ScoreInfo scoreInfo) { - extractFromStatistics(scoreInfo.Ruleset.CreateInstance(), + extractFromStatistics(ruleset, scoreInfo.Statistics, out double extractedBaseScore, out double extractedMaxBaseScore, @@ -282,7 +285,7 @@ namespace osu.Game.Rulesets.Scoring if (!beatmapApplied) throw new InvalidOperationException($"Cannot compute partial score without calling {nameof(ApplyBeatmap)}."); - extractFromStatistics(scoreInfo.Ruleset.CreateInstance(), + extractFromStatistics(ruleset, scoreInfo.Statistics, out double extractedBaseScore, out _, @@ -317,7 +320,7 @@ namespace osu.Game.Rulesets.Scoring if (scoreInfo.IsLegacyScore && scoreInfo.Ruleset.OnlineID == 3) { extractFromStatistics( - scoreInfo.Ruleset.CreateInstance(), + ruleset, scoreInfo.Statistics, out double computedBaseScore, out double computedMaxBaseScore, diff --git a/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs b/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs index a9b5544921..af360b42bb 100644 --- a/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs +++ b/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs @@ -26,6 +26,7 @@ using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Scoring; +using osu.Game.Scoring; using osu.Game.Skinning; using osuTK; @@ -56,6 +57,7 @@ namespace osu.Game.Screens.Play.HUD private JudgementResult lastJudgement; private PerformanceCalculator performanceCalculator; + private ScoreInfo scoreInfo; public PerformancePointsCounter() { @@ -72,9 +74,10 @@ namespace osu.Game.Screens.Play.HUD if (gameplayState != null) { performanceCalculator = gameplayState.Ruleset.CreatePerformanceCalculator(); - clonedMods = gameplayState.Mods.Select(m => m.DeepClone()).ToArray(); + scoreInfo = new ScoreInfo(gameplayState.Score.ScoreInfo.BeatmapInfo, gameplayState.Score.ScoreInfo.Ruleset); + var gameplayWorkingBeatmap = new GameplayWorkingBeatmap(gameplayState.Beatmap); difficultyCache.GetTimedDifficultyAttributesAsync(gameplayWorkingBeatmap, gameplayState.Ruleset, clonedMods, loadCancellationSource.Token) .ContinueWith(task => Schedule(() => @@ -123,16 +126,13 @@ namespace osu.Game.Screens.Play.HUD var attrib = getAttributeAtTime(judgement); - if (gameplayState == null || attrib == null) + if (gameplayState == null || attrib == null || scoreProcessor == null) { IsValid = false; return; } - // awkward but we need to make sure the true mods are not passed to PerformanceCalculator as it makes a mess of track applications. - var scoreInfo = gameplayState.Score.ScoreInfo.DeepClone(); - scoreInfo.Mods = clonedMods; - + scoreProcessor.PopulateScore(scoreInfo); Current.Value = (int)Math.Round(performanceCalculator?.Calculate(scoreInfo, attrib).Total ?? 0, MidpointRounding.AwayFromZero); IsValid = true; } diff --git a/osu.Game/Skinning/Editor/SkinComponentToolbox.cs b/osu.Game/Skinning/Editor/SkinComponentToolbox.cs index ce9afd650a..a9dcf705a9 100644 --- a/osu.Game/Skinning/Editor/SkinComponentToolbox.cs +++ b/osu.Game/Skinning/Editor/SkinComponentToolbox.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using System.Diagnostics; using System.Linq; using osu.Framework.Allocation; @@ -11,11 +12,16 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Effects; using osu.Framework.Input.Events; using osu.Framework.Utils; +using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osu.Game.Rulesets; +using osu.Game.Rulesets.Difficulty; using osu.Game.Rulesets.Edit; +using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring; +using osu.Game.Rulesets.UI; using osuTK; using osuTK.Graphics; @@ -30,7 +36,7 @@ namespace osu.Game.Skinning.Editor private const float component_display_scale = 0.8f; [Cached] - private ScoreProcessor scoreProcessor = new ScoreProcessor + private ScoreProcessor scoreProcessor = new ScoreProcessor(new DummyRuleset()) { Combo = { Value = RNG.Next(1, 1000) }, TotalScore = { Value = RNG.Next(1000, 10000000) } @@ -171,5 +177,15 @@ namespace osu.Game.Skinning.Editor return true; } } + + private class DummyRuleset : Ruleset + { + public override IEnumerable GetModsFor(ModType type) => throw new NotImplementedException(); + public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList mods = null) => throw new NotImplementedException(); + public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => throw new NotImplementedException(); + public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => throw new NotImplementedException(); + public override string Description { get; } + public override string ShortName { get; } + } } }