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.Audio;
using osu.Game.Graphics;
@ -13,7 +12,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 SampleControlPoint : ControlPoint
public class SampleControlPoint : ControlPoint, IEquatable<SampleControlPoint>
{
public const string DEFAULT_BANK = "normal";
@ -85,5 +84,16 @@ namespace osu.Game.Beatmaps.ControlPoints
base.CopyFrom(other);
}
public override bool Equals(ControlPoint? other)
=> other is SampleControlPoint otherSampleControlPoint
&& Equals(otherSampleControlPoint);
public bool Equals(SampleControlPoint? other)
=> base.Equals(other)
&& SampleBank == other.SampleBank
&& SampleVolume == other.SampleVolume;
public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), SampleBank, SampleVolume);
}
}