浏览代码

ActorMessageHandler跟ActorMessageLocationHandler改成Source Generator生成

tanghai 2 年之前
父节点
当前提交
e3d17e73e4
共有 68 个文件被更改,包括 303 次插入360 次删除
  1. 2 0
      .gitignore
  2. 1 1
      DotNet/Model/DotNet.Model.csproj
  3. 18 6
      Share/Share.SourceGenerator/Generator/ETSystemGenerator/AttributeTemplate.cs
  4. 15 6
      Share/Share.SourceGenerator/Generator/ETSystemGenerator/ETSystemGenerator.cs
  5. 3 2
      Share/Share.SourceGenerator/Share.SourceGenerator.csproj
  6. 二进制
      Unity/Assets/Plugins/Share.SourceGenerator.dll
  7. 0 71
      Unity/Assets/Plugins/Share.SourceGenerator.dll.meta
  8. 1 1
      Unity/Assets/Resources/GlobalConfig.asset
  9. 2 2
      Unity/Assets/Scripts/Editor/AssetPostProcessor/OnGenerateCSProjectProcessor.cs
  10. 0 13
      Unity/Assets/Scripts/Hotfix/Client/Demo/Move/M2C_PathfindingResultHandler.cs
  11. 4 3
      Unity/Assets/Scripts/Hotfix/Client/Demo/Move/M2C_StopHandler.cs
  12. 3 3
      Unity/Assets/Scripts/Hotfix/Client/Demo/Scene/M2C_StartSceneChangeHandler.cs
  13. 3 3
      Unity/Assets/Scripts/Hotfix/Client/Demo/Unit/M2C_CreateMyUnitHandler.cs
  14. 3 3
      Unity/Assets/Scripts/Hotfix/Client/Demo/Unit/M2C_CreateUnitsHandler.cs
  15. 3 3
      Unity/Assets/Scripts/Hotfix/Client/Demo/Unit/M2C_RemoveUnitsHandler.cs
  16. 3 4
      Unity/Assets/Scripts/Hotfix/Client/LockStep/G2C_ChangeSceneHandler.cs
  17. 3 3
      Unity/Assets/Scripts/Hotfix/Client/LockStep/G2C_ReconnectHandler.cs
  18. 3 3
      Unity/Assets/Scripts/Hotfix/Client/LockStep/OneFrameInputsHandler.cs
  19. 3 3
      Unity/Assets/Scripts/Hotfix/Client/LockStep/Room2C_AdjustUpdateTimeHandler.cs
  20. 3 3
      Unity/Assets/Scripts/Hotfix/Client/LockStep/Room2C_CheckHashFailHandler.cs
  21. 3 3
      Unity/Assets/Scripts/Hotfix/Client/LockStep/Room2C_EnterMapHandler.cs
  22. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Benchmark/C2G_BenchmarkHandler.cs
  23. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Gate/C2G_EnterMapHandler.cs
  24. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Gate/C2G_LoginGateHandler.cs
  25. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Gate/C2G_PingHandler.cs
  26. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Gate/R2G_GetLoginKeyHandler.cs
  27. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/C2M_TestRobotCaseHandler.cs
  28. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/G2M_SessionDisconnectHandler.cs
  29. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/Move/C2M_PathfindingResultHandler.cs
  30. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/Move/C2M_StopHandler.cs
  31. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/Transfer/C2M_TransferMapHandler.cs
  32. 4 4
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/Transfer/M2M_UnitTransferRequestHandler.cs
  33. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Realm/C2R_LoginHandler.cs
  34. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Robot/Case/RobotCase_SecondCase.cs
  35. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/Session/NetInnerComponentOnReadEvent.cs
  36. 3 3
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Gate/C2G_MatchHandler.cs
  37. 3 3
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Gate/Match2G_NotifyMatchSuccessHandler.cs
  38. 3 3
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Map/C2Room_ChangeSceneFinishHandler.cs
  39. 3 3
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Map/FrameMessageHandler.cs
  40. 3 3
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Map/Match2Map_GetRoomHandler.cs
  41. 3 3
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Match/G2Match_MatchHandler.cs
  42. 3 3
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Room/C2Room_CheckHashHandler.cs
  43. 3 3
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Room/G2Room_ReconnectHandler.cs
  44. 0 42
      Unity/Assets/Scripts/Hotfix/Server/Module/Actor/AMActorHandler.cs
  45. 38 24
      Unity/Assets/Scripts/Hotfix/Server/Module/Actor/ActorMessageDispatcherComponentSystem.cs
  46. 41 1
      Unity/Assets/Scripts/Hotfix/Server/Module/Actor/ActorMessageHandler.cs
  47. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Module/Actor/ActorMessageHandler.cs.meta
  48. 0 40
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/AMActorLocationHandler.cs
  49. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ActorLocationSenderComponentSystem.cs
  50. 39 1
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ActorMessageLocationHandler.cs
  51. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ActorMessageLocationHandler.cs.meta
  52. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ObjectAddRequestHandler.cs
  53. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ObjectGetRequestHandler.cs
  54. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ObjectLockRequestHandler.cs
  55. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ObjectRemoveRequestHandler.cs
  56. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ObjectUnLockRequestHandler.cs
  57. 1 0
      Unity/Assets/Scripts/Hotfix/Share/Module/Message/MessageDispatcherComponentSystem.cs
  58. 0 1
      Unity/Assets/Scripts/Model/Server/Module/Actor/ActorMessageHandlerAttribute.cs
  59. 1 1
      Unity/Assets/Scripts/Model/Server/Module/Actor/MailboxType.cs
  60. 11 0
      Unity/Assets/Scripts/Model/Server/Module/ActorLocation/ActorMessageLocationHandlerAttribute.cs
  61. 1 1
      Unity/Assets/Scripts/Model/Server/Module/ActorLocation/ActorMessageLocationHandlerAttribute.cs.meta
  62. 0 11
      Unity/Assets/Scripts/Model/Server/Module/Message/AMRpcHandler.cs.meta
  63. 1 1
      Unity/Assets/Scripts/Model/Server/Module/Message/MessageHandler.cs
  64. 1 1
      Unity/Assets/Scripts/Model/Server/Module/Message/MessageHandler.cs.meta
  65. 0 11
      Unity/Assets/Scripts/Model/Share/Module/Message/AMHandler.cs.meta
  66. 1 1
      Unity/Assets/Scripts/Model/Share/Module/Message/MessageHandler.cs
  67. 11 0
      Unity/Assets/Scripts/Model/Share/Module/Message/MessageHandler.cs.meta
  68. 0 7
      Unity/Assets/Scripts/Model/Share/Module/Message/MessageHandlerAttribute.cs

