File tree Expand file tree Collapse file tree 2 files changed +48
-2
lines changed
RhythmGameUtilities/Structs Expand file tree Collapse file tree 2 files changed +48
-2
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
1
2
using System . Runtime . InteropServices ;
2
3
3
4
namespace RhythmGameUtilities
4
5
{
5
6
6
7
[ StructLayout ( LayoutKind . Sequential ) ]
7
- public struct Note
8
+ public struct Note : IEquatable < Note >
8
9
{
9
10
10
11
public int Position ;
@@ -13,6 +14,28 @@ public struct Note
13
14
14
15
public int Length ;
15
16
17
+ public override int GetHashCode ( ) => ( Position , HandPosition , Length ) . GetHashCode ( ) ;
18
+
19
+ public bool Equals ( Note other )
20
+ {
21
+ return Position == other . Position && HandPosition == other . HandPosition && Length == other . Length ;
22
+ }
23
+
24
+ public override bool Equals ( object obj )
25
+ {
26
+ return obj is Note other && Equals ( other ) ;
27
+ }
28
+
29
+ public static bool operator == ( Note left , Note right )
30
+ {
31
+ return left . Equals ( right ) ;
32
+ }
33
+
34
+ public static bool operator != ( Note left , Note right )
35
+ {
36
+ return ! ( left == right ) ;
37
+ }
38
+
16
39
}
17
40
18
41
}
Original file line number Diff line number Diff line change
1
+ using System ;
1
2
using System . Runtime . InteropServices ;
2
3
3
4
namespace RhythmGameUtilities
4
5
{
5
6
6
7
[ StructLayout ( LayoutKind . Sequential ) ]
7
- public struct Note
8
+ public struct Note : IEquatable < Note >
8
9
{
9
10
10
11
public int Position ;
@@ -13,6 +14,28 @@ public struct Note
13
14
14
15
public int Length ;
15
16
17
+ public override int GetHashCode ( ) => ( Position , HandPosition , Length ) . GetHashCode ( ) ;
18
+
19
+ public bool Equals ( Note other )
20
+ {
21
+ return Position == other . Position && HandPosition == other . HandPosition && Length == other . Length ;
22
+ }
23
+
24
+ public override bool Equals ( object obj )
25
+ {
26
+ return obj is Note other && Equals ( other ) ;
27
+ }
28
+
29
+ public static bool operator == ( Note left , Note right )
30
+ {
31
+ return left . Equals ( right ) ;
32
+ }
33
+
34
+ public static bool operator != ( Note left , Note right )
35
+ {
36
+ return ! ( left == right ) ;
37
+ }
38
+
16
39
}
17
40
18
41
}
You can’t perform that action at this time.
0 commit comments