Browse Source

消息还是去掉Source Generator

tanghai 2 năm trước cách đây
mục cha
commit
6e70d6ee67
43 tập tin đã thay đổi với 172 bổ sung165 xóa
  1. 12 0
      Share/Share.SourceGenerator/Generator/ETSystemGenerator/AttributeTemplate.cs
  2. 0 2
      Share/Share.SourceGenerator/Generator/ETSystemGenerator/ETSystemGenerator.cs
  3. 1 1
      Unity/Assets/Scripts/Core/Module/EventSystem/BaseAttribute.cs
  4. 1 0
      Unity/Assets/Scripts/Core/Module/EventSystem/EntitySystemAttribute.cs
  5. 0 1
      Unity/Assets/Scripts/Core/Module/EventSystem/EventAttribute.cs
  6. 4 6
      Unity/Assets/Scripts/Hotfix/Client/Demo/Move/M2C_PathfindingResultHandler.cs
  7. 3 4
      Unity/Assets/Scripts/Hotfix/Client/Demo/Move/M2C_StopHandler.cs
  8. 3 3
      Unity/Assets/Scripts/Hotfix/Client/Demo/Scene/M2C_StartSceneChangeHandler.cs
  9. 3 3
      Unity/Assets/Scripts/Hotfix/Client/Demo/Unit/M2C_CreateMyUnitHandler.cs
  10. 3 3
      Unity/Assets/Scripts/Hotfix/Client/Demo/Unit/M2C_CreateUnitsHandler.cs
  11. 3 3
      Unity/Assets/Scripts/Hotfix/Client/Demo/Unit/M2C_RemoveUnitsHandler.cs
  12. 3 3
      Unity/Assets/Scripts/Hotfix/Client/LockStep/G2C_ChangeSceneHandler.cs
  13. 3 3
      Unity/Assets/Scripts/Hotfix/Client/LockStep/G2C_ReconnectHandler.cs
  14. 3 3
      Unity/Assets/Scripts/Hotfix/Client/LockStep/OneFrameInputsHandler.cs
  15. 3 3
      Unity/Assets/Scripts/Hotfix/Client/LockStep/Room2C_AdjustUpdateTimeHandler.cs
  16. 3 3
      Unity/Assets/Scripts/Hotfix/Client/LockStep/Room2C_CheckHashFailHandler.cs
  17. 3 3
      Unity/Assets/Scripts/Hotfix/Client/LockStep/Room2C_EnterMapHandler.cs
  18. 4 4
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Benchmark/C2G_BenchmarkHandler.cs
  19. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Gate/C2G_EnterMapHandler.cs
  20. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Gate/C2G_LoginGateHandler.cs
  21. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Gate/C2G_PingHandler.cs
  22. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Gate/R2G_GetLoginKeyHandler.cs
  23. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/C2M_TestRobotCaseHandler.cs
  24. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/G2M_SessionDisconnectHandler.cs
  25. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/Move/C2M_PathfindingResultHandler.cs
  26. 9 9
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/Move/C2M_StopHandler.cs
  27. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/Transfer/C2M_TransferMapHandler.cs
  28. 39 39
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/Transfer/M2M_UnitTransferRequestHandler.cs
  29. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Realm/C2R_LoginHandler.cs
  30. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Robot/Case/RobotCase_SecondCase.cs
  31. 3 3
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Gate/C2G_MatchHandler.cs
  32. 3 3
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Gate/Match2G_NotifyMatchSuccessHandler.cs
  33. 3 3
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Map/C2Room_ChangeSceneFinishHandler.cs
  34. 3 3
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Map/FrameMessageHandler.cs
  35. 3 3
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Map/Match2Map_GetRoomHandler.cs
  36. 3 3
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Match/G2Match_MatchHandler.cs
  37. 3 3
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Room/C2Room_CheckHashHandler.cs
  38. 3 3
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Room/G2Room_ReconnectHandler.cs
  39. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ObjectAddRequestHandler.cs
  40. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ObjectGetRequestHandler.cs
  41. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ObjectLockRequestHandler.cs
  42. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ObjectRemoveRequestHandler.cs
  43. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ObjectUnLockRequestHandler.cs

+ 12 - 0
Share/Share.SourceGenerator/Generator/ETSystemGenerator/AttributeTemplate.cs

