Bläddra i källkod

增加FrameMessage的operator重载

tanghai 2 år sedan
förälder
incheckning
71c655b418

+ 134 - 0
Unity/Assets/Scripts/Codes/Model/Share/LockStep/OneFrameMessage.cs

@@ -0,0 +1,134 @@
+using System;
+
+namespace ET
+{
+    public partial class FrameMessage
+    {
+        public bool Equals(FrameMessage other)
+        {
+            return this.PlayerId == other.PlayerId && this.Frame == other.Frame && this.V.Equals(other.V) && this.Button == other.Button;
+        }
+
+        public override bool Equals(object obj)
+        {
+            if (ReferenceEquals(null, obj))
+            {
+                return false;
+            }
+
+            if (ReferenceEquals(this, obj))
+            {
+                return true;
+            }
+
+            if (obj.GetType() != this.GetType())
+            {
+                return false;
+            }
+
+            return Equals((FrameMessage) obj);
+        }
+
+        public override int GetHashCode()
+        {
+            return HashCode.Combine(this.PlayerId, this.Frame, this.V, this.Button);
+        }
+
+        public static bool operator ==(FrameMessage a, FrameMessage b)
+        {
+            if (a.PlayerId != b.PlayerId)
+            {
+                return false;
+            }
+            
+            if (a.Frame != b.Frame)
+            {
+                return false;
+            }
+
+            if (a.V != b.V)
+            {
+                return false;
+            }
+
+            if (a.Button != b.Button)
+            {
+                return false;
+            }
+
+            return true;
+        }
+
+        public static bool operator !=(FrameMessage a, FrameMessage b)
+        {
+            return !(a == b);
+        }
+    }
+
+
+    public partial class OneFrameMessages
+    {
+        public bool Equals(OneFrameMessages other)
+        {
+            return this.Frame == other.Frame && Equals(this.Messages, other.Messages);
+        }
+
+        public override bool Equals(object obj)
+        {
+            if (ReferenceEquals(null, obj))
+            {
+                return false;
+            }
+
+            if (ReferenceEquals(this, obj))
+            {
+                return true;
+            }
+
+            if (obj.GetType() != this.GetType())
+            {
+                return false;
+            }
+
+            return Equals((OneFrameMessages) obj);
+        }
+
+        public override int GetHashCode()
+        {
+            return HashCode.Combine(this.Frame, this.Messages);
+        }
+
+        public static bool operator==(OneFrameMessages a, OneFrameMessages b)
+        {
+            if (a.Frame != b.Frame)
+            {
+                return false;
+            }
+
+            if (a.Messages.Count != b.Messages.Count)
+            {
+                return false;
+            }
+
+            foreach (var kv in a.Messages)
+            {
+                if (!b.Messages.TryGetValue(kv.Key, out FrameMessage frameMessage))
+                {
+                    return false;
+                }
+
+                if (kv.Value != frameMessage)
+                {
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
+        public static bool operator !=(OneFrameMessages a, OneFrameMessages b)
+        {
+            return !(a == b);
+        }
+    }
+}

+ 3 - 0
Unity/Assets/Scripts/Codes/Model/Share/LockStep/OneFrameMessage.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 4bdb7581d1bf417ebcb0a2d45ffad839
+timeCreated: 1681822483

+ 0 - 8
Unity/Assets/Scripts/Codes/Model/Share/Module/FixedUpdate.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 6cf74b61ee90c45e0b55fe74a712c9a3
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: