From 170513568be1a85e89f40ac622a70bee5c2ee753 Mon Sep 17 00:00:00 2001 From: ekrctb Date: Mon, 21 Jun 2021 19:08:43 +0900 Subject: [PATCH 1/2] Move caught object stack vertical offset logic --- osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs | 4 ++-- osu.Game.Rulesets.Catch/UI/Catcher.cs | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs index 1ad45d2f13..927175a138 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs @@ -194,8 +194,8 @@ namespace osu.Game.Rulesets.Catch.Tests AddStep("catch more fruits", () => attemptCatch(() => new Fruit(), 9)); checkPlate(10); AddAssert("caught objects are stacked", () => - catcher.CaughtObjects.All(obj => obj.Y <= Catcher.CAUGHT_FRUIT_VERTICAL_OFFSET) && - catcher.CaughtObjects.Any(obj => obj.Y == Catcher.CAUGHT_FRUIT_VERTICAL_OFFSET) && + catcher.CaughtObjects.All(obj => obj.Y <= 0) && + catcher.CaughtObjects.Any(obj => obj.Y == 0) && catcher.CaughtObjects.Any(obj => obj.Y < -25)); } diff --git a/osu.Game.Rulesets.Catch/UI/Catcher.cs b/osu.Game.Rulesets.Catch/UI/Catcher.cs index dcab9459ee..f2e29b2e10 100644 --- a/osu.Game.Rulesets.Catch/UI/Catcher.cs +++ b/osu.Game.Rulesets.Catch/UI/Catcher.cs @@ -56,11 +56,6 @@ namespace osu.Game.Rulesets.Catch.UI /// public double Speed => (Dashing ? 1 : 0.5) * BASE_SPEED * hyperDashModifier; - /// - /// The amount by which caught fruit should be offset from the plate surface to make them look visually "caught". - /// - public const float CAUGHT_FRUIT_VERTICAL_OFFSET = -5; - /// /// The amount by which caught fruit should be scaled down to fit on the plate. /// @@ -157,6 +152,8 @@ namespace osu.Game.Rulesets.Catch.UI { Anchor = Anchor.TopCentre, Origin = Anchor.BottomCentre, + // offset fruit vertically to better place "above" the plate. + Y = -5 }, body = new SkinnableCatcher(), hitExplosionContainer = new HitExplosionContainer @@ -388,9 +385,6 @@ namespace osu.Game.Rulesets.Catch.UI float adjustedRadius = displayRadius * lenience_adjust; float checkDistance = MathF.Pow(adjustedRadius, 2); - // offset fruit vertically to better place "above" the plate. - position.Y += CAUGHT_FRUIT_VERTICAL_OFFSET; - while (caughtObjectContainer.Any(f => Vector2Extensions.DistanceSquared(f.Position, position) < checkDistance)) { position.X += RNG.NextSingle(-adjustedRadius, adjustedRadius); From 623ba1591930383b2518ac1b9ad2b2d71f74b873 Mon Sep 17 00:00:00 2001 From: ekrctb Date: Sun, 4 Jul 2021 10:23:49 +0900 Subject: [PATCH 2/2] Relax caught object stacking test The stacking code currently uses an unseeded RNG and there is a non-zero chance the stack will be very flat (small Y position difference). Technically, `RNG.NextSingle(0, 5)` can return `0`, but extremely unlikely that the all RNG calls return 0. --- osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs index 927175a138..8359657f84 100644 --- a/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs +++ b/osu.Game.Rulesets.Catch.Tests/TestSceneCatcher.cs @@ -196,7 +196,7 @@ namespace osu.Game.Rulesets.Catch.Tests AddAssert("caught objects are stacked", () => catcher.CaughtObjects.All(obj => obj.Y <= 0) && catcher.CaughtObjects.Any(obj => obj.Y == 0) && - catcher.CaughtObjects.Any(obj => obj.Y < -25)); + catcher.CaughtObjects.Any(obj => obj.Y < 0)); } [Test]