mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 11:12:54 +08:00
Add legacy constructor
This commit is contained in:
parent
986ac1cee4
commit
1585d83b96
@ -37,13 +37,8 @@ namespace osu.Game.Rulesets.Objects
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="SliderPath"/>.
|
||||
/// </summary>
|
||||
/// <param name="controlPoints">An optional set of <see cref="PathControlPoint"/>s to initialise the path with.</param>
|
||||
/// <param name="expectedDistance">A user-set distance of the path that may be shorter or longer than the true distance between all control points.
|
||||
/// The path will be shortened/lengthened to match this length. If null, the path will use the true distance between all control points.</param>
|
||||
[JsonConstructor]
|
||||
public SliderPath(PathControlPoint[] controlPoints = null, double? expectedDistance = null)
|
||||
public SliderPath()
|
||||
{
|
||||
ExpectedDistance.Value = expectedDistance;
|
||||
ExpectedDistance.ValueChanged += _ => pathCache.Invalidate();
|
||||
|
||||
ControlPoints.ItemsAdded += items =>
|
||||
@ -62,11 +57,33 @@ namespace osu.Game.Rulesets.Objects
|
||||
onControlPointChanged();
|
||||
};
|
||||
|
||||
ControlPoints.AddRange(controlPoints);
|
||||
|
||||
void onControlPointChanged() => pathCache.Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="SliderPath"/>.
|
||||
/// </summary>
|
||||
/// <param name="controlPoints">An optional set of <see cref="PathControlPoint"/>s to initialise the path with.</param>
|
||||
/// <param name="expectedDistance">A user-set distance of the path that may be shorter or longer than the true distance between all control points.
|
||||
/// The path will be shortened/lengthened to match this length. If null, the path will use the true distance between all control points.</param>
|
||||
[JsonConstructor]
|
||||
public SliderPath(PathControlPoint[] controlPoints, double? expectedDistance = null)
|
||||
: this()
|
||||
{
|
||||
ControlPoints.AddRange(controlPoints);
|
||||
ExpectedDistance.Value = expectedDistance;
|
||||
}
|
||||
|
||||
public SliderPath(PathType type, Vector2[] controlPoints, double? expectedDistance = null)
|
||||
: this()
|
||||
{
|
||||
foreach (var c in controlPoints)
|
||||
ControlPoints.Add(new PathControlPoint { Position = { Value = c } });
|
||||
ControlPoints[0].Type.Value = type;
|
||||
|
||||
ExpectedDistance.Value = expectedDistance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The distance of the path after lengthening/shortening to account for <see cref="ExpectedDistance"/>.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user