mirror of
https://github.com/ppy/osu.git
synced 2026-05-22 04:09:54 +08:00
Move static instances / construction methods closer together
This commit is contained in:
@@ -16,11 +16,6 @@ namespace osu.Game.Rulesets.Objects.Types
|
||||
|
||||
public readonly struct PathType : IEquatable<PathType>, IHasDescription
|
||||
{
|
||||
public static readonly PathType CATMULL = new PathType(SplineType.Catmull);
|
||||
public static readonly PathType BEZIER = new PathType(SplineType.BSpline);
|
||||
public static readonly PathType LINEAR = new PathType(SplineType.Linear);
|
||||
public static readonly PathType PERFECT_CURVE = new PathType(SplineType.PerfectCurve);
|
||||
|
||||
/// <summary>
|
||||
/// The type of the spline that should be used to interpret the control points of the path.
|
||||
/// </summary>
|
||||
@@ -32,6 +27,25 @@ namespace osu.Game.Rulesets.Objects.Types
|
||||
/// </summary>
|
||||
public int? Degree { get; init; }
|
||||
|
||||
public PathType(SplineType splineType)
|
||||
{
|
||||
Type = splineType;
|
||||
Degree = null;
|
||||
}
|
||||
|
||||
public static readonly PathType CATMULL = new PathType(SplineType.Catmull);
|
||||
public static readonly PathType BEZIER = new PathType(SplineType.BSpline);
|
||||
public static readonly PathType LINEAR = new PathType(SplineType.Linear);
|
||||
public static readonly PathType PERFECT_CURVE = new PathType(SplineType.PerfectCurve);
|
||||
|
||||
public static PathType BSpline(int degree)
|
||||
{
|
||||
if (degree <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(degree), "The degree of a B-Spline path must be greater than zero.");
|
||||
|
||||
return new PathType { Type = SplineType.BSpline, Degree = degree };
|
||||
}
|
||||
|
||||
public string Description => Type switch
|
||||
{
|
||||
SplineType.Catmull => "Catmull",
|
||||
@@ -41,12 +55,6 @@ namespace osu.Game.Rulesets.Objects.Types
|
||||
_ => Type.ToString()
|
||||
};
|
||||
|
||||
public PathType(SplineType splineType)
|
||||
{
|
||||
Type = splineType;
|
||||
Degree = null;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
=> HashCode.Combine(Type, Degree);
|
||||
|
||||
@@ -59,14 +67,6 @@ namespace osu.Game.Rulesets.Objects.Types
|
||||
public static bool operator !=(PathType a, PathType b)
|
||||
=> a.Type != b.Type || a.Degree != b.Degree;
|
||||
|
||||
public static PathType BSpline(int degree)
|
||||
{
|
||||
if (degree <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(degree), "The degree of a B-Spline path must be greater than zero.");
|
||||
|
||||
return new PathType { Type = SplineType.BSpline, Degree = degree };
|
||||
}
|
||||
|
||||
public bool Equals(PathType other)
|
||||
=> Type == other.Type && Degree == other.Degree;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user