mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Simplify path/point construction
This commit is contained in:
@ -26,12 +26,25 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal event Action Changed;
|
internal event Action Changed;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new <see cref="PathControlPoint"/>.
|
||||||
|
/// </summary>
|
||||||
public PathControlPoint()
|
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();
|
Position.ValueChanged += _ => Changed?.Invoke();
|
||||||
Type.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>
|
/// </summary>
|
||||||
public readonly BindableList<PathControlPoint> ControlPoints = new BindableList<PathControlPoint>();
|
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<Vector2> calculatedPath = new List<Vector2>();
|
||||||
private readonly List<double> cumulativeLength = new List<double>();
|
private readonly List<double> cumulativeLength = new List<double>();
|
||||||
|
private readonly Cached pathCache = new Cached();
|
||||||
|
|
||||||
private double calculatedLength;
|
private double calculatedLength;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -87,7 +85,7 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="SliderPath"/>.
|
/// Creates a new <see cref="SliderPath"/> initialised with a list of control points.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="controlPoints">An optional set of <see cref="PathControlPoint"/>s to initialise the path with.</param>
|
/// <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.
|
/// <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)
|
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>
|
/// <summary>
|
||||||
|
Reference in New Issue
Block a user