Skip to content

Commit

Permalink
Merge pull request #30021 from bdach/fix-random-mod-broken-sr
Browse files Browse the repository at this point in the history
Fix broken star rating on Random mod
  • Loading branch information
smoogipoo authored Oct 7, 2024
2 parents 8496005 + 31d1ba4 commit b977a18
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
27 changes: 21 additions & 6 deletions osu.Game.Rulesets.Osu/Objects/Slider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ protected override void CreateNestedHitObjects(CancellationToken cancellationTok
SpanStartTime = e.SpanStartTime,
StartTime = e.Time,
Position = Position + Path.PositionAt(e.PathProgress),
PathProgress = e.PathProgress,
StackHeight = StackHeight,
});
break;
Expand Down Expand Up @@ -236,6 +237,7 @@ protected override void CreateNestedHitObjects(CancellationToken cancellationTok
StartTime = StartTime + (e.SpanIndex + 1) * SpanDuration,
Position = Position + Path.PositionAt(e.PathProgress),
StackHeight = StackHeight,
PathProgress = e.PathProgress,
});
break;
}
Expand All @@ -248,14 +250,27 @@ private void updateNestedPositions()
{
endPositionCache.Invalidate();

if (HeadCircle != null)
HeadCircle.Position = Position;
foreach (var nested in NestedHitObjects)
{
switch (nested)
{
case SliderHeadCircle headCircle:
headCircle.Position = Position;
break;

case SliderTailCircle tailCircle:
tailCircle.Position = EndPosition;
break;

if (TailCircle != null)
TailCircle.Position = EndPosition;
case SliderRepeat repeat:
repeat.Position = Position + Path.PositionAt(repeat.PathProgress);
break;

if (LastRepeat != null)
LastRepeat.Position = RepeatCount % 2 == 0 ? Position : Position + Path.PositionAt(1);
case SliderTick tick:
tick.Position = Position + Path.PositionAt(tick.PathProgress);
break;
}
}
}

protected void UpdateNestedSamples()
Expand Down
2 changes: 2 additions & 0 deletions osu.Game.Rulesets.Osu/Objects/SliderRepeat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace osu.Game.Rulesets.Osu.Objects
{
public class SliderRepeat : SliderEndCircle
{
public double PathProgress { get; set; }

public SliderRepeat(Slider slider)
: base(slider)
{
Expand Down
1 change: 1 addition & 0 deletions osu.Game.Rulesets.Osu/Objects/SliderTick.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class SliderTick : OsuHitObject
{
public int SpanIndex { get; set; }
public double SpanStartTime { get; set; }
public double PathProgress { get; set; }

protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ private static Vector2 clampSliderToPlayfield(WorkingObject workingObject)
slider.Position = workingObject.PositionModified = new Vector2(newX, newY);
workingObject.EndPositionModified = slider.EndPosition;

shiftNestedObjects(slider, workingObject.PositionModified - workingObject.PositionOriginal);

return workingObject.PositionModified - previousPosition;
}

Expand Down Expand Up @@ -307,22 +305,6 @@ public static RectangleF CalculatePossibleMovementBounds(Slider slider)
return new RectangleF(left, top, right - left, bottom - top);
}

/// <summary>
/// Shifts all nested <see cref="SliderTick"/>s and <see cref="SliderRepeat"/>s by the specified shift.
/// </summary>
/// <param name="slider"><see cref="Slider"/> whose nested <see cref="SliderTick"/>s and <see cref="SliderRepeat"/>s should be shifted</param>
/// <param name="shift">The <see cref="Vector2"/> the <see cref="Slider"/>'s nested <see cref="SliderTick"/>s and <see cref="SliderRepeat"/>s should be shifted by</param>
private static void shiftNestedObjects(Slider slider, Vector2 shift)
{
foreach (var hitObject in slider.NestedHitObjects.Where(o => o is SliderTick || o is SliderRepeat))
{
if (!(hitObject is OsuHitObject osuHitObject))
continue;

osuHitObject.Position += shift;
}
}

/// <summary>
/// Clamp a position to playfield, keeping a specified distance from the edges.
/// </summary>
Expand Down Expand Up @@ -431,7 +413,6 @@ public ObjectPositionInfo(OsuHitObject hitObject)
private class WorkingObject
{
public float RotationOriginal { get; }
public Vector2 PositionOriginal { get; }
public Vector2 PositionModified { get; set; }
public Vector2 EndPositionModified { get; set; }

Expand All @@ -442,7 +423,7 @@ public WorkingObject(ObjectPositionInfo positionInfo)
{
PositionInfo = positionInfo;
RotationOriginal = HitObject is Slider slider ? getSliderRotation(slider) : 0;
PositionModified = PositionOriginal = HitObject.Position;
PositionModified = HitObject.Position;
EndPositionModified = HitObject.EndPosition;
}
}
Expand Down

0 comments on commit b977a18

Please sign in to comment.