Remove `repeat` and simplify `getMinSliderMargin`

This commit is contained in:
Pasi4K5 2021-06-05 17:13:08 +02:00
parent f59263932a
commit b214f2ae0e
1 changed files with 7 additions and 15 deletions

View File

@ -151,31 +151,23 @@ private void moveSliderIntoPlayfield(Slider slider, RandomObjectInfo currentObje
/// </summary>
private MarginPadding getMinSliderMargin(Slider slider)
{
var minMargin = new MarginPadding();
var pathPositions = new List<Vector2>();
slider.Path.GetPathToProgress(pathPositions, 0, 1);
var minMargin = new MarginPadding();
foreach (var pos in pathPositions)
updateMargin(pos);
var repeat = (SliderRepeat)slider.NestedHitObjects.FirstOrDefault(o => o is SliderRepeat);
if (repeat != null)
updateMargin(repeat.Position - slider.Position);
minMargin.Left = Math.Min(minMargin.Left, OsuPlayfield.BASE_SIZE.X - minMargin.Right);
minMargin.Top = Math.Min(minMargin.Top, OsuPlayfield.BASE_SIZE.Y - minMargin.Bottom);
return minMargin;
void updateMargin(Vector2 pos)
{
minMargin.Left = Math.Max(minMargin.Left, -pos.X);
minMargin.Right = Math.Max(minMargin.Right, pos.X);
minMargin.Top = Math.Max(minMargin.Top, -pos.Y);
minMargin.Bottom = Math.Max(minMargin.Bottom, pos.Y);
}
minMargin.Left = Math.Min(minMargin.Left, OsuPlayfield.BASE_SIZE.X - minMargin.Right);
minMargin.Top = Math.Min(minMargin.Top, OsuPlayfield.BASE_SIZE.Y - minMargin.Bottom);
return minMargin;
}
/// <summary>