mirror of
https://github.com/ppy/osu.git
synced 2024-11-15 09:47:24 +08:00
Remove no longer required nested object reposition hacks
As touched on in https://github.com/ppy/osu/issues/30237#issuecomment-2408557766, these types of maneouvers are no longer required after https://github.com/ppy/osu/pull/30021 - although as it turns out on closer inspection, these things being there still *did not actually break anything*, because the `slider.Path` mutation at the end of `modifySlider()` causes `updateNestedPositions()` to be called eventually anyway. So this is at mostly a code quality upgrade.
This commit is contained in:
parent
275b86cd3c
commit
1f1a174c50
@ -3,7 +3,6 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Game.Rulesets.Osu.UI;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||
@ -117,10 +116,9 @@ namespace osu.Game.Rulesets.Osu.Utils
|
||||
if (osuObject is not Slider slider)
|
||||
return;
|
||||
|
||||
void reflectNestedObject(OsuHitObject nested) => nested.Position = new Vector2(OsuPlayfield.BASE_SIZE.X - nested.Position.X, nested.Position.Y);
|
||||
static void reflectControlPoint(PathControlPoint point) => point.Position = new Vector2(-point.Position.X, point.Position.Y);
|
||||
|
||||
modifySlider(slider, reflectNestedObject, reflectControlPoint);
|
||||
modifySlider(slider, reflectControlPoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -134,10 +132,9 @@ namespace osu.Game.Rulesets.Osu.Utils
|
||||
if (osuObject is not Slider slider)
|
||||
return;
|
||||
|
||||
void reflectNestedObject(OsuHitObject nested) => nested.Position = new Vector2(nested.Position.X, OsuPlayfield.BASE_SIZE.Y - nested.Position.Y);
|
||||
static void reflectControlPoint(PathControlPoint point) => point.Position = new Vector2(point.Position.X, -point.Position.Y);
|
||||
|
||||
modifySlider(slider, reflectNestedObject, reflectControlPoint);
|
||||
modifySlider(slider, reflectControlPoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -146,10 +143,9 @@ namespace osu.Game.Rulesets.Osu.Utils
|
||||
/// <param name="slider">The slider to be flipped.</param>
|
||||
public static void FlipSliderInPlaceHorizontally(Slider slider)
|
||||
{
|
||||
void flipNestedObject(OsuHitObject nested) => nested.Position = new Vector2(slider.X - (nested.X - slider.X), nested.Y);
|
||||
static void flipControlPoint(PathControlPoint point) => point.Position = new Vector2(-point.Position.X, point.Position.Y);
|
||||
|
||||
modifySlider(slider, flipNestedObject, flipControlPoint);
|
||||
modifySlider(slider, flipControlPoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -159,18 +155,13 @@ namespace osu.Game.Rulesets.Osu.Utils
|
||||
/// <param name="rotation">The angle, measured in radians, to rotate the slider by.</param>
|
||||
public static void RotateSlider(Slider slider, float rotation)
|
||||
{
|
||||
void rotateNestedObject(OsuHitObject nested) => nested.Position = rotateVector(nested.Position - slider.Position, rotation) + slider.Position;
|
||||
void rotateControlPoint(PathControlPoint point) => point.Position = rotateVector(point.Position, rotation);
|
||||
|
||||
modifySlider(slider, rotateNestedObject, rotateControlPoint);
|
||||
modifySlider(slider, rotateControlPoint);
|
||||
}
|
||||
|
||||
private static void modifySlider(Slider slider, Action<OsuHitObject> modifyNestedObject, Action<PathControlPoint> modifyControlPoint)
|
||||
private static void modifySlider(Slider slider, Action<PathControlPoint> modifyControlPoint)
|
||||
{
|
||||
// No need to update the head and tail circles, since slider handles that when the new slider path is set
|
||||
slider.NestedHitObjects.OfType<SliderTick>().ForEach(modifyNestedObject);
|
||||
slider.NestedHitObjects.OfType<SliderRepeat>().ForEach(modifyNestedObject);
|
||||
|
||||
var controlPoints = slider.Path.ControlPoints.Select(p => new PathControlPoint(p.Position, p.Type)).ToArray();
|
||||
foreach (var point in controlPoints)
|
||||
modifyControlPoint(point);
|
||||
|
Loading…
Reference in New Issue
Block a user