@@ -57,6 +57,18 @@ namespace ET.Generator
                             }
                         }
                 """);
+            
+            this.templates.Add("Event", 
+                $$"""
+                $attribute$
+                        public class $argsTypes2$_$methodName$: AEvent<$argsTypes$>
+                        {
+                            protected override async ETTask Run($argsTypesVars$)
+                            {
+                                await $className$.$methodName$($argsVars$);
+                            }
+                        }
+                """);
         }
 
         public string Get(string attributeType)

+ 0 - 2
Share/Share.SourceGenerator/Generator/ETSystemGenerator/ETSystemGenerator.cs

@@ -1,7 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 using ET.Analyzer;
 using Microsoft.CodeAnalysis;
 using Microsoft.CodeAnalysis.CSharp.Syntax;

+ 1 - 1
Unity/Assets/Scripts/Core/Module/EventSystem/BaseAttribute.cs

@@ -2,7 +2,7 @@
 
 namespace ET
 {
-	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
+	[AttributeUsage(AttributeTargets.Class)]
 	public class BaseAttribute: Attribute
 	{
 	}

+ 1 - 0
Unity/Assets/Scripts/Core/Module/EventSystem/EntitySystemAttribute.cs

@@ -6,6 +6,7 @@ namespace ET
 	{
 	}
 	
+	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
 	public class EntitySystemAttribute: SystemAttribute
 	{
 	}

+ 0 - 1
Unity/Assets/Scripts/Core/Module/EventSystem/EventAttribute.cs

@@ -2,7 +2,6 @@
 
 namespace ET
 {
-	[AttributeUsage(AttributeTargets.Class)]
 	public class EventAttribute: BaseAttribute
 	{
 		public SceneType SceneType { get; }

+ 4 - 6
Unity/Assets/Scripts/Hotfix/Client/Demo/Move/M2C_PathfindingResultHandler.cs

@@ -1,11 +1,9 @@
-
-
-namespace ET.Client
+namespace ET.Client
 {
-	public static partial class M2C_PathfindingResultHandler
+	[MessageHandler(SceneType.Demo)]
+	public class M2C_PathfindingResultHandler : MessageHandler<M2C_PathfindingResult>
 	{
-		[MessageHandler(SceneType.Demo)]
-		private static async ETTask Run(Session session, M2C_PathfindingResult message)
+		protected override async ETTask Run(Session session, M2C_PathfindingResult message)
 		{
 			Unit unit = session.DomainScene().CurrentScene().GetComponent<UnitComponent>().Get(message.Id);
 

+ 3 - 4
Unity/Assets/Scripts/Hotfix/Client/Demo/Move/M2C_StopHandler.cs

@@ -2,11 +2,10 @@
 
 namespace ET.Client
 {
-	
-	public static partial class M2C_StopHandler
+	[MessageHandler(SceneType.Demo)]
+	public class M2C_StopHandler : MessageHandler<M2C_Stop>
 	{
-		[MessageHandler(SceneType.Demo)]
-		private static async ETTask Run(Session session, M2C_Stop message)
+		protected override async ETTask Run(Session session, M2C_Stop message)
 		{
 			Unit unit = session.DomainScene().CurrentScene().GetComponent<UnitComponent>().Get(message.Id);
 			if (unit == null)

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Client/Demo/Scene/M2C_StartSceneChangeHandler.cs

@@ -1,9 +1,9 @@
 namespace ET.Client
 {
-	public static partial class M2C_StartSceneChangeHandler
+	[MessageHandler(SceneType.Demo)]
+	public class M2C_StartSceneChangeHandler : MessageHandler<M2C_StartSceneChange>
 	{
-		[MessageHandler(SceneType.Demo)]
-		private static async ETTask Run(Session session, M2C_StartSceneChange message)
+		protected override async ETTask Run(Session session, M2C_StartSceneChange message)
 		{
 			await SceneChangeHelper.SceneChangeTo(session.ClientScene(), message.SceneName, message.SceneInstanceId);
 		}

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Client/Demo/Unit/M2C_CreateMyUnitHandler.cs

@@ -1,9 +1,9 @@
 namespace ET.Client
 {
-	public static partial class M2C_CreateMyUnitHandler
+	[MessageHandler(SceneType.Demo)]
+	public class M2C_CreateMyUnitHandler : MessageHandler<M2C_CreateMyUnit>
 	{
-		[MessageHandler(SceneType.Demo)]
-		private static async ETTask Run(Session session, M2C_CreateMyUnit message)
+		protected override async ETTask Run(Session session, M2C_CreateMyUnit message)
 		{
 			// 通知场景切换协程继续往下走
 			session.DomainScene().GetComponent<ObjectWait>().Notify(new Wait_CreateMyUnit() {Message = message});

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Client/Demo/Unit/M2C_CreateUnitsHandler.cs

@@ -1,9 +1,9 @@
 namespace ET.Client
 {
-	public static partial class M2C_CreateUnitsHandler
+	[MessageHandler(SceneType.Demo)]
+	public class M2C_CreateUnitsHandler : MessageHandler<M2C_CreateUnits>
 	{
-		[MessageHandler(SceneType.Demo)]
-		private static async ETTask Run(Session session, M2C_CreateUnits message)
+		protected override async ETTask Run(Session session, M2C_CreateUnits message)
 		{
 			Scene currentScene = session.DomainScene().CurrentScene();
 			UnitComponent unitComponent = currentScene.GetComponent<UnitComponent>();

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Client/Demo/Unit/M2C_RemoveUnitsHandler.cs

@@ -1,9 +1,9 @@
 namespace ET.Client
 {
-	public static partial class M2C_RemoveUnitsHandler
+	[MessageHandler(SceneType.Demo)]
+	public class M2C_RemoveUnitsHandler : MessageHandler<M2C_RemoveUnits>
 	{
-		[MessageHandler(SceneType.Demo)]
-		private static async ETTask Run(Session session, M2C_RemoveUnits message)
+		protected override async ETTask Run(Session session, M2C_RemoveUnits message)
 		{	
 			UnitComponent unitComponent = session.DomainScene().CurrentScene()?.GetComponent<UnitComponent>();
 			if (unitComponent == null)

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Client/LockStep/G2C_ChangeSceneHandler.cs

@@ -1,9 +1,9 @@
 namespace ET.Client
 {
-    public static partial class Match2G_NotifyMatchSuccessHandler
+    [MessageHandler(SceneType.LockStep)]
+    public class Match2G_NotifyMatchSuccessHandler: MessageHandler<Match2G_NotifyMatchSuccess>
     {
-        [MessageHandler(SceneType.LockStep)]
-        private static async ETTask Run(Session session, Match2G_NotifyMatchSuccess message)
+        protected override async ETTask Run(Session session, Match2G_NotifyMatchSuccess message)
         {
             await LSSceneChangeHelper.SceneChangeTo(session.DomainScene(), "Map1", message.InstanceId);
         }

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Client/LockStep/G2C_ReconnectHandler.cs

@@ -1,9 +1,9 @@
 namespace ET.Client
 {
-    public static partial class G2C_ReconnectHandler
+    [MessageHandler(SceneType.LockStep)]
+    public class G2C_ReconnectHandler: MessageHandler<G2C_Reconnect>
     {
-        [MessageHandler(SceneType.LockStep)]
-        private static async ETTask Run(Session session, G2C_Reconnect message)
+        protected override async ETTask Run(Session session, G2C_Reconnect message)
         {
             await LSSceneChangeHelper.SceneChangeToReconnect(session.ClientScene(), message);
             await ETTask.CompletedTask;

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Client/LockStep/OneFrameInputsHandler.cs

@@ -2,10 +2,10 @@ using System;
 
 namespace ET.Client
 {
-    public static partial class OneFrameInputsHandler
+    [MessageHandler(SceneType.LockStep)]
+    public class OneFrameInputsHandler: MessageHandler<OneFrameInputs>
     {
-        [MessageHandler(SceneType.LockStep)]
-        private static async ETTask Run(Session session, OneFrameInputs input)
+        protected override async ETTask Run(Session session, OneFrameInputs input)
         {
             Room room = session.DomainScene().GetComponent<Room>();
             

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Client/LockStep/Room2C_AdjustUpdateTimeHandler.cs

@@ -1,9 +1,9 @@
 namespace ET.Client
 {
-    public static partial class Room2C_AdjustUpdateTimeHandler
+    [MessageHandler(SceneType.LockStep)]
+    public class Room2C_AdjustUpdateTimeHandler: MessageHandler<Room2C_AdjustUpdateTime>
     {
-        [MessageHandler(SceneType.LockStep)]
-        private static async ETTask Run(Session session, Room2C_AdjustUpdateTime message)
+        protected override async ETTask Run(Session session, Room2C_AdjustUpdateTime message)
         {
             Room room = session.DomainScene().GetComponent<Room>();
             int newInterval = (1000 + (message.DiffTime - LSConstValue.UpdateInterval)) * LSConstValue.UpdateInterval / 1000;

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Client/LockStep/Room2C_CheckHashFailHandler.cs

@@ -1,9 +1,9 @@
 namespace ET.Client
 {
-    public static partial class Room2C_CheckHashFailHandler
+    [MessageHandler(SceneType.LockStep)]
+    public class Room2C_CheckHashFailHandler: MessageHandler<Room2C_CheckHashFail>
     {
-        [MessageHandler(SceneType.LockStep)]
-        private static async ETTask Run(Session session, Room2C_CheckHashFail message)
+        protected override async ETTask Run(Session session, Room2C_CheckHashFail message)
         {
             LSWorld serverWorld = MongoHelper.Deserialize(typeof(LSWorld), message.LSWorldBytes, 0, message.LSWorldBytes.Length) as LSWorld;
             using (session.ClientScene().AddChild(serverWorld))

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Client/LockStep/Room2C_EnterMapHandler.cs

@@ -1,9 +1,9 @@
 namespace ET.Client
 {
-    public static partial class Room2C_EnterMapHandler
+    [MessageHandler(SceneType.LockStep)]
+    public class Room2C_EnterMapHandler: MessageHandler<Room2C_Start>
     {
-        [MessageHandler(SceneType.LockStep)]
-        private static async ETTask Run(Session session, Room2C_Start message)
+        protected override async ETTask Run(Session session, Room2C_Start message)
         {
             session.DomainScene().GetComponent<ObjectWait>().Notify(new WaitType.Wait_Room2C_Start() {Message = message});
             await ETTask.CompletedTask;

+ 4 - 4
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Benchmark/C2G_BenchmarkHandler.cs

@@ -2,11 +2,11 @@
 
 namespace ET.Server
 {
-    public static partial class C2G_BenchmarkHandler
+    [MessageHandler(SceneType.BenchmarkServer)]
+    public class C2G_BenchmarkHandler: MessageHandler<C2G_Benchmark, G2C_Benchmark>
     {
-        [MessageHandler(SceneType.BenchmarkServer)]
-        private static async ETTask Run(Session session, C2G_Benchmark request, G2C_Benchmark response)
-        {
+        protected override async ETTask Run(Session session, C2G_Benchmark request, G2C_Benchmark response)
+        {            
             BenchmarkServerComponent benchmarkServerComponent = session.DomainScene().GetComponent<BenchmarkServerComponent>();
             if (benchmarkServerComponent.Count++ % 1000000 == 0)
             {

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Gate/C2G_EnterMapHandler.cs

@@ -1,9 +1,9 @@
 namespace ET.Server
 {
-	public static partial class C2G_EnterMapHandler
+	[MessageHandler(SceneType.Gate)]
+	public class C2G_EnterMapHandler : MessageHandler<C2G_EnterMap, G2C_EnterMap>
 	{
-		[MessageHandler(SceneType.Gate)]
-		private static async ETTask Run(Session session, C2G_EnterMap request, G2C_EnterMap response)
+		protected override async ETTask Run(Session session, C2G_EnterMap request, G2C_EnterMap response)
 		{
 			Player player = session.GetComponent<SessionPlayerComponent>().Player;
 

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Gate/C2G_LoginGateHandler.cs

@@ -3,10 +3,10 @@
 
 namespace ET.Server
 {
-    public static partial class C2G_LoginGateHandler
+    [MessageHandler(SceneType.Gate)]
+    public class C2G_LoginGateHandler : MessageHandler<C2G_LoginGate, G2C_LoginGate>
     {
-        [MessageHandler(SceneType.Gate)]
-        private static async ETTask Run(Session session, C2G_LoginGate request, G2C_LoginGate response)
+        protected override async ETTask Run(Session session, C2G_LoginGate request, G2C_LoginGate response)
         {
             Scene scene = session.DomainScene();
             string account = scene.GetComponent<GateSessionKeyComponent>().Get(request.Key);

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Gate/C2G_PingHandler.cs

@@ -3,10 +3,10 @@
 
 namespace ET.Server
 {
-	public static partial class C2G_PingHandler
+	[MessageHandler(SceneType.Gate)]
+	public class C2G_PingHandler : MessageHandler<C2G_Ping, G2C_Ping>
 	{
-		[MessageHandler(SceneType.Gate)]
-		private static async ETTask Run(Session session, C2G_Ping request, G2C_Ping response)
+		protected override async ETTask Run(Session session, C2G_Ping request, G2C_Ping response)
 		{
 			response.Time = TimeHelper.ServerNow();
 			await ETTask.CompletedTask;

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Gate/R2G_GetLoginKeyHandler.cs

@@ -3,10 +3,10 @@
 
 namespace ET.Server
 {
-	public static partial class R2G_GetLoginKeyHandler
+	[ActorMessageHandler(SceneType.Gate)]
+	public class R2G_GetLoginKeyHandler : ActorMessageHandler<Scene, R2G_GetLoginKey, G2R_GetLoginKey>
 	{
-		[ActorMessageHandler(SceneType.Gate)]
-		private static async ETTask Run(Scene scene, R2G_GetLoginKey request, G2R_GetLoginKey response)
+		protected override async ETTask Run(Scene scene, R2G_GetLoginKey request, G2R_GetLoginKey response)
 		{
 			long key = RandomGenerator.RandInt64();
 			scene.GetComponent<GateSessionKeyComponent>().Add(key, request.Account);

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/C2M_TestRobotCaseHandler.cs

@@ -2,10 +2,10 @@
 
 namespace ET.Server
 {
-	public static partial class C2M_TestRobotCaseHandler
+	[ActorMessageLocationHandler(SceneType.Map)]
+	public class C2M_TestRobotCaseHandler : ActorMessageLocationHandler<Unit, C2M_TestRobotCase, M2C_TestRobotCase>
 	{
-		[ActorMessageLocationHandler(SceneType.Map)]
-		private static async ETTask Run(Unit unit, C2M_TestRobotCase request, M2C_TestRobotCase response)
+		protected override async ETTask Run(Unit unit, C2M_TestRobotCase request, M2C_TestRobotCase response)
 		{
 			response.N = request.N;
 			await ETTask.CompletedTask;

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/G2M_SessionDisconnectHandler.cs

@@ -2,10 +2,10 @@
 
 namespace ET.Server
 {
-	public static partial class G2M_SessionDisconnectHandler
+	[ActorMessageLocationHandler(SceneType.Map)]
+	public class G2M_SessionDisconnectHandler : ActorMessageLocationHandler<Unit, G2M_SessionDisconnect>
 	{
-		[ActorMessageLocationHandler(SceneType.Map)]
-		private static async ETTask Run(Unit unit, G2M_SessionDisconnect message)
+		protected override async ETTask Run(Unit unit, G2M_SessionDisconnect message)
 		{
 			await ETTask.CompletedTask;
 		}

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/Move/C2M_PathfindingResultHandler.cs

@@ -1,10 +1,10 @@
 
 namespace ET.Server
 {
-	public static partial class C2M_PathfindingResultHandler
+	[ActorMessageLocationHandler(SceneType.Map)]
+	public class C2M_PathfindingResultHandler : ActorMessageLocationHandler<Unit, C2M_PathfindingResult>
 	{
-		[ActorMessageLocationHandler(SceneType.Map)]
-		private static async ETTask Run(Unit unit, C2M_PathfindingResult message)
+		protected override async ETTask Run(Unit unit, C2M_PathfindingResult message)
 		{
 			unit.FindPathMoveToAsync(message.Position).Coroutine();
 			await ETTask.CompletedTask;

+ 9 - 9
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/Move/C2M_StopHandler.cs

@@ -1,12 +1,12 @@
 namespace ET.Server
 {
-	public static partial class C2M_StopHandler
-	{
-		[ActorMessageLocationHandler(SceneType.Map)]
-		private static async ETTask Run(Unit unit, C2M_Stop message)
-		{
-			unit.Stop(1);
-			await ETTask.CompletedTask;
-		}
-	}
+    [ActorMessageLocationHandler(SceneType.Map)]
+    public class C2M_StopHandler: ActorMessageLocationHandler<Unit, C2M_Stop>
+    {
+        protected override async ETTask Run(Unit unit, C2M_Stop message)
+        {
+            unit.Stop(1);
+            await ETTask.CompletedTask;
+        }
+    }
 }

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/Transfer/C2M_TransferMapHandler.cs

@@ -2,10 +2,10 @@
 
 namespace ET.Server
 {
-	public static partial class C2M_TransferMapHandler
+	[ActorMessageLocationHandler(SceneType.Map)]
+	public class C2M_TransferMapHandler : ActorMessageLocationHandler<Unit, C2M_TransferMap, M2C_TransferMap>
 	{
-		[ActorMessageLocationHandler(SceneType.Map)]
-		private static async ETTask Run(Unit unit, C2M_TransferMap request, M2C_TransferMap response)
+		protected override async ETTask Run(Unit unit, C2M_TransferMap request, M2C_TransferMap response)
 		{
 			await ETTask.CompletedTask;
 

+ 39 - 39
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/Transfer/M2M_UnitTransferRequestHandler.cs

@@ -3,43 +3,43 @@ using Unity.Mathematics;
 
 namespace ET.Server
 {
-	public static partial class M2M_UnitTransferRequestHandler
-	{
-		[ActorMessageHandler(SceneType.Map)]
-		private static async ETTask Run(Scene scene, M2M_UnitTransferRequest request, M2M_UnitTransferResponse response)
-		{
-			UnitComponent unitComponent = scene.GetComponent<UnitComponent>();
-			Unit unit = MongoHelper.Deserialize<Unit>(request.Unit);
-			
-			unitComponent.AddChild(unit);
-			unitComponent.Add(unit);
-
-			foreach (byte[] bytes in request.Entitys)
-			{
-				Entity entity = MongoHelper.Deserialize<Entity>(bytes);
-				unit.AddComponent(entity);
-			}
-			
-			unit.AddComponent<MoveComponent>();
-			unit.AddComponent<PathfindingComponent, string>(scene.Name);
-			unit.Position = new float3(-10, 0, -10);
-			
-			unit.AddComponent<MailBoxComponent, MailboxType>(MailboxType.OrderedMessage);
-
-			// 通知客户端开始切场景
-			M2C_StartSceneChange m2CStartSceneChange = new M2C_StartSceneChange() {SceneInstanceId = scene.InstanceId, SceneName = scene.Name};
-			MessageHelper.SendToClient(unit, m2CStartSceneChange);
-			
-			// 通知客户端创建My Unit
-			M2C_CreateMyUnit m2CCreateUnits = new M2C_CreateMyUnit();
-			m2CCreateUnits.Unit = UnitHelper.CreateUnitInfo(unit);
-			MessageHelper.SendToClient(unit, m2CCreateUnits);
-			
-			// 加入aoi
-			unit.AddComponent<AOIEntity, int, float3>(9 * 1000, unit.Position);
-			
-			// 解锁location,可以接收发给Unit的消息
-			await LocationProxyComponent.Instance.UnLock(LocationType.Unit, unit.Id, request.OldInstanceId, unit.InstanceId);
-		}
-	}
+    [ActorMessageHandler(SceneType.Map)]
+    public class M2M_UnitTransferRequestHandler: ActorMessageHandler<Scene, M2M_UnitTransferRequest, M2M_UnitTransferResponse>
+    {
+        protected override async ETTask Run(Scene scene, M2M_UnitTransferRequest request, M2M_UnitTransferResponse response)
+        {
+            UnitComponent unitComponent = scene.GetComponent<UnitComponent>();
+            Unit unit = MongoHelper.Deserialize<Unit>(request.Unit);
+
+            unitComponent.AddChild(unit);
+            unitComponent.Add(unit);
+
+            foreach (byte[] bytes in request.Entitys)
+            {
+                Entity entity = MongoHelper.Deserialize<Entity>(bytes);
+                unit.AddComponent(entity);
+            }
+
+            unit.AddComponent<MoveComponent>();
+            unit.AddComponent<PathfindingComponent, string>(scene.Name);
+            unit.Position = new float3(-10, 0, -10);
+
+            unit.AddComponent<MailBoxComponent, MailboxType>(MailboxType.OrderedMessage);
+
+            // 通知客户端开始切场景
+            M2C_StartSceneChange m2CStartSceneChange = new M2C_StartSceneChange() { SceneInstanceId = scene.InstanceId, SceneName = scene.Name };
+            MessageHelper.SendToClient(unit, m2CStartSceneChange);
+
+            // 通知客户端创建My Unit
+            M2C_CreateMyUnit m2CCreateUnits = new M2C_CreateMyUnit();
+            m2CCreateUnits.Unit = UnitHelper.CreateUnitInfo(unit);
+            MessageHelper.SendToClient(unit, m2CCreateUnits);
+
+            // 加入aoi
+            unit.AddComponent<AOIEntity, int, float3>(9 * 1000, unit.Position);
+
+            // 解锁location,可以接收发给Unit的消息
+            await LocationProxyComponent.Instance.UnLock(LocationType.Unit, unit.Id, request.OldInstanceId, unit.InstanceId);
+        }
+    }
 }

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Realm/C2R_LoginHandler.cs

@@ -4,10 +4,10 @@ using System.Net;
 
 namespace ET.Server
 {
-	public static partial class C2R_LoginHandler
+	[MessageHandler(SceneType.Realm)]
+	public class C2R_LoginHandler : MessageHandler<C2R_Login, R2C_Login>
 	{
-		[MessageHandler(SceneType.Realm)]
-		private static async ETTask Run(Session session, C2R_Login request, R2C_Login response)
+		protected override async ETTask Run(Session session, C2R_Login request, R2C_Login response)
 		{
 			// 随机分配一个Gate
 			StartSceneConfig config = RealmGateAddressHelper.GetGate(session.DomainZone(), request.Account);

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Robot/Case/RobotCase_SecondCase.cs

@@ -2,10 +2,10 @@ using System;
 
 namespace ET.Server
 {
-    public static partial class M2C_TestRobotCase2Handler
+    [MessageHandler(SceneType.Demo)]
+    public class M2C_TestRobotCase2Handler: MessageHandler<M2C_TestRobotCase2>
     {
-        [MessageHandler(SceneType.Demo)]
-        private static async ETTask Run(Session session, M2C_TestRobotCase2 message)
+        protected override async ETTask Run(Session session, M2C_TestRobotCase2 message)
         {
             ObjectWait objectWait = session.ClientScene().GetComponent<ObjectWait>();
             if (objectWait == null)

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/LockStep/Gate/C2G_MatchHandler.cs

@@ -1,9 +1,9 @@
 namespace ET.Server
 {
-	public static partial class C2G_MatchHandler
+	[MessageHandler(SceneType.Gate)]
+	public class C2G_MatchHandler : MessageHandler<C2G_Match, G2C_Match>
 	{
-		[MessageHandler(SceneType.Gate)]
-		private static async ETTask Run(Session session, C2G_Match request, G2C_Match response)
+		protected override async ETTask Run(Session session, C2G_Match request, G2C_Match response)
 		{
 			Player player = session.GetComponent<SessionPlayerComponent>().Player;
 

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/LockStep/Gate/Match2G_NotifyMatchSuccessHandler.cs

@@ -3,10 +3,10 @@
 
 namespace ET.Server
 {
-	public static partial class Match2G_NotifyMatchSuccessHandler
+	[ActorMessageHandler(SceneType.Gate)]
+	public class Match2G_NotifyMatchSuccessHandler : ActorMessageHandler<Player, Match2G_NotifyMatchSuccess>
 	{
-		[ActorMessageHandler(SceneType.Gate)]
-		private static async ETTask Run(Player player, Match2G_NotifyMatchSuccess message)
+		protected override async ETTask Run(Player player, Match2G_NotifyMatchSuccess message)
 		{
 			player.AddComponent<PlayerRoomComponent>().RoomInstanceId = message.InstanceId;
 			

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/LockStep/Map/C2Room_ChangeSceneFinishHandler.cs

@@ -3,11 +3,11 @@ using TrueSync;
 
 namespace ET.Server
 {
+    [ActorMessageHandler(SceneType.Room)]
     [FriendOf(typeof (RoomServerComponent))]
-    public static partial class C2Room_ChangeSceneFinishHandler
+    public class C2Room_ChangeSceneFinishHandler: ActorMessageHandler<Room, C2Room_ChangeSceneFinish>
     {
-        [ActorMessageHandler(SceneType.Room)]
-        private static async ETTask Run(Room room, C2Room_ChangeSceneFinish message)
+        protected override async ETTask Run(Room room, C2Room_ChangeSceneFinish message)
         {
             RoomServerComponent roomServerComponent = room.GetComponent<RoomServerComponent>();
             RoomPlayer roomPlayer = room.GetComponent<RoomServerComponent>().GetChild<RoomPlayer>(message.PlayerId);

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/LockStep/Map/FrameMessageHandler.cs

@@ -3,10 +3,10 @@ using System.Collections.Generic;
 
 namespace ET.Server
 {
-    public static partial class FrameMessageHandler
+    [ActorMessageHandler(SceneType.Room)]
+    public class FrameMessageHandler: ActorMessageHandler<Room, FrameMessage>
     {
-        [ActorMessageHandler(SceneType.Room)]
-        private static async ETTask Run(Room room, FrameMessage message)
+        protected override async ETTask Run(Room room, FrameMessage message)
         {
             FrameBuffer frameBuffer = room.FrameBuffer;
             

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/LockStep/Map/Match2Map_GetRoomHandler.cs

@@ -3,10 +3,10 @@
 
 namespace ET.Server
 {
-	public static partial class Match2Map_GetRoomHandler
+	[ActorMessageHandler(SceneType.Map)]
+	public class Match2Map_GetRoomHandler : ActorMessageHandler<Scene, Match2Map_GetRoom, Map2Match_GetRoom>
 	{
-		[ActorMessageHandler(SceneType.Map)]
-		private static async ETTask Run(Scene scene, Match2Map_GetRoom request, Map2Match_GetRoom response)
+		protected override async ETTask Run(Scene scene, Match2Map_GetRoom request, Map2Match_GetRoom response)
 		{
 			RoomManagerComponent roomManagerComponent = scene.GetComponent<RoomManagerComponent>();
 			Room room = await roomManagerComponent.CreateServerRoom(request);

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/LockStep/Match/G2Match_MatchHandler.cs

@@ -3,10 +3,10 @@
 
 namespace ET.Server
 {
-	public static partial class G2Match_MatchHandler
+	[ActorMessageHandler(SceneType.Match)]
+	public class G2Match_MatchHandler : ActorMessageHandler<Scene, G2Match_Match, Match2G_Match>
 	{
-		[ActorMessageHandler(SceneType.Match)]
-		private static async ETTask Run(Scene scene, G2Match_Match request, Match2G_Match response)
+		protected override async ETTask Run(Scene scene, G2Match_Match request, Match2G_Match response)
 		{
 			MatchComponent matchComponent = scene.GetComponent<MatchComponent>();
 			matchComponent.Match(request.Id).Coroutine();

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/LockStep/Room/C2Room_CheckHashHandler.cs

@@ -1,9 +1,9 @@
 namespace ET.Server
 {
-    public static partial class C2Room_CheckHashHandler
+    [ActorMessageHandler(SceneType.Room)]
+    public class C2Room_CheckHashHandler: ActorMessageHandler<Room, C2Room_CheckHash>
     {
-        [ActorMessageHandler(SceneType.Room)]
-        private static async ETTask Run(Room room, C2Room_CheckHash message)
+        protected override async ETTask Run(Room room, C2Room_CheckHash message)
         {
             long hash = room.FrameBuffer.GetHash(message.Frame);
             if (message.Hash != hash)

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/LockStep/Room/G2Room_ReconnectHandler.cs

@@ -2,10 +2,10 @@ using System.Collections.Generic;
 
 namespace ET.Server
 {
-    public static partial class G2Room_ReconnectHandler
+    [ActorMessageHandler(SceneType.Room)]
+    public class G2Room_ReconnectHandler: ActorMessageHandler<Room, G2Room_Reconnect, Room2G_Reconnect>
     {
-        [ActorMessageHandler(SceneType.Room)]
-        private static async ETTask Run(Room room, G2Room_Reconnect request, Room2G_Reconnect response)
+        protected override async ETTask Run(Room room, G2Room_Reconnect request, Room2G_Reconnect response)
         {
             response.StartTime = room.StartTime;
             response.UnitInfos = new List<LockStepUnitInfo>();

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ObjectAddRequestHandler.cs

@@ -2,10 +2,10 @@
 
 namespace ET.Server
 {
-    public static partial class ObjectAddRequestHandler
+    [ActorMessageHandler(SceneType.Location)]
+    public class ObjectAddRequestHandler: ActorMessageHandler<Scene, ObjectAddRequest, ObjectAddResponse>
     {
-        [ActorMessageHandler(SceneType.Location)]
-        private static async ETTask Run(Scene scene, ObjectAddRequest request, ObjectAddResponse response)
+        protected override async ETTask Run(Scene scene, ObjectAddRequest request, ObjectAddResponse response)
         {
             await scene.GetComponent<LocationManagerComoponent>().Get(request.Type).Add(request.Key, request.InstanceId);
         }

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ObjectGetRequestHandler.cs

@@ -2,10 +2,10 @@
 
 namespace ET.Server
 {
-    public static partial class ObjectGetRequestHandler
+    [ActorMessageHandler(SceneType.Location)]
+    public class ObjectGetRequestHandler: ActorMessageHandler<Scene, ObjectGetRequest, ObjectGetResponse>
     {
-        [ActorMessageHandler(SceneType.Location)]
-        private static async ETTask Run(Scene scene, ObjectGetRequest request, ObjectGetResponse response)
+        protected override async ETTask Run(Scene scene, ObjectGetRequest request, ObjectGetResponse response)
         {
             long instanceId = await scene.GetComponent<LocationManagerComoponent>().Get(request.Type).Get(request.Key);
             response.InstanceId = instanceId;

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ObjectLockRequestHandler.cs

@@ -2,10 +2,10 @@
 
 namespace ET.Server
 {
-    public static partial class ObjectLockRequestHandler
+    [ActorMessageHandler(SceneType.Location)]
+    public class ObjectLockRequestHandler: ActorMessageHandler<Scene, ObjectLockRequest, ObjectLockResponse>
     {
-        [ActorMessageHandler(SceneType.Location)]
-        private static async ETTask Run(Scene scene, ObjectLockRequest request, ObjectLockResponse response)
+        protected override async ETTask Run(Scene scene, ObjectLockRequest request, ObjectLockResponse response)
         {
             await scene.GetComponent<LocationManagerComoponent>().Get(request.Type).Lock(request.Key, request.InstanceId, request.Time);
         }

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ObjectRemoveRequestHandler.cs

@@ -2,10 +2,10 @@
 
 namespace ET.Server
 {
-    public static partial class ObjectRemoveRequestHandler
+    [ActorMessageHandler(SceneType.Location)]
+    public class ObjectRemoveRequestHandler: ActorMessageHandler<Scene, ObjectRemoveRequest, ObjectRemoveResponse>
     {
-        [ActorMessageHandler(SceneType.Location)]
-        private static async ETTask Run(Scene scene, ObjectRemoveRequest request, ObjectRemoveResponse response)
+        protected override async ETTask Run(Scene scene, ObjectRemoveRequest request, ObjectRemoveResponse response)
         {
             await scene.GetComponent<LocationManagerComoponent>().Get(request.Type).Remove(request.Key);
         }

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ObjectUnLockRequestHandler.cs

@@ -2,10 +2,10 @@
 
 namespace ET.Server
 {
-    public static partial class ObjectUnLockRequestHandler
+    [ActorMessageHandler(SceneType.Location)]
+    public class ObjectUnLockRequestHandler: ActorMessageHandler<Scene, ObjectUnLockRequest, ObjectUnLockResponse>
     {
-        [ActorMessageHandler(SceneType.Location)]
-        private static async ETTask Run(Scene scene, ObjectUnLockRequest request, ObjectUnLockResponse response)
+        protected override async ETTask Run(Scene scene, ObjectUnLockRequest request, ObjectUnLockResponse response)
         {
             scene.GetComponent<LocationManagerComoponent>().Get(request.Type).UnLock(request.Key, request.OldInstanceId, request.InstanceId);