tanghai 2 лет назад
Родитель
Сommit
601700de23
19 измененных файлов с 56 добавлено и 58 удалено
  1. 3 3
      Unity/Assets/Config/Proto/LockStepOuter_C_11001.proto
  2. 4 4
      Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/RoomClientUpdaterSystem.cs
  3. 2 2
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Room/ServerFrameRecvComponentSystem.cs
  4. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Share/LockStep/LSUnitFactory.cs
  5. 3 3
      Unity/Assets/Scripts/Codes/Hotfix/Share/LockStep/LSUnitInputComponentSystem.cs
  6. 4 4
      Unity/Assets/Scripts/Codes/Hotfix/Share/LockStep/RoomSystem.cs
  7. 1 1
      Unity/Assets/Scripts/Codes/HotfixView/Client/LockStep/LockStepOperaComponentSystem.cs
  8. 1 1
      Unity/Assets/Scripts/Codes/Model/Client/LockStep/RoomClientUpdater.cs
  9. 5 5
      Unity/Assets/Scripts/Codes/Model/Generate/Client/Message/LockStepOuter_C_11001.cs
  10. 5 5
      Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/LockStepOuter_C_11001.cs
  11. 5 5
      Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/LockStepOuter_C_11001.cs
  12. 5 5
      Unity/Assets/Scripts/Codes/Model/Share/LockStep/LSInput.cs
  13. 0 0
      Unity/Assets/Scripts/Codes/Model/Share/LockStep/LSInput.cs.meta
  14. 8 0
      Unity/Assets/Scripts/Codes/Model/Share/LockStep/LSInputComponent.cs
  15. 0 0
      Unity/Assets/Scripts/Codes/Model/Share/LockStep/LSInputComponent.cs.meta
  16. 0 8
      Unity/Assets/Scripts/Codes/Model/Share/LockStep/LSUnitInputComponent.cs
  17. 6 6
      Unity/Assets/Scripts/Codes/Model/Share/LockStep/OneFrameMessage.cs
  18. 1 1
      Unity/Assets/Scripts/Core/LockStep/LSEntity.cs
  19. 2 4
      Unity/Assets/Scripts/Core/LockStep/LSWorld.cs

+ 3 - 3
Unity/Assets/Config/Proto/LockStepOuter_C_11001.proto

@@ -42,7 +42,7 @@ message Room2C_Start // IActorMessage
 	repeated LockStepUnitInfo UnitInfo = 2;
 }
 
-message LSInputInfo
+message LSInput
 {
 	TrueSync.TSVector2 V = 1;
 	int32 Button = 2;
@@ -52,12 +52,12 @@ message FrameMessage // IActorMessage
 {
 	int32 Frame = 1;
 	int64 PlayerId = 2;
-	LSInputInfo InputInfo = 3;
+	LSInput Input = 3;
 }
 
 message OneFrameMessages // IActorMessage
 {
 	int32 Frame = 1;
-	map<int64, LSInputInfo> InputInfos = 2;
+	map<int64, LSInput> Inputs = 2;
 }
 

+ 4 - 4
Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/RoomClientUpdaterSystem.cs

@@ -60,11 +60,11 @@ namespace ET.Client
             PlayerComponent playerComponent = clientScene.GetComponent<PlayerComponent>();
             long myId = playerComponent.MyId;
 
-            FrameMessage frameMessage = new() { InputInfo = new LSInputInfo(), Frame = frame };
-            frameMessage.InputInfo.V = self.InputInfo.V;
-            frameMessage.InputInfo.Button = self.InputInfo.Button;
+            FrameMessage frameMessage = new() { Input = new LSInput(), Frame = frame };
+            frameMessage.Input.V = self.Input.V;
+            frameMessage.Input.Button = self.Input.Button;
 
-            predictionFrame.InputInfos[myId] = frameMessage.InputInfo;
+            predictionFrame.Inputs[myId] = frameMessage.Input;
             
             room.FrameBuffer.AddFrame(predictionFrame);
             

+ 2 - 2
Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Room/ServerFrameRecvComponentSystem.cs

@@ -23,14 +23,14 @@ namespace ET.Server
                 self.FrameMessages.Add(oneFrameMessages.Frame, oneFrameMessages);
             }
 
-            oneFrameMessages.InputInfos[message.PlayerId] = message.InputInfo;
+            oneFrameMessages.Inputs[message.PlayerId] = message.Input;
 
             if (oneFrameMessages.Frame > self.NowFrame)
             {
                 return null;   
             }
 
