1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Remove extra parameters

This commit is contained in:
Henry Lin 2022-03-14 20:23:35 +08:00
parent 6657d93b29
commit 76021c7627

View File

@ -81,12 +81,12 @@ namespace osu.Game.Rulesets.Osu.Utils
switch (hitObject) switch (hitObject)
{ {
case HitCircle circle: case HitCircle _:
shift = clampHitCircleToPlayfield(circle, current); shift = clampHitCircleToPlayfield(current);
break; break;
case Slider slider: case Slider _:
shift = clampSliderToPlayfield(slider, current); shift = clampSliderToPlayfield(current);
break; break;
} }
@ -144,48 +144,49 @@ namespace osu.Game.Rulesets.Osu.Utils
} }
/// <summary> /// <summary>
/// Move the modified position of a hit circle so that it fits inside the playfield. /// Move the modified position of a <see cref="HitCircle"/> so that it fits inside the playfield.
/// </summary> /// </summary>
/// <returns>The deviation from the original modified position in order to fit within the playfield.</returns> /// <returns>The deviation from the original modified position in order to fit within the playfield.</returns>
private static Vector2 clampHitCircleToPlayfield(HitCircle circle, WorkingObject objectPositionInfo) private static Vector2 clampHitCircleToPlayfield(WorkingObject workingObject)
{ {
var previousPosition = objectPositionInfo.PositionModified; var previousPosition = workingObject.PositionModified;
objectPositionInfo.EndPositionModified = objectPositionInfo.PositionModified = clampToPlayfieldWithPadding( workingObject.EndPositionModified = workingObject.PositionModified = clampToPlayfieldWithPadding(
objectPositionInfo.PositionModified, workingObject.PositionModified,
(float)circle.Radius (float)workingObject.HitObject.Radius
); );
circle.Position = objectPositionInfo.PositionModified; workingObject.HitObject.Position = workingObject.PositionModified;
return objectPositionInfo.PositionModified - previousPosition; return workingObject.PositionModified - previousPosition;
} }
/// <summary> /// <summary>
/// Moves the <see cref="Slider"/> and all necessary nested <see cref="OsuHitObject"/>s into the <see cref="OsuPlayfield"/> if they aren't already. /// Moves the <see cref="Slider"/> and all necessary nested <see cref="OsuHitObject"/>s into the <see cref="OsuPlayfield"/> if they aren't already.
/// </summary> /// </summary>
/// <returns>The deviation from the original modified position in order to fit within the playfield.</returns> /// <returns>The deviation from the original modified position in order to fit within the playfield.</returns>
private static Vector2 clampSliderToPlayfield(Slider slider, WorkingObject objectPositionInfo) private static Vector2 clampSliderToPlayfield(WorkingObject workingObject)
{ {
var slider = (Slider)workingObject.HitObject;
var possibleMovementBounds = calculatePossibleMovementBounds(slider); var possibleMovementBounds = calculatePossibleMovementBounds(slider);
var previousPosition = objectPositionInfo.PositionModified; var previousPosition = workingObject.PositionModified;
// Clamp slider position to the placement area // Clamp slider position to the placement area
// If the slider is larger than the playfield, force it to stay at the original position // If the slider is larger than the playfield, force it to stay at the original position
float newX = possibleMovementBounds.Width < 0 float newX = possibleMovementBounds.Width < 0
? objectPositionInfo.PositionOriginal.X ? workingObject.PositionOriginal.X
: Math.Clamp(previousPosition.X, possibleMovementBounds.Left, possibleMovementBounds.Right); : Math.Clamp(previousPosition.X, possibleMovementBounds.Left, possibleMovementBounds.Right);
float newY = possibleMovementBounds.Height < 0 float newY = possibleMovementBounds.Height < 0
? objectPositionInfo.PositionOriginal.Y ? workingObject.PositionOriginal.Y
: Math.Clamp(previousPosition.Y, possibleMovementBounds.Top, possibleMovementBounds.Bottom); : Math.Clamp(previousPosition.Y, possibleMovementBounds.Top, possibleMovementBounds.Bottom);
slider.Position = objectPositionInfo.PositionModified = new Vector2(newX, newY); slider.Position = workingObject.PositionModified = new Vector2(newX, newY);
objectPositionInfo.EndPositionModified = slider.EndPosition; workingObject.EndPositionModified = slider.EndPosition;
shiftNestedObjects(slider, objectPositionInfo.PositionModified - objectPositionInfo.PositionOriginal); shiftNestedObjects(slider, workingObject.PositionModified - workingObject.PositionOriginal);
return objectPositionInfo.PositionModified - previousPosition; return workingObject.PositionModified - previousPosition;
} }
/// <summary> /// <summary>