From 04af46b8c72a03030aa61b69bc4a1ef72b8d9843 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 16 Oct 2023 18:34:56 +0900 Subject: [PATCH] Change `SpinFramesGenerator` to take degrees as input --- .../SpinFramesGenerator.cs | 4 +- .../TestSceneLegacyHitPolicy.cs | 2 +- .../TestSceneSpinnerInput.cs | 38 +++++++++---------- .../TestSceneSpinnerJudgement.cs | 2 +- .../TestSceneStartTimeOrderedHitPolicy.cs | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/SpinFramesGenerator.cs b/osu.Game.Rulesets.Osu.Tests/SpinFramesGenerator.cs index 43adfb7f1f..dbdfa1f258 100644 --- a/osu.Game.Rulesets.Osu.Tests/SpinFramesGenerator.cs +++ b/osu.Game.Rulesets.Osu.Tests/SpinFramesGenerator.cs @@ -39,12 +39,12 @@ namespace osu.Game.Rulesets.Osu.Tests /// /// Performs a single spin. /// - /// The amount, relative to a full circle, to spin. + /// The amount of degrees to spin. /// The time to spend to perform the spin. /// This . public SpinFramesGenerator Spin(float delta, double duration) { - sequences.Add((delta * 2 * MathF.PI, duration)); + sequences.Add((delta / 360 * 2 * MathF.PI, duration)); return this; } diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs index e0a618b187..fa6aa580a3 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs @@ -362,7 +362,7 @@ namespace osu.Game.Rulesets.Osu.Tests }; frames.AddRange(new SpinFramesGenerator(time_spinner + 10) - .Spin(1, 500) + .Spin(360, 500) .Build()); performTest(hitObjects, frames); diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerInput.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerInput.cs index d7151f9370..c4bf0d4e2e 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerInput.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerInput.cs @@ -107,14 +107,14 @@ namespace osu.Game.Rulesets.Osu.Tests /// /// Spins in a single direction. /// - [TestCase(0.5f, 0)] - [TestCase(-0.5f, 0)] - [TestCase(1, 1)] - [TestCase(-1, 1)] - [TestCase(1.5f, 1)] - [TestCase(-1.5f, 1)] - [TestCase(2f, 2)] - [TestCase(-2f, 2)] + [TestCase(180, 0)] + [TestCase(-180, 0)] + [TestCase(360, 1)] + [TestCase(-360, 1)] + [TestCase(540, 1)] + [TestCase(-540, 1)] + [TestCase(720, 2)] + [TestCase(-720, 2)] public void TestSpinSingleDirection(float amount, int expectedTicks) { performTest(new SpinFramesGenerator(time_spinner_start) @@ -134,8 +134,8 @@ namespace osu.Game.Rulesets.Osu.Tests public void TestSpinHalfBothDirections() { performTest(new SpinFramesGenerator(time_spinner_start) - .Spin(0.5f, 500) // Rotate to +0.5. - .Spin(-1f, 500) // Rotate to -0.5 + .Spin(180, 500) // Rotate to +0.5. + .Spin(-360, 500) // Rotate to -0.5 .Build()); assertTicksHit(0); @@ -145,10 +145,10 @@ namespace osu.Game.Rulesets.Osu.Tests /// /// Spin in one direction then spin in the other. /// - [TestCase(0.5f, -1.5f, 1)] - [TestCase(-0.5f, 1.5f, 1)] - [TestCase(0.5f, -2.5f, 2)] - [TestCase(-0.5f, 2.5f, 2)] + [TestCase(180, -540, 1)] + [TestCase(-180, 540, 1)] + [TestCase(180, -900, 2)] + [TestCase(-180, 900, 2)] [Ignore("An upcoming implementation will fix this case")] public void TestSpinOneDirectionThenChangeDirection(float direction1, float direction2, int expectedTicks) { @@ -168,11 +168,11 @@ namespace osu.Game.Rulesets.Osu.Tests AddStep("set manual clock", () => manualClock = new ManualClock { Rate = 1 }); List frames = new SpinFramesGenerator(time_spinner_start) - .Spin(1f, 500) // 2000ms -> 1 full CW spin - .Spin(-0.5f, 500) // 2500ms -> 0.5 CCW spins - .Spin(0.25f, 500) // 3000ms -> 0.25 CW spins - .Spin(1.25f, 500) // 3500ms -> 1 full CW spin - .Spin(0.5f, 500) // 4000ms -> 0.5 CW spins + .Spin(360, 500) // 2000ms -> 1 full CW spin + .Spin(-180, 500) // 2500ms -> 0.5 CCW spins + .Spin(90, 500) // 3000ms -> 0.25 CW spins + .Spin(450, 500) // 3500ms -> 1 full CW spin + .Spin(180, 500) // 4000ms -> 0.5 CW spins .Build(); loadPlayer(frames); diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerJudgement.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerJudgement.cs index 6a50f08508..8d8c2e9639 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerJudgement.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneSpinnerJudgement.cs @@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Osu.Tests } private static List generateReplay(int spins) => new SpinFramesGenerator(time_spinner_start) - .Spin(spins, time_spinner_end - time_spinner_start) + .Spin(spins * 360, time_spinner_end - time_spinner_start) .Build(); private void performTest(List frames) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneStartTimeOrderedHitPolicy.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneStartTimeOrderedHitPolicy.cs index 19413a50a8..3475680c71 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneStartTimeOrderedHitPolicy.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneStartTimeOrderedHitPolicy.cs @@ -290,7 +290,7 @@ namespace osu.Game.Rulesets.Osu.Tests }; frames.AddRange(new SpinFramesGenerator(time_spinner + 10) - .Spin(1, 500) + .Spin(360, 500) .Build()); performTest(hitObjects, frames);