Implement IEquatable

This commit is contained in:
smoogipoo 2018-11-12 16:53:30 +09:00
parent 0220ed21b0
commit f4fd6189f8
1 changed files with 17 additions and 1 deletions

View File

@ -11,7 +11,7 @@
namespace osu.Game.Rulesets.Objects
{
public struct SliderPath
public struct SliderPath : IEquatable<SliderPath>
{
/// <summary>
/// The control points of the path.
@ -254,5 +254,21 @@ private Vector2 interpolateVertices(int i, double d)
double w = (d - d0) / (d1 - d0);
return p0 + (p1 - p0) * (float)w;
}
public bool Equals(SliderPath other)
{
if (ControlPoints == null && other.ControlPoints != null)
return false;
if (other.ControlPoints == null && ControlPoints != null)
return false;
return ControlPoints.SequenceEqual(other.ControlPoints) && ExpectedDistance.Equals(other.ExpectedDistance) && Type == other.Type;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is SliderPath other && Equals(other);
}
}
}