Implement IEquatable on ControlPoint

This commit is contained in:
Dan Balasescu
2022-06-20 14:56:04 +09:00
parent 468e5fcbed
commit 03ab6fc141
7 changed files with 109 additions and 22 deletions

View File

@ -1,8 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using System;
using osu.Framework.Bindables;
using osu.Game.Graphics;
using osuTK.Graphics;
@ -12,7 +11,7 @@ namespace osu.Game.Beatmaps.ControlPoints
/// <remarks>
/// Note that going forward, this control point type should always be assigned directly to HitObjects.
/// </remarks>
public class DifficultyControlPoint : ControlPoint
public class DifficultyControlPoint : ControlPoint, IEquatable<DifficultyControlPoint>
{
public static readonly DifficultyControlPoint DEFAULT = new DifficultyControlPoint
{
@ -51,5 +50,15 @@ namespace osu.Game.Beatmaps.ControlPoints
base.CopyFrom(other);
}
public override bool Equals(ControlPoint? other)
=> other is DifficultyControlPoint otherDifficultyControlPoint
&& Equals(otherDifficultyControlPoint);
public bool Equals(DifficultyControlPoint? other)
=> base.Equals(other)
&& SliderVelocity == other.SliderVelocity;
public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), SliderVelocity);
}
}