mirror of
https://github.com/ppy/osu
synced 2025-01-29 17:23:03 +00:00
Simplify path/point construction
This commit is contained in:
parent
53f7c753fb
commit
5a093c039c
@ -26,12 +26,25 @@ namespace osu.Game.Rulesets.Objects
|
||||
/// </summary>
|
||||
internal event Action Changed;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PathControlPoint"/>.
|
||||
/// </summary>
|
||||
public PathControlPoint()
|
||||
: this(Vector2.Zero, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PathControlPoint"/> with a provided position and type.
|
||||
/// </summary>
|
||||
/// <param name="position">The initial position.</param>
|
||||
/// <param name="type">The initial type.</param>
|
||||
public PathControlPoint(Vector2 position, PathType? type = null)
|
||||
{
|
||||
Position.ValueChanged += _ => Changed?.Invoke();
|
||||
Type.ValueChanged += _ => Changed?.Invoke();
|
||||
}
|
||||
|
||||
public bool Equals(PathControlPoint other) => Position.Value == other.Position.Value && Type.Value == other.Type.Value;
|
||||
public bool Equals(PathControlPoint other) => Position.Value == other?.Position.Value && Type.Value == other.Type.Value;
|
||||
}
|
||||
}
|
||||
|
@ -40,12 +40,10 @@ namespace osu.Game.Rulesets.Objects
|
||||
/// </summary>
|
||||
public readonly BindableList<PathControlPoint> ControlPoints = new BindableList<PathControlPoint>();
|
||||
|
||||
public readonly List<int> Test = new List<int>();
|
||||
|
||||
private readonly Cached pathCache = new Cached();
|
||||
|
||||
private readonly List<Vector2> calculatedPath = new List<Vector2>();
|
||||
private readonly List<double> cumulativeLength = new List<double>();
|
||||
private readonly Cached pathCache = new Cached();
|
||||
|
||||
private double calculatedLength;
|
||||
|
||||
/// <summary>
|
||||
@ -87,7 +85,7 @@ namespace osu.Game.Rulesets.Objects
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="SliderPath"/>.
|
||||
/// Creates a new <see cref="SliderPath"/> initialised with a list of control points.
|
||||
/// </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.
|
||||
@ -101,13 +99,8 @@ namespace osu.Game.Rulesets.Objects
|
||||
}
|
||||
|
||||
public SliderPath(PathType type, Vector2[] controlPoints, double? expectedDistance = null)
|
||||
: this()
|
||||
: this(controlPoints.Select((c, i) => new PathControlPoint(c, i == 0 ? (PathType?)type : null)).ToArray(), expectedDistance)
|
||||
{
|
||||
foreach (var c in controlPoints)
|
||||
ControlPoints.Add(new PathControlPoint { Position = { Value = c } });
|
||||
ControlPoints[0].Type.Value = type;
|
||||
|
||||
ExpectedDistance.Value = expectedDistance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user