From 76021c76278cf3a91a6f38e6b9b047a93f5dadad Mon Sep 17 00:00:00 2001 From: Henry Lin Date: Mon, 14 Mar 2022 20:23:35 +0800 Subject: [PATCH] Remove extra parameters --- .../OsuHitObjectGenerationUtils_Reposition.cs | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Utils/OsuHitObjectGenerationUtils_Reposition.cs b/osu.Game.Rulesets.Osu/Utils/OsuHitObjectGenerationUtils_Reposition.cs index 94f4f154bd..d1bc3b45df 100644 --- a/osu.Game.Rulesets.Osu/Utils/OsuHitObjectGenerationUtils_Reposition.cs +++ b/osu.Game.Rulesets.Osu/Utils/OsuHitObjectGenerationUtils_Reposition.cs @@ -81,12 +81,12 @@ namespace osu.Game.Rulesets.Osu.Utils switch (hitObject) { - case HitCircle circle: - shift = clampHitCircleToPlayfield(circle, current); + case HitCircle _: + shift = clampHitCircleToPlayfield(current); break; - case Slider slider: - shift = clampSliderToPlayfield(slider, current); + case Slider _: + shift = clampSliderToPlayfield(current); break; } @@ -144,48 +144,49 @@ namespace osu.Game.Rulesets.Osu.Utils } /// - /// Move the modified position of a hit circle so that it fits inside the playfield. + /// Move the modified position of a so that it fits inside the playfield. /// /// The deviation from the original modified position in order to fit within the playfield. - private static Vector2 clampHitCircleToPlayfield(HitCircle circle, WorkingObject objectPositionInfo) + private static Vector2 clampHitCircleToPlayfield(WorkingObject workingObject) { - var previousPosition = objectPositionInfo.PositionModified; - objectPositionInfo.EndPositionModified = objectPositionInfo.PositionModified = clampToPlayfieldWithPadding( - objectPositionInfo.PositionModified, - (float)circle.Radius + var previousPosition = workingObject.PositionModified; + workingObject.EndPositionModified = workingObject.PositionModified = clampToPlayfieldWithPadding( + workingObject.PositionModified, + (float)workingObject.HitObject.Radius ); - circle.Position = objectPositionInfo.PositionModified; + workingObject.HitObject.Position = workingObject.PositionModified; - return objectPositionInfo.PositionModified - previousPosition; + return workingObject.PositionModified - previousPosition; } /// /// Moves the and all necessary nested s into the if they aren't already. /// /// The deviation from the original modified position in order to fit within the playfield. - private static Vector2 clampSliderToPlayfield(Slider slider, WorkingObject objectPositionInfo) + private static Vector2 clampSliderToPlayfield(WorkingObject workingObject) { + var slider = (Slider)workingObject.HitObject; var possibleMovementBounds = calculatePossibleMovementBounds(slider); - var previousPosition = objectPositionInfo.PositionModified; + var previousPosition = workingObject.PositionModified; // Clamp slider position to the placement area // If the slider is larger than the playfield, force it to stay at the original position float newX = possibleMovementBounds.Width < 0 - ? objectPositionInfo.PositionOriginal.X + ? workingObject.PositionOriginal.X : Math.Clamp(previousPosition.X, possibleMovementBounds.Left, possibleMovementBounds.Right); float newY = possibleMovementBounds.Height < 0 - ? objectPositionInfo.PositionOriginal.Y + ? workingObject.PositionOriginal.Y : Math.Clamp(previousPosition.Y, possibleMovementBounds.Top, possibleMovementBounds.Bottom); - slider.Position = objectPositionInfo.PositionModified = new Vector2(newX, newY); - objectPositionInfo.EndPositionModified = slider.EndPosition; + slider.Position = workingObject.PositionModified = new Vector2(newX, newY); + workingObject.EndPositionModified = slider.EndPosition; - shiftNestedObjects(slider, objectPositionInfo.PositionModified - objectPositionInfo.PositionOriginal); + shiftNestedObjects(slider, workingObject.PositionModified - workingObject.PositionOriginal); - return objectPositionInfo.PositionModified - previousPosition; + return workingObject.PositionModified - previousPosition; } ///