1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 15:43:21 +08:00

Add legacy constructor

This commit is contained in:
smoogipoo 2019-12-05 18:19:42 +09:00
parent 986ac1cee4
commit 1585d83b96

View File

@ -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>