1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 01:02:56 +08:00

Implement IEquatable

This commit is contained in:
smoogipoo 2018-11-12 16:53:30 +09:00
parent 0220ed21b0
commit f4fd6189f8

View File

@ -11,7 +11,7 @@ using OpenTK;
namespace osu.Game.Rulesets.Objects
{
public struct SliderPath
public struct SliderPath : IEquatable<SliderPath>
{
/// <summary>
/// The control points of the path.
@ -254,5 +254,21 @@ namespace osu.Game.Rulesets.Objects
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);
}
}
}