1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-31 22:22:55 +08:00

Apply suggested refactorings

This commit is contained in:
smoogipoo 2019-12-10 13:12:54 +09:00
parent 2c4c190f15
commit ab0f2e7c6a
2 changed files with 7 additions and 9 deletions

View File

@ -257,14 +257,13 @@ namespace osu.Game.Rulesets.Objects.Legacy
{ {
if (type == PathType.PerfectCurve) if (type == PathType.PerfectCurve)
{ {
if (vertices.Length == 3) if (vertices.Length != 3)
type = PathType.Bezier;
else if (isLinear(vertices))
{ {
// osu-stable special-cased colinear perfect curves to a linear path // osu-stable special-cased colinear perfect curves to a linear path
if (isLinear(vertices))
type = PathType.Linear; type = PathType.Linear;
} }
else
type = PathType.Bezier;
} }
var points = new List<PathControlPoint>(vertices.Length) var points = new List<PathControlPoint>(vertices.Length)

View File

@ -30,8 +30,9 @@ namespace osu.Game.Rulesets.Objects
/// Creates a new <see cref="PathControlPoint"/>. /// Creates a new <see cref="PathControlPoint"/>.
/// </summary> /// </summary>
public PathControlPoint() public PathControlPoint()
: this(Vector2.Zero, null)
{ {
Position.ValueChanged += _ => Changed?.Invoke();
Type.ValueChanged += _ => Changed?.Invoke();
} }
/// <summary> /// <summary>
@ -40,12 +41,10 @@ namespace osu.Game.Rulesets.Objects
/// <param name="position">The initial position.</param> /// <param name="position">The initial position.</param>
/// <param name="type">The initial type.</param> /// <param name="type">The initial type.</param>
public PathControlPoint(Vector2 position, PathType? type = null) public PathControlPoint(Vector2 position, PathType? type = null)
: this()
{ {
Position.Value = position; Position.Value = position;
Type.Value = type; Type.Value = type;
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;