-            if (oneFrameMessages.InputInfos.Count != LSConstValue.MatchCount)
+            if (oneFrameMessages.Inputs.Count != LSConstValue.MatchCount)
             {
                 return null;
             }

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Share/LockStep/LSUnitFactory.cs

@@ -10,7 +10,7 @@
 	        lsUnit.Position = unitInfo.Position;
 	        lsUnit.Rotation = unitInfo.Rotation;
 
-			lsUnit.AddComponent<LSUnitInputComponent>();
+			lsUnit.AddComponent<LSInputComponent>();
 	        
 	        EventSystem.Instance.Publish(lsUnit.DomainScene(), new EventType.LSAfterUnitCreate() {LsUnit = lsUnit});
             return lsUnit;

+ 3 - 3
Unity/Assets/Scripts/Codes/Hotfix/Share/LockStep/LSUnitInputComponentSystem.cs

@@ -6,13 +6,13 @@ namespace ET
     public static class LSUnitInputComponentSystem
     {
         [ObjectSystem]
-        public class LSUpdateSystem: LSUpdateSystem<LSUnitInputComponent>
+        public class LSUpdateSystem: LSUpdateSystem<LSInputComponent>
         {
-            protected override void LSUpdate(LSUnitInputComponent self)
+            protected override void LSUpdate(LSInputComponent self)
             {
                 LSUnit unit = self.GetParent<LSUnit>();
 
-                TSVector2 v2 = self.LSInputInfo.V * 6 * 50 / 1000;
+                TSVector2 v2 = self.LSInput.V * 6 * 50 / 1000;
                 unit.Position += new TSVector(v2.x, 0, v2.y);
             }
         }

+ 4 - 4
Unity/Assets/Scripts/Codes/Hotfix/Share/LockStep/RoomSystem.cs

@@ -23,12 +23,12 @@ namespace ET
             // 设置输入到每个LSUnit身上
             LSWorld lsWorld = self.LSWorld;
             LSUnitComponent unitComponent = lsWorld.GetComponent<LSUnitComponent>();
-            foreach (var kv in oneFrameMessages.InputInfos)
+            foreach (var kv in oneFrameMessages.Inputs)
             {
                 LSUnit lsUnit = unitComponent.GetChild<LSUnit>(kv.Key);
-                LSInputInfo lsInputInfo = lsUnit.GetComponent<LSUnitInputComponent>().LSInputInfo;
-                lsInputInfo.V = kv.Value.V;
-                lsInputInfo.Button = kv.Value.Button;
+                LSInput lsInput = lsUnit.GetComponent<LSInputComponent>().LSInput;
+                lsInput.V = kv.Value.V;
+                lsInput.Button = kv.Value.Button;
             }
             
             lsWorld.Updater.Update();

+ 1 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/LockStep/LockStepOperaComponentSystem.cs

@@ -33,7 +33,7 @@ namespace ET.Client
                 }
 
                 RoomClientUpdater roomClientUpdater = self.GetParent<Room>().GetComponent<RoomClientUpdater>();
-                roomClientUpdater.InputInfo.V = v;
+                roomClientUpdater.Input.V = v;
             }
         }
     }

+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Client/LockStep/RoomClientUpdater.cs

@@ -5,6 +5,6 @@ namespace ET.Client
     [ComponentOf(typeof(Room))]
     public class RoomClientUpdater: Entity, IAwake, IUpdate
     {
-        public LSInputInfo InputInfo = new LSInputInfo();
+        public LSInput Input = new();
     }
 }

+ 5 - 5
Unity/Assets/Scripts/Codes/Model/Generate/Client/Message/LockStepOuter_C_11001.cs

@@ -80,9 +80,9 @@ namespace ET
 
 	}
 
-	[Message(LockStepOuter.LSInputInfo)]
+	[Message(LockStepOuter.LSInput)]
 	[ProtoContract]
-	public partial class LSInputInfo: ProtoObject
+	public partial class LSInput: ProtoObject
 	{
 		[ProtoMember(1)]
 		public TrueSync.TSVector2 V { get; set; }
@@ -103,7 +103,7 @@ namespace ET
 		public long PlayerId { get; set; }
 
 		[ProtoMember(3)]
-		public LSInputInfo InputInfo { get; set; }
+		public LSInput Input { get; set; }
 
 	}
 
@@ -116,7 +116,7 @@ namespace ET
 
 		[MongoDB.Bson.Serialization.Attributes.BsonDictionaryOptions(MongoDB.Bson.Serialization.Options.DictionaryRepresentation.ArrayOfArrays)]
 		[ProtoMember(2)]
