diff --git a/RhythmGameUtilities/Structs/Note.cs b/RhythmGameUtilities/Structs/Note.cs index 9257628..a1d4f15 100644 --- a/RhythmGameUtilities/Structs/Note.cs +++ b/RhythmGameUtilities/Structs/Note.cs @@ -1,10 +1,11 @@ +using System; using System.Runtime.InteropServices; namespace RhythmGameUtilities { [StructLayout(LayoutKind.Sequential)] - public struct Note + public struct Note : IEquatable { public int Position; @@ -13,6 +14,28 @@ public struct Note public int Length; + public override int GetHashCode() => (Position, HandPosition, Length).GetHashCode(); + + public bool Equals(Note other) + { + return Position == other.Position && HandPosition == other.HandPosition && Length == other.Length; + } + + public override bool Equals(object obj) + { + return obj is Note other && Equals(other); + } + + public static bool operator ==(Note left, Note right) + { + return left.Equals(right); + } + + public static bool operator !=(Note left, Note right) + { + return !(left == right); + } + } } diff --git a/UnityPackage/Structs/Note.cs b/UnityPackage/Structs/Note.cs index 9257628..a1d4f15 100644 --- a/UnityPackage/Structs/Note.cs +++ b/UnityPackage/Structs/Note.cs @@ -1,10 +1,11 @@ +using System; using System.Runtime.InteropServices; namespace RhythmGameUtilities { [StructLayout(LayoutKind.Sequential)] - public struct Note + public struct Note : IEquatable { public int Position; @@ -13,6 +14,28 @@ public struct Note public int Length; + public override int GetHashCode() => (Position, HandPosition, Length).GetHashCode(); + + public bool Equals(Note other) + { + return Position == other.Position && HandPosition == other.HandPosition && Length == other.Length; + } + + public override bool Equals(object obj) + { + return obj is Note other && Equals(other); + } + + public static bool operator ==(Note left, Note right) + { + return left.Equals(right); + } + + public static bool operator !=(Note left, Note right) + { + return !(left == right); + } + } }