+ 2 - 0
.gitignore

@@ -91,3 +91,5 @@ Publish/
 /Unity/Assembly-CSharp-firstpass.csproj
 
 /Unity/*.csproj
+/Unity/Assets/Plugins/Share.SourceGenerator.dll
+/Unity/Assets/Plugins/Share.SourceGenerator.dll.meta

+ 1 - 1
DotNet/Model/DotNet.Model.csproj

@@ -44,7 +44,7 @@
     </ItemGroup> 
     <ItemGroup> 
         <ProjectReference Include="..\..\Share\Analyzer\Share.Analyzer.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
-        <ProjectReference Include="..\..\Share\Share.SourceGenerator\Share.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
+        <ProjectReference Include="..\..\Share\Share.SourceGenerator\Share.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
         <ProjectReference Include="..\Core\DotNet.Core.csproj" />
         <ProjectReference Include="..\Loader\DotNet.Loader.csproj" />
         <ProjectReference Include="..\ThirdParty\DotNet.ThirdParty.csproj" />

+ 18 - 6
Share/Share.SourceGenerator/Generator/ETSystemGenerator/AttributeTemplate.cs

@@ -12,7 +12,7 @@ namespace ET.Generator
         {
             this.templates.Add("EntitySystem", 
                 $$"""
-                        $attribute$
+                $attribute$
                         public class $argsTypesUnderLine$_$methodName$System: $methodName$System<$argsTypes$>
                         {   
                             protected override void $methodName$($argsTypesVars$)
@@ -24,8 +24,8 @@ namespace ET.Generator
             
             this.templates.Add("MessageHandler", 
                 $$"""
-                        $attribute$
-                	    public class $className$_$methodName$_Handler: AMHandler<$argsTypes1$>
+                $attribute$
+                	    public class $className$_$methodName$_Handler: MessageHandler<$argsTypesWithout0$>
                 	    {
                 	    	protected override async ETTask Run($argsTypesVars$)
                 	    	{
@@ -34,10 +34,22 @@ namespace ET.Generator
                         }
                 """);
             
-            this.templates.Add("MessageRpcHandler", 
+            this.templates.Add("ActorMessageHandler", 
                 $$"""
-                        $attribute$
-                	    public class $className$_$methodName$_Handler: AMRpcHandler<$argsTypes1$, $argsTypes2$>
+                $attribute$
+                	    public class $className$_$methodName$_Handler: ActorMessageHandler<$argsTypes$>
+                	    {
+                	    	protected override async ETTask Run($argsTypesVars$)
+                	    	{
+                                await $className$.$methodName$($argsVars$);
+                            }
+                        }
+                """);
+            
+            this.templates.Add("ActorMessageLocationHandler", 
+                $$"""
+                $attribute$
+                	    public class $className$_$methodName$_Handler: ActorMessageLocationHandler<$argsTypes$>
                 	    {
                 	    	protected override async ETTask Run($argsTypesVars$)
                 	    	{

+ 15 - 6
Share/Share.SourceGenerator/Generator/ETSystemGenerator/ETSystemGenerator.cs

@@ -106,6 +106,8 @@ public class ETSystemGenerator: ISourceGenerator
             List<string> argsTypesList = new List<string>();
             List<string> argsTypeVarsList = new List<string>();
             List<string> argsVarsList = new List<string>();
+            List<string> argsTypesWithout0List = new List<string>();
+            List<string> argsTypeVarsWithout0List = new List<string>();
             List<string> argsVarsWithout0List = new List<string>();
             for (int i = 0; i < methodSymbol.Parameters.Length; i++)
             {
@@ -121,10 +123,13 @@ public class ETSystemGenerator: ISourceGenerator
                 
                 argsTypesList.Add(type);
                 argsVarsList.Add(name);
-                argsTypeVarsList.Add($"{type} {name}");
+                string typeName = $"{type} {name}";
+                argsTypeVarsList.Add(typeName);
 
                 if (i != 0)
                 {
+                    argsTypesWithout0List.Add(type);
+                    argsTypeVarsWithout0List.Add(typeName);
                     argsVarsWithout0List.Add(name);
                 }
             }
@@ -152,11 +157,13 @@ namespace {{namespaceName}}
 }
 """;
 
-                string argsVars = string.Join(",", argsVarsList);
-                string argsTypes = string.Join(",", argsTypesList);
-                string argsTypesVars = string.Join(",", argsTypeVarsList);
-                string argsTypesUnderLine = argsTypes.Replace(",", "_").Replace(".", "_");
-                string argsVarsWithout0 = string.Join(",", argsVarsWithout0List);
+                string argsVars = string.Join(", ", argsVarsList);
+                string argsTypes = string.Join(", ", argsTypesList);
+                string argsTypesVars = string.Join(", ", argsTypeVarsList);
+                string argsTypesUnderLine = string.Join("_", argsTypesList).Replace(", ", "_").Replace(".", "_");
+                string argsTypesWithout0 = string.Join(", ", argsTypesWithout0List);
+                string argsVarsWithout0 = string.Join(", ", argsVarsWithout0List);
+                string argsTypesVarsWithout0 = string.Join(", ", argsTypeVarsWithout0List);
 
                 code = code.Replace("$attribute$", attributeString);
                 code = code.Replace("$attributeType$", attributeType);
@@ -167,7 +174,9 @@ namespace {{namespaceName}}
                 code = code.Replace("$argsTypesUnderLine$", argsTypesUnderLine);
                 code = code.Replace("$argsTypesVars$", argsTypesVars);
                 code = code.Replace("$argsVars$", argsVars);
+                code = code.Replace("$argsTypesWithout0$", argsTypesWithout0);
                 code = code.Replace("$argsVarsWithout0$", argsVarsWithout0);
+                code = code.Replace("$argsTypesVarsWithout0$", argsTypesVarsWithout0);
 
                 for (int i = 0; i < argsTypesList.Count; ++i)
                 {

+ 3 - 2
Share/Share.SourceGenerator/Share.SourceGenerator.csproj

@@ -9,7 +9,8 @@
         <DevelopmentDependency>true</DevelopmentDependency>
         <IncludeSymbols>false</IncludeSymbols>
         <NoWarn>1701;1702;RS2008</NoWarn>
-        
+        <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
+        <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
     </PropertyGroup>
 
     <ItemGroup>
@@ -26,7 +27,7 @@
         </PackageReference>
     </ItemGroup>
 
-    <Target Name="AfterBuild">
+    <Target Name="PostBuild" AfterTargets="PostBuildEvent">
         <Copy SourceFiles="$(TargetDir)/$(TargetName).dll" DestinationFolder="$(ProjectDir)/../../Unity/Assets/Plugins/" ContinueOnError="false" />
     </Target>
 

二进制
Unity/Assets/Plugins/Share.SourceGenerator.dll


+ 0 - 71
Unity/Assets/Plugins/Share.SourceGenerator.dll.meta

@@ -1,71 +0,0 @@
-fileFormatVersion: 2
-guid: dbed22035f711974b8caf049edbfe8f8
-labels:
-- RoslynAnalyzer
-PluginImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  iconMap: {}
-  executionOrder: {}
-  defineConstraints: []
-  isPreloaded: 0
-  isOverridable: 0
-  isExplicitlyReferenced: 0
-  validateReferences: 1
-  platformData:
-  - first:
-      : Any
-    second:
-      enabled: 0
-      settings:
-        Exclude Editor: 1
-        Exclude Linux64: 1
-        Exclude OSXUniversal: 1
-        Exclude Win: 1
-        Exclude Win64: 1
-  - first:
-      Any: 
-    second:
-      enabled: 0
-      settings: {}
-  - first:
-      Editor: Editor
-    second:
-      enabled: 0
-      settings:
-        CPU: AnyCPU
-        DefaultValueInitialized: true
-        OS: AnyOS
-  - first:
-      Standalone: Linux64
-    second:
-      enabled: 0
-      settings:
-        CPU: None
-  - first:
-      Standalone: OSXUniversal
-    second:
-      enabled: 0
-      settings:
-        CPU: None
-  - first:
-      Standalone: Win
-    second:
-      enabled: 0
-      settings:
-        CPU: None
-  - first:
-      Standalone: Win64
-    second:
-      enabled: 0
-      settings:
-        CPU: None
-  - first:
-      Windows Store Apps: WindowsStoreApps
-    second:
-      enabled: 0
-      settings:
-        CPU: AnyCPU
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 1 - 1
Unity/Assets/Resources/GlobalConfig.asset

@@ -14,4 +14,4 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   CodeMode: 3
   BuildType: 1
-  AppType: 8
+  AppType: 7

+ 2 - 2
Unity/Assets/Scripts/Editor/AssetPostProcessor/OnGenerateCSProjectProcessor.cs

@@ -61,7 +61,7 @@ namespace ET
 
                 content = GenerateCustomProject(path, content, files);
                 content = content.Replace("<Target Name=\"AfterBuild\" />",
-                    "   <Target Name=\"AfterBuild\">\n" +
+                    "   <Target Name=\"PostBuild\" AfterTargets=\"PostBuildEvent\">\n" +
                     $"       <Copy SourceFiles=\"$(TargetDir)/$(TargetName).dll\" DestinationFiles=\"$(ProjectDir)/{Define.CodeDir}/Codes.dll.bytes\" ContinueOnError=\"false\" />\n" +
                     $"       <Copy SourceFiles=\"$(TargetDir)/$(TargetName).pdb\" DestinationFiles=\"$(ProjectDir)/{Define.CodeDir}/Codes.pdb.bytes\" ContinueOnError=\"false\" />\n" +
                     $"       <Copy SourceFiles=\"$(TargetDir)/$(TargetName).dll\" DestinationFiles=\"$(ProjectDir)/{Define.BuildOutputDir}/Codes.dll\" ContinueOnError=\"false\" />\n" +
@@ -94,7 +94,7 @@ namespace ET
                 XmlElement compile = newDoc.CreateElement("Compile", newDoc.DocumentElement.NamespaceURI);
                 XmlElement link = newDoc.CreateElement("Link", newDoc.DocumentElement.NamespaceURI);
                 link.InnerText = linkStr;
-                compile.AppendChild(link);
+                //compile.AppendChild(link);
                 compile.SetAttribute("Include", p);
                 itemGroup.AppendChild(compile);
             }

+ 0 - 13
Unity/Assets/Scripts/Hotfix/Client/Demo/Move/M2C_PathfindingResultHandler.cs

@@ -14,17 +14,4 @@ namespace ET.Client
 			await unit.GetComponent<MoveComponent>().MoveToAsync(message.Points, speed);
 		}
 	}
-	
-	//[MessageHandler(SceneType.Demo)]
-	//public class M2C_PathfindingResultHandler : AMHandler<M2C_PathfindingResult>
-	//{
-	//	protected override async ETTask Run(Session session, M2C_PathfindingResult message)
-	//	{
-	//		Unit unit = session.DomainScene().CurrentScene().GetComponent<UnitComponent>().Get(message.Id);
-//
-	//		float speed = unit.GetComponent<NumericComponent>().GetAsFloat(NumericType.Speed);
-//
-	//		await unit.GetComponent<MoveComponent>().MoveToAsync(message.Points, speed);
-	//	}
-	//}
 }

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

@@ -2,10 +2,11 @@
 
 namespace ET.Client
 {
-	[MessageHandler(SceneType.Demo)]
-	public class M2C_StopHandler : AMHandler<M2C_Stop>
+	
+	public static partial class M2C_StopHandler
 	{
-		protected override async ETTask Run(Session session, M2C_Stop message)
+		[MessageHandler(SceneType.Demo)]
+		private static 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
 {
-	[MessageHandler(SceneType.Demo)]
-	public class M2C_StartSceneChangeHandler : AMHandler<M2C_StartSceneChange>
+	public static partial class M2C_StartSceneChangeHandler
 	{
-		protected override async ETTask Run(Session session, M2C_StartSceneChange message)
+		[MessageHandler(SceneType.Demo)]
+		private static 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
 {
-	[MessageHandler(SceneType.Demo)]
-	public class M2C_CreateMyUnitHandler : AMHandler<M2C_CreateMyUnit>
+	public static partial class M2C_CreateMyUnitHandler
 	{
-		protected override async ETTask Run(Session session, M2C_CreateMyUnit message)
+		[MessageHandler(SceneType.Demo)]
+		private static 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
 {
-	[MessageHandler(SceneType.Demo)]
-	public class M2C_CreateUnitsHandler : AMHandler<M2C_CreateUnits>
+	public static partial class M2C_CreateUnitsHandler
 	{
-		protected override async ETTask Run(Session session, M2C_CreateUnits message)
+		[MessageHandler(SceneType.Demo)]
+		private static 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
 {
-	[MessageHandler(SceneType.Demo)]
-	public class M2C_RemoveUnitsHandler : AMHandler<M2C_RemoveUnits>
+	public static partial class M2C_RemoveUnitsHandler
 	{
-		protected override async ETTask Run(Session session, M2C_RemoveUnits message)
+		[MessageHandler(SceneType.Demo)]
+		private static async ETTask Run(Session session, M2C_RemoveUnits message)
 		{	
 			UnitComponent unitComponent = session.DomainScene().CurrentScene()?.GetComponent<UnitComponent>();
 			if (unitComponent == null)

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

@@ -1,10 +1,9 @@
 namespace ET.Client
 {
-
-    [MessageHandler(SceneType.LockStep)]
-    public class Match2G_NotifyMatchSuccessHandler: AMHandler<Match2G_NotifyMatchSuccess>
+    public static partial class Match2G_NotifyMatchSuccessHandler
     {
-        protected override async ETTask Run(Session session, Match2G_NotifyMatchSuccess message)
+        [MessageHandler(SceneType.LockStep)]
+        private static 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
 {
-    [MessageHandler(SceneType.LockStep)]
-    public class G2C_ReconnectHandler: AMHandler<G2C_Reconnect>
+    public static partial class G2C_ReconnectHandler
     {
-        protected override async ETTask Run(Session session, G2C_Reconnect message)
+        [MessageHandler(SceneType.LockStep)]
+        private static 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
 {
-    [MessageHandler(SceneType.LockStep)]
-    public class OneFrameInputsHandler: AMHandler<OneFrameInputs>
+    public static partial class OneFrameInputsHandler
     {
-        protected override async ETTask Run(Session session, OneFrameInputs input)
+        [MessageHandler(SceneType.LockStep)]
+        private static 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
 {
-    [MessageHandler(SceneType.LockStep)]
-    public class Room2C_AdjustUpdateTimeHandler: AMHandler<Room2C_AdjustUpdateTime>
+    public static partial class Room2C_AdjustUpdateTimeHandler
     {
-        protected override async ETTask Run(Session session, Room2C_AdjustUpdateTime message)
+        [MessageHandler(SceneType.LockStep)]
+        private static 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
 {
-    [MessageHandler(SceneType.LockStep)]
-    public class Room2C_CheckHashFailHandler: AMHandler<Room2C_CheckHashFail>
+    public static partial class Room2C_CheckHashFailHandler
     {
-        protected override async ETTask Run(Session session, Room2C_CheckHashFail message)
+        [MessageHandler(SceneType.LockStep)]
+        private static 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
 {
-    [MessageHandler(SceneType.LockStep)]
-    public class Room2C_EnterMapHandler: AMHandler<Room2C_Start>
+    public static partial class Room2C_EnterMapHandler
     {
-        protected override async ETTask Run(Session session, Room2C_Start message)
+        [MessageHandler(SceneType.LockStep)]
+        private static async ETTask Run(Session session, Room2C_Start message)
         {
             session.DomainScene().GetComponent<ObjectWait>().Notify(new WaitType.Wait_Room2C_Start() {Message = message});
             await ETTask.CompletedTask;

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

@@ -4,7 +4,7 @@ namespace ET.Server
 {
     public static partial class C2G_BenchmarkHandler
     {
-        [MessageRpcHandler(SceneType.BenchmarkServer)]
+        [MessageHandler(SceneType.BenchmarkServer)]
         private static async ETTask Run(Session session, C2G_Benchmark request, G2C_Benchmark response)
         {
             BenchmarkServerComponent benchmarkServerComponent = session.DomainScene().GetComponent<BenchmarkServerComponent>();

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

@@ -1,9 +1,9 @@
 namespace ET.Server
 {
-	[MessageHandler(SceneType.Gate)]
-	public class C2G_EnterMapHandler : AMRpcHandler<C2G_EnterMap, G2C_EnterMap>
+	public static partial class C2G_EnterMapHandler
 	{
-		protected override async ETTask Run(Session session, C2G_EnterMap request, G2C_EnterMap response)
+		[MessageHandler(SceneType.Gate)]
+		private static 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
 {
-    [MessageHandler(SceneType.Gate)]
-    public class C2G_LoginGateHandler : AMRpcHandler<C2G_LoginGate, G2C_LoginGate>
+    public static partial class C2G_LoginGateHandler
     {
-        protected override async ETTask Run(Session session, C2G_LoginGate request, G2C_LoginGate response)
+        [MessageHandler(SceneType.Gate)]
+        private static 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
 {
-	[MessageHandler(SceneType.Gate)]
-	public class C2G_PingHandler : AMRpcHandler<C2G_Ping, G2C_Ping>
+	public static partial class C2G_PingHandler
 	{
-		protected override async ETTask Run(Session session, C2G_Ping request, G2C_Ping response)
+		[MessageHandler(SceneType.Gate)]
+		private static 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
 {
-	[ActorMessageHandler(SceneType.Gate)]
-	public class R2G_GetLoginKeyHandler : AMActorRpcHandler<Scene, R2G_GetLoginKey, G2R_GetLoginKey>
+	public static partial class R2G_GetLoginKeyHandler
 	{
-		protected override async ETTask Run(Scene scene, R2G_GetLoginKey request, G2R_GetLoginKey response)
+		[ActorMessageHandler(SceneType.Gate)]
+		private static 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
 {
-	[ActorMessageHandler(SceneType.Map)]
-	public class C2M_TestRobotCaseHandler : AMActorLocationRpcHandler<Unit, C2M_TestRobotCase, M2C_TestRobotCase>
+	public static partial class C2M_TestRobotCaseHandler
 	{
-		protected override async ETTask Run(Unit unit, C2M_TestRobotCase request, M2C_TestRobotCase response)
+		[ActorMessageLocationHandler(SceneType.Map)]
+		private static 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
 {
-	[ActorMessageHandler(SceneType.Map)]
-	public class G2M_SessionDisconnectHandler : AMActorLocationHandler<Unit, G2M_SessionDisconnect>
+	public static partial class G2M_SessionDisconnectHandler
 	{
-		protected override async ETTask Run(Unit unit, G2M_SessionDisconnect message)
+		[ActorMessageLocationHandler(SceneType.Map)]
+		private static 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
 {
-	[ActorMessageHandler(SceneType.Map)]
-	public class C2M_PathfindingResultHandler : AMActorLocationHandler<Unit, C2M_PathfindingResult>
+	public static partial class C2M_PathfindingResultHandler
 	{
-		protected override async ETTask Run(Unit unit, C2M_PathfindingResult message)
+		[ActorMessageLocationHandler(SceneType.Map)]
+		private static async ETTask Run(Unit unit, C2M_PathfindingResult message)
 		{
 			unit.FindPathMoveToAsync(message.Position).Coroutine();
 			await ETTask.CompletedTask;

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

@@ -1,9 +1,9 @@
 namespace ET.Server
 {
-	[ActorMessageHandler(SceneType.Map)]
-	public class C2M_StopHandler : AMActorLocationHandler<Unit, C2M_Stop>
+	public static partial class C2M_StopHandler
 	{
-		protected override async ETTask Run(Unit unit, C2M_Stop message)
+		[ActorMessageLocationHandler(SceneType.Map)]
+		private static 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
 {
-	[ActorMessageHandler(SceneType.Map)]
-	public class C2M_TransferMapHandler : AMActorLocationRpcHandler<Unit, C2M_TransferMap, M2C_TransferMap>
+	public static partial class C2M_TransferMapHandler
 	{
-		protected override async ETTask Run(Unit unit, C2M_TransferMap request, M2C_TransferMap response)
+		[ActorMessageLocationHandler(SceneType.Map)]
+		private static async ETTask Run(Unit unit, C2M_TransferMap request, M2C_TransferMap response)
 		{
 			await ETTask.CompletedTask;
 

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

@@ -3,10 +3,10 @@ using Unity.Mathematics;
 
 namespace ET.Server
 {
-	[ActorMessageHandler(SceneType.Map)]
-	public class M2M_UnitTransferRequestHandler : AMActorRpcHandler<Scene, M2M_UnitTransferRequest, M2M_UnitTransferResponse>
+	public static partial class M2M_UnitTransferRequestHandler
 	{
-		protected override async ETTask Run(Scene scene, M2M_UnitTransferRequest request, M2M_UnitTransferResponse response)
+		[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);
@@ -24,7 +24,7 @@ namespace ET.Server
 			unit.AddComponent<PathfindingComponent, string>(scene.Name);
 			unit.Position = new float3(-10, 0, -10);
 			
-			unit.AddComponent<MailBoxComponent>();
+			unit.AddComponent<MailBoxComponent, MailboxType>(MailboxType.OrderedMessage);
 
 			// 通知客户端开始切场景
 			M2C_StartSceneChange m2CStartSceneChange = new M2C_StartSceneChange() {SceneInstanceId = scene.InstanceId, SceneName = scene.Name};

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

@@ -4,10 +4,10 @@ using System.Net;
 
 namespace ET.Server
 {
-	[MessageHandler(SceneType.Realm)]
-	public class C2R_LoginHandler : AMRpcHandler<C2R_Login, R2C_Login>
+	public static partial class C2R_LoginHandler
 	{
-		protected override async ETTask Run(Session session, C2R_Login request, R2C_Login response)
+		[MessageHandler(SceneType.Realm)]
+		private static 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
 {
-    [MessageHandler(SceneType.Demo)]
-    public class M2C_TestRobotCase2Handler: AMHandler<M2C_TestRobotCase2>
+    public static partial class M2C_TestRobotCase2Handler
     {
-        protected override async ETTask Run(Session session, M2C_TestRobotCase2 message)
+        [MessageHandler(SceneType.Demo)]
+        private static async ETTask Run(Session session, M2C_TestRobotCase2 message)
         {
             ObjectWait objectWait = session.ClientScene().GetComponent<ObjectWait>();
             if (objectWait == null)

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/Session/NetInnerComponentOnReadEvent.cs

@@ -11,7 +11,7 @@ namespace ET.Server
             {
                 long actorId = args.ActorId;
                 object message = args.Message;
-
+                
                 if (message is IActorResponse iActorResponse)
                 {
                     ActorMessageSenderComponent.Instance.HandleIActorResponse(iActorResponse);

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

@@ -1,9 +1,9 @@
 namespace ET.Server
 {
-	[MessageHandler(SceneType.Gate)]
-	public class C2G_MatchHandler : AMRpcHandler<C2G_Match, G2C_Match>
+	public static partial class C2G_MatchHandler
 	{
-		protected override async ETTask Run(Session session, C2G_Match request, G2C_Match response)
+		[MessageHandler(SceneType.Gate)]
+		private static 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
 {
-	[ActorMessageHandler(SceneType.Gate)]
-	public class Match2G_NotifyMatchSuccessHandler : AMActorHandler<Player, Match2G_NotifyMatchSuccess>
+	public static partial class Match2G_NotifyMatchSuccessHandler
 	{
-		protected override async ETTask Run(Player player, Match2G_NotifyMatchSuccess message)
+		[ActorMessageHandler(SceneType.Gate)]
+		private static 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 class C2Room_ChangeSceneFinishHandler: AMActorHandler<Room, C2Room_ChangeSceneFinish>
+    public static partial class C2Room_ChangeSceneFinishHandler
     {
-        protected override async ETTask Run(Room room, C2Room_ChangeSceneFinish message)
+        [ActorMessageHandler(SceneType.Room)]
+        private static 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
 {
-    [ActorMessageHandler(SceneType.Room)]
-    public class FrameMessageHandler: AMActorHandler<Room, FrameMessage>
+    public static partial class FrameMessageHandler
     {
-        protected override async ETTask Run(Room room, FrameMessage message)
+        [ActorMessageHandler(SceneType.Room)]
+        private static 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
 {
-	[ActorMessageHandler(SceneType.Map)]
-	public class Match2Map_GetRoomHandler : AMActorRpcHandler<Scene, Match2Map_GetRoom, Map2Match_GetRoom>
+	public static partial class Match2Map_GetRoomHandler
 	{
-		protected override async ETTask Run(Scene scene, Match2Map_GetRoom request, Map2Match_GetRoom response)
+		[ActorMessageHandler(SceneType.Map)]
+		private static 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
 {
-	[ActorMessageHandler(SceneType.Match)]
-	public class G2Match_MatchHandler : AMActorRpcHandler<Scene, G2Match_Match, Match2G_Match>
+	public static partial class G2Match_MatchHandler
 	{
-		protected override async ETTask Run(Scene scene, G2Match_Match request, Match2G_Match response)
+		[ActorMessageHandler(SceneType.Match)]
+		private static 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
 {
-    [ActorMessageHandler(SceneType.Room)]
-    public class C2Room_CheckHashHandler: AMActorHandler<Room, C2Room_CheckHash>
+    public static partial class C2Room_CheckHashHandler
     {
-        protected override async ETTask Run(Room room, C2Room_CheckHash message)
+        [ActorMessageHandler(SceneType.Room)]
+        private static 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
 {
-    [ActorMessageHandler(SceneType.Room)]
-    public class G2Room_ReconnectHandler: AMActorRpcHandler<Room, G2Room_Reconnect, Room2G_Reconnect>
+    public static partial class G2Room_ReconnectHandler
     {
-        protected override async ETTask Run(Room room, G2Room_Reconnect request, Room2G_Reconnect response)
+        [ActorMessageHandler(SceneType.Room)]
+        private static async ETTask Run(Room room, G2Room_Reconnect request, Room2G_Reconnect response)
         {
             response.StartTime = room.StartTime;
             response.UnitInfos = new List<LockStepUnitInfo>();

+ 0 - 42
Unity/Assets/Scripts/Hotfix/Server/Module/Actor/AMActorHandler.cs

@@ -1,42 +0,0 @@
-using System;
-
-namespace ET.Server
-{
-    [EnableClass]
-    public abstract class AMActorHandler<E, Message>: IMActorHandler where E : Entity where Message : class, IActorMessage
-    {
-        protected abstract ETTask Run(E entity, Message message);
-
-        public async ETTask Handle(Entity entity, int fromProcess, object actorMessage)
-        {
-            if (actorMessage is not Message msg)
-            {
-                Log.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Message).Name}");
-                return;
-            }
-
-            if (entity is not E e)
-            {
-                Log.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).Name} --{typeof (Message).FullName}");
-                return;
-            }
-
-            await this.Run(e, msg);
-        }
-
-        public Type GetRequestType()
-        {
-            if (typeof (IActorLocationMessage).IsAssignableFrom(typeof (Message)))
-            {
-                Log.Error($"message is IActorLocationMessage but handler is AMActorHandler: {typeof (Message)}");
-            }
-
-            return typeof (Message);
-        }
-
-        public Type GetResponseType()
-        {
-            return null;
-        }
-    }
-}

+ 38 - 24
Unity/Assets/Scripts/Hotfix/Server/Module/Actor/ActorMessageDispatcherComponentSystem.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Linq;
 
 namespace ET.Server
 {
@@ -28,39 +29,52 @@ namespace ET.Server
         {
             self.ActorMessageHandlers.Clear();
 
-            var types = EventSystem.Instance.GetTypes(typeof (ActorMessageHandlerAttribute));
+            HashSet<Type> types = EventSystem.Instance.GetTypes(typeof (ActorMessageHandlerAttribute));
+            
             foreach (Type type in types)
             {
-                object obj = Activator.CreateInstance(type);
+                self.Register(type);
+            }
+            
+            HashSet<Type> types2 = EventSystem.Instance.GetTypes(typeof (ActorMessageLocationHandlerAttribute));
+            
+            foreach (Type type in types2)
+            {
+                self.Register(type);
+            }
+        }
 
-                IMActorHandler imHandler = obj as IMActorHandler;
-                if (imHandler == null)
-                {
-                    throw new Exception($"message handler not inherit IMActorHandler abstract class: {obj.GetType().FullName}");
-                }
+        private static void Register(this ActorMessageDispatcherComponent self, Type type)
+        {
+            object obj = Activator.CreateInstance(type);
+
+            IMActorHandler imHandler = obj as IMActorHandler;
+            if (imHandler == null)
+            {
+                throw new Exception($"message handler not inherit IMActorHandler abstract class: {obj.GetType().FullName}");
+            }
                 
-                object[] attrs = type.GetCustomAttributes(typeof(ActorMessageHandlerAttribute), false);
+            object[] attrs = type.GetCustomAttributes(typeof(ActorMessageHandlerAttribute), true);
 
-                foreach (object attr in attrs)
-                {
-                    ActorMessageHandlerAttribute actorMessageHandlerAttribute = attr as ActorMessageHandlerAttribute;
+            foreach (object attr in attrs)
+            {
+                ActorMessageHandlerAttribute actorMessageHandlerAttribute = attr as ActorMessageHandlerAttribute;
 
-                    Type messageType = imHandler.GetRequestType();
+                Type messageType = imHandler.GetRequestType();
 
-                    Type handleResponseType = imHandler.GetResponseType();
-                    if (handleResponseType != null)
+                Type handleResponseType = imHandler.GetResponseType();
+                if (handleResponseType != null)
+                {
+                    Type responseType = OpcodeTypeComponent.Instance.GetResponseType(messageType);
+                    if (handleResponseType != responseType)
                     {
-                        Type responseType = OpcodeTypeComponent.Instance.GetResponseType(messageType);
-                        if (handleResponseType != responseType)
-                        {
-                            throw new Exception($"message handler response type error: {messageType.FullName}");
-                        }
+                        throw new Exception($"message handler response type error: {messageType.FullName}");
                     }
+                }
 
-                    ActorMessageDispatcherInfo actorMessageDispatcherInfo = new(actorMessageHandlerAttribute.SceneType, imHandler);
+                ActorMessageDispatcherInfo actorMessageDispatcherInfo = new(actorMessageHandlerAttribute.SceneType, imHandler);
 
-                    self.RegisterHandler(messageType, actorMessageDispatcherInfo);
-                }
+                self.RegisterHandler(messageType, actorMessageDispatcherInfo);
             }
         }
         
@@ -121,7 +135,7 @@ namespace ET.Server
             
             switch (mailBoxComponent.MailboxType)
             {
-                case MailboxType.MessageDispatcher:
+                case MailboxType.OrderedMessage:
                 {
                     using (await CoroutineLockComponent.Instance.Wait(CoroutineLockType.Mailbox, actorId))
                     {
@@ -167,7 +181,7 @@ namespace ET.Server
 
             switch (mailBoxComponent.MailboxType)
             {
-                case MailboxType.MessageDispatcher:
+                case MailboxType.OrderedMessage:
                 {
                     using (await CoroutineLockComponent.Instance.Wait(CoroutineLockType.Mailbox, actorId))
                     {

+ 41 - 1
Unity/Assets/Scripts/Hotfix/Server/Module/Actor/AMActorRpcHandler.cs → Unity/Assets/Scripts/Hotfix/Server/Module/Actor/ActorMessageHandler.cs

@@ -3,7 +3,47 @@
 namespace ET.Server
 {
     [EnableClass]
-    public abstract class AMActorRpcHandler<E, Request, Response>: IMActorHandler where E : Entity where Request : class, IActorRequest where Response : class, IActorResponse
+    public abstract class ActorMessageHandler<E, Message>: IMActorHandler where E : Entity where Message : class, IActorMessage
+    {
+        protected abstract ETTask Run(E entity, Message message);
+
+        public async ETTask Handle(Entity entity, int fromProcess, object actorMessage)
+        {
+            if (actorMessage is not Message msg)
+            {
+                Log.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Message).Name}");
+                return;
+            }
+
+            if (entity is not E e)
+            {
+                Log.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).Name} --{typeof (Message).FullName}");
+                return;
+            }
+
+            await this.Run(e, msg);
+        }
+
+        public Type GetRequestType()
+        {
+            if (typeof (IActorLocationMessage).IsAssignableFrom(typeof (Message)))
+            {
+                Log.Error($"message is IActorLocationMessage but handler is AMActorHandler: {typeof (Message)}");
+            }
+
+            return typeof (Message);
+        }
+
+        public Type GetResponseType()
+        {
+            return null;
+        }
+    }
+    
+    
+    
+    [EnableClass]
+    public abstract class ActorMessageHandler<E, Request, Response>: IMActorHandler where E : Entity where Request : class, IActorRequest where Response : class, IActorResponse
     {
         protected abstract ETTask Run(E unit, Request request, Response response);
 

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Module/Actor/AMActorRpcHandler.cs.meta → Unity/Assets/Scripts/Hotfix/Server/Module/Actor/ActorMessageHandler.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 60daa362514eebe43a33fbcbf566c9a0
+guid: 04b4a2b11a349624bb67b2fe9a0ff8da
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 0 - 40
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/AMActorLocationHandler.cs

@@ -1,40 +0,0 @@
-using System;
-
-namespace ET.Server
-{
-    [EnableClass]
-    public abstract class AMActorLocationHandler<E, Message>: IMActorHandler where E : Entity where Message : class, IActorLocationMessage
-    {
-        protected abstract ETTask Run(E entity, Message message);
-
-        public async ETTask Handle(Entity entity, int fromProcess, object actorMessage)
-        {
-            if (actorMessage is not Message message)
-            {
-                Log.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Message).Name}");
-                return;
-            }
-
-            if (entity is not E e)
-            {
-                Log.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).FullName} --{typeof (Message).FullName}");
-                return;
-            }
-            
-            ActorResponse response = new() {RpcId = message.RpcId};
-            ActorHandleHelper.Reply(fromProcess, response);
-
-            await this.Run(e, message);
-        }
-
-        public Type GetRequestType()
-        {
-            return typeof (Message);
-        }
-
-        public Type GetResponseType()
-        {
-            return typeof (ActorResponse);
-        }
-    }
-}

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ActorLocationSenderComponentSystem.cs

@@ -246,7 +246,7 @@ namespace ET.Server
                         ++failTimes;
                         if (failTimes > 20)
                         {
-                            Log.Debug($"actor send message fail, actorid: {actorLocationSender.Id}");
+                            Log.Debug($"actor send message fail, actorid: {actorLocationSender.Id} {iActorRequest}");
                             actorLocationSender.Error = ErrorCore.ERR_NotFoundActor;
                             // 这里不能删除actor,要让后面等待发送的消息也返回ERR_NotFoundActor,直到超时删除
                             return response;

+ 39 - 1
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/AMActorLocationRpcHandler.cs → Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ActorMessageLocationHandler.cs

@@ -3,7 +3,45 @@
 namespace ET.Server
 {
     [EnableClass]
-    public abstract class AMActorLocationRpcHandler<E, Request, Response>: IMActorHandler where E : Entity where Request : class, IActorLocationRequest where Response : class, IActorLocationResponse
+    public abstract class ActorMessageLocationHandler<E, Message>: IMActorHandler where E : Entity where Message : class, IActorLocationMessage
+    {
+        protected abstract ETTask Run(E entity, Message message);
+
+        public async ETTask Handle(Entity entity, int fromProcess, object actorMessage)
+        {
+            if (actorMessage is not Message message)
+            {
+                Log.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Message).Name}");
+                return;
+            }
+
+            if (entity is not E e)
+            {
+                Log.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).FullName} --{typeof (Message).FullName}");
+                return;
+            }
+            
+            ActorResponse response = new() {RpcId = message.RpcId};
+            ActorHandleHelper.Reply(fromProcess, response);
+
+            await this.Run(e, message);
+        }
+
+        public Type GetRequestType()
+        {
+            return typeof (Message);
+        }
+
+        public Type GetResponseType()
+        {
+            return typeof (ActorResponse);
+        }
+    }
+    
+    
+    
+    [EnableClass]
+    public abstract class ActorMessageLocationHandler<E, Request, Response>: IMActorHandler where E : Entity where Request : class, IActorLocationRequest where Response : class, IActorLocationResponse
     {
         protected abstract ETTask Run(E unit, Request request, Response response);
 

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/AMActorLocationHandler.cs.meta → Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/ActorMessageLocationHandler.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 3b2a0088a0a9c93448fe5cddbe1874f7
+guid: 1366e4041bf79d1468b108c582082181
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

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

@@ -2,10 +2,10 @@
 
 namespace ET.Server
 {
-    [ActorMessageHandler(SceneType.Location)]
-    public class ObjectAddRequestHandler: AMActorRpcHandler<Scene, ObjectAddRequest, ObjectAddResponse>
+    public static partial class ObjectAddRequestHandler
     {
-        protected override async ETTask Run(Scene scene, ObjectAddRequest request, ObjectAddResponse response)
+        [ActorMessageHandler(SceneType.Location)]
+        private static 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
 {
-    [ActorMessageHandler(SceneType.Location)]
-    public class ObjectGetRequestHandler: AMActorRpcHandler<Scene, ObjectGetRequest, ObjectGetResponse>
+    public static partial class ObjectGetRequestHandler
     {
-        protected override async ETTask Run(Scene scene, ObjectGetRequest request, ObjectGetResponse response)
+        [ActorMessageHandler(SceneType.Location)]
+        private static 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
 {
-    [ActorMessageHandler(SceneType.Location)]
-    public class ObjectLockRequestHandler: AMActorRpcHandler<Scene, ObjectLockRequest, ObjectLockResponse>
+    public static partial class ObjectLockRequestHandler
     {
-        protected override async ETTask Run(Scene scene, ObjectLockRequest request, ObjectLockResponse response)
+        [ActorMessageHandler(SceneType.Location)]
+        private static 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
 {
-    [ActorMessageHandler(SceneType.Location)]
-    public class ObjectRemoveRequestHandler: AMActorRpcHandler<Scene, ObjectRemoveRequest, ObjectRemoveResponse>
+    public static partial class ObjectRemoveRequestHandler
     {
-        protected override async ETTask Run(Scene scene, ObjectRemoveRequest request, ObjectRemoveResponse response)
+        [ActorMessageHandler(SceneType.Location)]
+        private static 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
 {
-    [ActorMessageHandler(SceneType.Location)]
-    public class ObjectUnLockRequestHandler: AMActorRpcHandler<Scene, ObjectUnLockRequest, ObjectUnLockResponse>
+    public static partial class ObjectUnLockRequestHandler
     {
-        protected override async ETTask Run(Scene scene, ObjectUnLockRequest request, ObjectUnLockResponse response)
+        [ActorMessageHandler(SceneType.Location)]
+        private static async ETTask Run(Scene scene, ObjectUnLockRequest request, ObjectUnLockResponse response)
         {
             scene.GetComponent<LocationManagerComoponent>().Get(request.Type).UnLock(request.Key, request.OldInstanceId, request.InstanceId);
 

+ 1 - 0
Unity/Assets/Scripts/Hotfix/Share/Module/Message/MessageDispatcherComponentSystem.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Linq;
 
 namespace ET
 {

+ 0 - 1
Unity/Assets/Scripts/Model/Server/Module/Actor/ActorMessageHandlerAttribute.cs

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

+ 1 - 1
Unity/Assets/Scripts/Model/Server/Module/Actor/MailboxType.cs

@@ -2,7 +2,7 @@
 {
     public enum MailboxType
     {
-        MessageDispatcher,
+        OrderedMessage,
         UnOrderMessageDispatcher,
         GateSession,
     }

+ 11 - 0
Unity/Assets/Scripts/Model/Server/Module/ActorLocation/ActorMessageLocationHandlerAttribute.cs

@@ -0,0 +1,11 @@
+using System;
+
+namespace ET.Server
+{
+    public class ActorMessageLocationHandlerAttribute: ActorMessageHandlerAttribute
+    {
+        public ActorMessageLocationHandlerAttribute(SceneType sceneType): base(sceneType)
+        {
+        }
+    }
+}

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/AMActorLocationRpcHandler.cs.meta → Unity/Assets/Scripts/Model/Server/Module/ActorLocation/ActorMessageLocationHandlerAttribute.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: b600ff66c60bb2f4d8081a24077bd2ae
+guid: 93635a0b30dc9c940af1c28d9614db92
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 0 - 11
Unity/Assets/Scripts/Model/Server/Module/Message/AMRpcHandler.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 36bfe40b20c683145a1bd09b382bb845
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 1 - 1
Unity/Assets/Scripts/Model/Server/Module/Message/AMRpcHandler.cs → Unity/Assets/Scripts/Model/Server/Module/Message/MessageHandler.cs

@@ -2,7 +2,7 @@ using System;
 
 namespace ET.Server
 {
-    public abstract class AMRpcHandler<Request, Response>: IMHandler where Request : class, IRequest where Response : class, IResponse
+    public abstract class MessageHandler<Request, Response>: IMHandler where Request : class, IRequest where Response : class, IResponse
     {
         protected abstract ETTask Run(Session session, Request request, Response response);
 

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Module/Actor/AMActorHandler.cs.meta → Unity/Assets/Scripts/Model/Server/Module/Message/MessageHandler.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: c1692e66d0661b4498c5aaf1cd51dc9b
+guid: e3881ad9cfc7dc343a107f25d5659fb1
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 0 - 11
Unity/Assets/Scripts/Model/Share/Module/Message/AMHandler.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: d88c5b0a0bda11f4c974fe5f062d0f41
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 1 - 1
Unity/Assets/Scripts/Model/Share/Module/Message/AMHandler.cs → Unity/Assets/Scripts/Model/Share/Module/Message/MessageHandler.cs

@@ -2,7 +2,7 @@ using System;
 
 namespace ET
 {
-    public abstract class AMHandler<Message>: IMHandler where Message : class
+    public abstract class MessageHandler<Message>: IMHandler where Message : class
     {
         protected abstract ETTask Run(Session session, Message message);
 

+ 11 - 0
Unity/Assets/Scripts/Model/Share/Module/Message/MessageHandler.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 4c40ee71fc1a2f144bf4d2ff2cf7c65d
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 0 - 7
Unity/Assets/Scripts/Model/Share/Module/Message/MessageHandlerAttribute.cs

@@ -11,11 +11,4 @@ namespace ET
             this.SceneType = sceneType;
         }
     }
-    
-    public class MessageRpcHandlerAttribute: MessageHandlerAttribute
-    {
-        public MessageRpcHandlerAttribute(SceneType sceneType): base(sceneType)
-        {
-        }
-    }
 }