-		public Dictionary<long, LSInputInfo> InputInfos { get; set; }
+		public Dictionary<long, LSInput> Inputs { get; set; }
 	}
 
 	public static class LockStepOuter
@@ -127,7 +127,7 @@ namespace ET
 		 public const ushort C2Room_ChangeSceneFinish = 11005;
 		 public const ushort LockStepUnitInfo = 11006;
 		 public const ushort Room2C_Start = 11007;
-		 public const ushort LSInputInfo = 11008;
+		 public const ushort LSInput = 11008;
 		 public const ushort FrameMessage = 11009;
 		 public const ushort OneFrameMessages = 11010;
 	}

+ 5 - 5
Unity/Assets/Scripts/Codes/Model/Generate/ClientServer/Message/LockStepOuter_C_11001.cs

@@ -80,9 +80,9 @@ namespace ET
 
 	}
 
-	[Message(LockStepOuter.LSInputInfo)]
+	[Message(LockStepOuter.LSInput)]
 	[ProtoContract]
-	public partial class LSInputInfo: ProtoObject
+	public partial class LSInput: ProtoObject
 	{
 		[ProtoMember(1)]
 		public TrueSync.TSVector2 V { get; set; }
@@ -103,7 +103,7 @@ namespace ET
 		public long PlayerId { get; set; }
 
 		[ProtoMember(3)]
-		public LSInputInfo InputInfo { get; set; }
+		public LSInput Input { get; set; }
 
 	}
 
@@ -116,7 +116,7 @@ namespace ET
 
 		[MongoDB.Bson.Serialization.Attributes.BsonDictionaryOptions(MongoDB.Bson.Serialization.Options.DictionaryRepresentation.ArrayOfArrays)]
 		[ProtoMember(2)]
-		public Dictionary<long, LSInputInfo> InputInfos { get; set; }
+		public Dictionary<long, LSInput> Inputs { get; set; }
 	}
 
 	public static class LockStepOuter
@@ -127,7 +127,7 @@ namespace ET
 		 public const ushort C2Room_ChangeSceneFinish = 11005;
 		 public const ushort LockStepUnitInfo = 11006;
 		 public const ushort Room2C_Start = 11007;
-		 public const ushort LSInputInfo = 11008;
+		 public const ushort LSInput = 11008;
 		 public const ushort FrameMessage = 11009;
 		 public const ushort OneFrameMessages = 11010;
 	}

+ 5 - 5
Unity/Assets/Scripts/Codes/Model/Generate/Server/Message/LockStepOuter_C_11001.cs

@@ -80,9 +80,9 @@ namespace ET
 
 	}
 
-	[Message(LockStepOuter.LSInputInfo)]
+	[Message(LockStepOuter.LSInput)]
 	[ProtoContract]
-	public partial class LSInputInfo: ProtoObject
+	public partial class LSInput: ProtoObject
 	{
 		[ProtoMember(1)]
 		public TrueSync.TSVector2 V { get; set; }
@@ -103,7 +103,7 @@ namespace ET
 		public long PlayerId { get; set; }
 
 		[ProtoMember(3)]
-		public LSInputInfo InputInfo { get; set; }
+		public LSInput Input { get; set; }
 
 	}
 
@@ -116,7 +116,7 @@ namespace ET
 
 		[MongoDB.Bson.Serialization.Attributes.BsonDictionaryOptions(MongoDB.Bson.Serialization.Options.DictionaryRepresentation.ArrayOfArrays)]
 		[ProtoMember(2)]
-		public Dictionary<long, LSInputInfo> InputInfos { get; set; }
+		public Dictionary<long, LSInput> Inputs { get; set; }
 	}
 
 	public static class LockStepOuter
@@ -127,7 +127,7 @@ namespace ET
 		 public const ushort C2Room_ChangeSceneFinish = 11005;
 		 public const ushort LockStepUnitInfo = 11006;
 		 public const ushort Room2C_Start = 11007;
-		 public const ushort LSInputInfo = 11008;
+		 public const ushort LSInput = 11008;
 		 public const ushort FrameMessage = 11009;
 		 public const ushort OneFrameMessages = 11010;
 	}

+ 5 - 5
Unity/Assets/Scripts/Codes/Model/Share/LockStep/LSInputInfo.cs → Unity/Assets/Scripts/Codes/Model/Share/LockStep/LSInput.cs

@@ -3,9 +3,9 @@ using TrueSync;
 
 namespace ET
 {
-    public partial class LSInputInfo
+    public partial class LSInput
     {
-        protected bool Equals(LSInputInfo other)
+        protected bool Equals(LSInput other)
         {
             return this.V.Equals(other.V) && this.Button == other.Button;
         }
@@ -27,7 +27,7 @@ namespace ET
                 return false;
             }
 
-            return Equals((LSInputInfo) obj);
+            return Equals((LSInput) obj);
         }
 
         public override int GetHashCode()
