mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 03:07:19 +08:00
Rework to avoid access to modified closures
This commit is contained in:
parent
c221cfd30c
commit
9260f5b64e
@ -68,31 +68,8 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing
|
|||||||
var lastSlider = t[1] as Slider;
|
var lastSlider = t[1] as Slider;
|
||||||
if (lastSlider != null)
|
if (lastSlider != null)
|
||||||
{
|
{
|
||||||
if (lastSlider.CursorPosition == null)
|
computeSliderCursorPosition(lastSlider);
|
||||||
{
|
lastCursorPosition = lastSlider.CursorPosition ?? lastCursorPosition;
|
||||||
float approxFollowCircleRadius = (float)(lastSlider.Radius * scalingFactor * 3);
|
|
||||||
|
|
||||||
var computeVertex = new Action<double>(t =>
|
|
||||||
{
|
|
||||||
var diff = lastSlider.PositionAt(t) - lastCursorPosition;
|
|
||||||
float dist = diff.Length;
|
|
||||||
|
|
||||||
if (dist > approxFollowCircleRadius)
|
|
||||||
{
|
|
||||||
// The cursor would be outside the follow circle, we need to move it
|
|
||||||
diff.Normalize(); // Obtain direction of diff
|
|
||||||
dist -= approxFollowCircleRadius;
|
|
||||||
lastCursorPosition += diff * dist;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var scoringTimes = lastSlider.Ticks.Select(t => t.StartTime).Concat(lastSlider.RepeatPoints.Select(r => r.StartTime)).OrderBy(t => t);
|
|
||||||
foreach (var time in scoringTimes)
|
|
||||||
computeVertex(time);
|
|
||||||
computeVertex(lastSlider.EndTime);
|
|
||||||
|
|
||||||
lastSlider.CursorPosition = lastCursorPosition;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Distance = (BaseObject.StackedPosition - lastCursorPosition).Length * scalingFactor;
|
Distance = (BaseObject.StackedPosition - lastCursorPosition).Length * scalingFactor;
|
||||||
@ -104,5 +81,32 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing
|
|||||||
DeltaTime = Math.Max(40, (t[0].StartTime - t[1].StartTime) / timeRate);
|
DeltaTime = Math.Max(40, (t[0].StartTime - t[1].StartTime) / timeRate);
|
||||||
TimeUntilHit = 450; // BaseObject.PreEmpt;
|
TimeUntilHit = 450; // BaseObject.PreEmpt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void computeSliderCursorPosition(Slider slider)
|
||||||
|
{
|
||||||
|
if (slider.CursorPosition != null)
|
||||||
|
return;
|
||||||
|
slider.CursorPosition = slider.StackedPosition;
|
||||||
|
|
||||||
|
float approxFollowCircleRadius = (float)(slider.Radius * 3);
|
||||||
|
var computeVertex = new Action<double>(t =>
|
||||||
|
{
|
||||||
|
var diff = slider.PositionAt(t) - slider.CursorPosition.Value;
|
||||||
|
float dist = diff.Length;
|
||||||
|
|
||||||
|
if (dist > approxFollowCircleRadius)
|
||||||
|
{
|
||||||
|
// The cursor would be outside the follow circle, we need to move it
|
||||||
|
diff.Normalize(); // Obtain direction of diff
|
||||||
|
dist -= approxFollowCircleRadius;
|
||||||
|
slider.CursorPosition += diff * dist;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var scoringTimes = slider.Ticks.Select(t => t.StartTime).Concat(slider.RepeatPoints.Select(r => r.StartTime)).OrderBy(t => t);
|
||||||
|
foreach (var time in scoringTimes)
|
||||||
|
computeVertex(time);
|
||||||
|
computeVertex(slider.EndTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user