From b1d5f4edd9c0ddced9da02e36f38c0493cca9a8a Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Fri, 23 May 2014 13:49:12 +0100 Subject: [PATCH] Also implemented on the Bits struct. --- OpenRA.Game/Primitives/Bits.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/Primitives/Bits.cs b/OpenRA.Game/Primitives/Bits.cs index 1e1aa6794e..7b35e89590 100644 --- a/OpenRA.Game/Primitives/Bits.cs +++ b/OpenRA.Game/Primitives/Bits.cs @@ -48,7 +48,7 @@ namespace OpenRA.Primitives } } - public struct Bits where T : struct + public struct Bits : IEquatable> where T : struct { public int Value; @@ -60,6 +60,11 @@ namespace OpenRA.Primitives return BitAllocator.GetStrings(Value).JoinWith(","); } + public static bool operator ==(Bits me, Bits other) { return (me.Value == other.Value); } + public static bool operator !=(Bits me, Bits other) { return !(me == other); } + + public bool Equals(Bits other) { return other == this; } + public override bool Equals(object obj) { return obj is Bits && Equals((Bits)obj); } public override int GetHashCode() { return Value.GetHashCode(); } } }