@@ -35,7 +35,7 @@ namespace ET
             return HashCode.Combine(this.V, this.Button);
         }
 
-        public static bool operator==(LSInputInfo a, LSInputInfo b)
+        public static bool operator==(LSInput a, LSInput b)
         {
             if (a.V != b.V)
             {
@@ -50,7 +50,7 @@ namespace ET
             return true;
         }
 
-        public static bool operator !=(LSInputInfo a, LSInputInfo b)
+        public static bool operator !=(LSInput a, LSInput b)
         {
             return !(a == b);
         }

+ 0 - 0
Unity/Assets/Scripts/Codes/Model/Share/LockStep/LSInputInfo.cs.meta → Unity/Assets/Scripts/Codes/Model/Share/LockStep/LSInput.cs.meta


+ 8 - 0
Unity/Assets/Scripts/Codes/Model/Share/LockStep/LSInputComponent.cs

@@ -0,0 +1,8 @@
+namespace ET
+{
+    public class LSInputComponent: LSEntity, ILSUpdate, IAwake
+    {
+        public LSInput LSInput { get; set; } = new LSInput();
+
+    }
+}

+ 0 - 0
Unity/Assets/Scripts/Codes/Model/Share/LockStep/LSUnitInputComponent.cs.meta → Unity/Assets/Scripts/Codes/Model/Share/LockStep/LSInputComponent.cs.meta


+ 0 - 8
Unity/Assets/Scripts/Codes/Model/Share/LockStep/LSUnitInputComponent.cs

@@ -1,8 +0,0 @@
-namespace ET
-{
-    public class LSUnitInputComponent: LSEntity, ILSUpdate, IAwake
-    {
-        public LSInputInfo LSInputInfo { get; set; } = new LSInputInfo();
-
-    }
-}

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

@@ -7,7 +7,7 @@ namespace ET
     {
         protected bool Equals(OneFrameMessages other)
         {
-            return this.Frame == other.Frame && Equals(this.InputInfos, other.InputInfos);
+            return this.Frame == other.Frame && Equals(this.Inputs, other.Inputs);
         }
 
         public override bool Equals(object obj)
@@ -32,12 +32,12 @@ namespace ET
 
         public override int GetHashCode()
         {
-            return HashCode.Combine(this.Frame, this.InputInfos);
+            return HashCode.Combine(this.Frame, this.Inputs);
         }
 
         public OneFrameMessages()
         {
-            this.InputInfos = new Dictionary<long, LSInputInfo>(LSConstValue.MatchCount);
+            this.Inputs = new Dictionary<long, LSInput>(LSConstValue.MatchCount);
         }
 
         public static bool operator==(OneFrameMessages a, OneFrameMessages b)
@@ -56,14 +56,14 @@ namespace ET
                 return false;
             }
 
-            if (a.InputInfos.Count != b.InputInfos.Count)
+            if (a.Inputs.Count != b.Inputs.Count)
             {
                 return false;
             }
 
-            foreach (var kv in a.InputInfos)
+            foreach (var kv in a.Inputs)
             {
-                if (!b.InputInfos.TryGetValue(kv.Key, out LSInputInfo inputInfo))
+                if (!b.Inputs.TryGetValue(kv.Key, out LSInput inputInfo))
                 {
                     return false;
                 }

+ 1 - 1
Unity/Assets/Scripts/Core/LockStep/LSEntity.cs

@@ -62,7 +62,7 @@ namespace ET
 
                 if (newIsRegister)
                 {
-                    this.DomainScene().RegisterSystem(this);
+                    this.DomainScene().Add(this);
                 }
                 else
                 {

+ 2 - 4
Unity/Assets/Scripts/Core/LockStep/LSWorld.cs

@@ -75,13 +75,11 @@ namespace ET
             this.allLSEntities.Remove(id);
         }
 
-        public void RegisterSystem(LSEntity entity) 
+        public void Add(LSEntity entity) 
         {
             this.allLSEntities.Add(entity.Id, entity);
 
-            Type type = entity.GetType();
-
-            TypeSystems.OneTypeSystems oneTypeSystems = LSSington.Instance.GetOneTypeSystems(type);
+            TypeSystems.OneTypeSystems oneTypeSystems = LSSington.Instance.GetOneTypeSystems(entity.GetType());
             if (oneTypeSystems == null)
             {
                 return;