mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Implement IEquatable on ControlPoint
This commit is contained in:
@ -1,18 +1,16 @@
|
||||
// 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 System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
|
||||
namespace osu.Game.Beatmaps.ControlPoints
|
||||
{
|
||||
public class ControlPointGroup : IComparable<ControlPointGroup>
|
||||
public class ControlPointGroup : IComparable<ControlPointGroup>, IEquatable<ControlPointGroup>
|
||||
{
|
||||
public event Action<ControlPoint> ItemAdded;
|
||||
public event Action<ControlPoint> ItemRemoved;
|
||||
public event Action<ControlPoint>? ItemAdded;
|
||||
public event Action<ControlPoint>? ItemRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// The time at which the control point takes effect.
|
||||
@ -48,5 +46,23 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
controlPoints.Remove(point);
|
||||
ItemRemoved?.Invoke(point);
|
||||
}
|
||||
|
||||
public sealed override bool Equals(object? obj)
|
||||
=> obj is ControlPointGroup otherGroup
|
||||
&& Equals(otherGroup);
|
||||
|
||||
public virtual bool Equals(ControlPointGroup? other)
|
||||
=> other != null
|
||||
&& Time == other.Time
|
||||
&& ControlPoints.SequenceEqual(other.ControlPoints);
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
HashCode hashCode = new HashCode();
|
||||
hashCode.Add(Time);
|
||||
foreach (var point in controlPoints)
|
||||
hashCode.Add(point);
|
||||
return hashCode.ToHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user