Pārlūkot izejas kodu

Callback改成Invoke,这样更加含义清晰

tanghai 3 gadi atpakaļ
vecāks
revīzija
b11561e6cc
50 mainītis faili ar 163 papildinājumiem un 212 dzēšanām
  1. 4 4
      DotNet/App/ConfigLoader.cs
  2. 2 2
      DotNet/ThirdParty/DotNet.ThirdParty.csproj
  3. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Robot/Case/RobotCase_FirstCase.cs
  4. 2 2
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Robot/RobotConsoleHandler.cs
  5. 2 2
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/Actor/ActorMessageSenderComponentSystem.cs
  6. 2 2
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/ActorLocationSenderComponentSystem.cs
  7. 3 3
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/RobotCase/ARobotCase.cs
  8. 2 2
      Unity/Assets/Scripts/Codes/Hotfix/Share/Module/AI/AIComponentSystem.cs
  9. 2 2
      Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Message/SessionAcceptTimeoutComponentSystem.cs
  10. 2 2
      Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Message/SessionIdleCheckerComponentSystem.cs
  11. 2 2
      Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Move/MoveComponentSystem.cs
  12. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Recast/NavmeshComponentSystem.cs
  13. 2 2
      Unity/Assets/Scripts/Codes/Model/Server/Demo/Map/Recast/RecastFileReader.cs
  14. 0 8
      Unity/Assets/Scripts/Codes/Model/Server/Module/RobotCase/RobotCallbackArgs.cs
  15. 7 0
      Unity/Assets/Scripts/Codes/Model/Server/Module/RobotCase/RobotInvokeArgs.cs
  16. 1 1
      Unity/Assets/Scripts/Codes/Model/Server/Module/RobotCase/RobotInvokeArgs.cs.meta
  17. 0 22
      Unity/Assets/Scripts/Codes/Model/Share/Module/Message/SessionStreamCallback.cs
  18. 1 3
      Unity/Assets/Scripts/Codes/Model/Share/Module/Recast/NavmeshComponent.cs
  19. 2 2
      Unity/Assets/Scripts/Codes/Model/Share/TimerInvokeType.cs
  20. 1 1
      Unity/Assets/Scripts/Codes/Model/Share/TimerInvokeType.cs.meta
  21. 4 4
      Unity/Assets/Scripts/Codes/ModelView/Client/Demo/Config/ConfigLoader.cs
  22. 0 0
      Unity/Assets/Scripts/Core/Analyzer/EnableClassAttribute.cs
  23. 0 0
      Unity/Assets/Scripts/Core/Analyzer/EnableClassAttribute.cs.meta
  24. 5 7
      Unity/Assets/Scripts/Core/Module/Config/ConfigComponent.cs
  25. 1 1
      Unity/Assets/Scripts/Core/Module/CoroutineLock/CoroutineLockQueue.cs
  26. 1 1
      Unity/Assets/Scripts/Core/Module/CoroutineLock/WaitCoroutineLock.cs
  27. 0 12
      Unity/Assets/Scripts/Core/Module/EventSystem/CallbackAttribute.cs
  28. 35 30
      Unity/Assets/Scripts/Core/Module/EventSystem/EventSystem.cs
  29. 0 38
      Unity/Assets/Scripts/Core/Module/EventSystem/ICallback.cs
  30. 0 11
      Unity/Assets/Scripts/Core/Module/EventSystem/ICallback.cs.meta
  31. 6 3
      Unity/Assets/Scripts/Core/Module/EventSystem/IEvent.cs
  32. 35 0
      Unity/Assets/Scripts/Core/Module/EventSystem/IInvoke.cs
  33. 1 1
      Unity/Assets/Scripts/Core/Module/EventSystem/IInvoke.cs.meta
  34. 12 0
      Unity/Assets/Scripts/Core/Module/EventSystem/InvokeAttribute.cs
  35. 1 1
      Unity/Assets/Scripts/Core/Module/EventSystem/InvokeAttribute.cs.meta
  36. 0 8
      Unity/Assets/Scripts/Core/Module/Random.meta
  37. 1 1
      Unity/Assets/Scripts/Core/Module/Timer/ATimer.cs
  38. 3 4
      Unity/Assets/Scripts/Core/Module/Timer/TimerComponent.cs
  39. 0 7
      Unity/Assets/Scripts/Core/TimerCoreCallbackId.cs
  40. 0 3
      Unity/Assets/Scripts/Core/TimerCoreCallbackId.cs.meta
  41. 8 0
      Unity/Assets/Scripts/Core/TimerCoreInvokeType.cs
  42. 11 0
      Unity/Assets/Scripts/Core/TimerCoreInvokeType.cs.meta
  43. 0 8
      Unity/Assets/Scripts/Mono/HybridCLR.meta
  44. 0 0
      Unity/Assets/Scripts/ThirdParty/Kcp.meta
  45. 0 0
      Unity/Assets/Scripts/ThirdParty/Kcp/Kcp.cs
  46. 0 0
      Unity/Assets/Scripts/ThirdParty/Kcp/Kcp.cs.meta
  47. 0 0
      Unity/Assets/Scripts/ThirdParty/Recast.meta
  48. 0 0
      Unity/Assets/Scripts/ThirdParty/Recast/Recast.cs
  49. 0 0
      Unity/Assets/Scripts/ThirdParty/Recast/Recast.cs.meta
  50. 0 8
      Unity/Assets/Scripts/ThirdParty/ShareLib.meta

+ 4 - 4
DotNet/App/ConfigLoader.cs

@@ -4,8 +4,8 @@ using System.IO;
 
 
 namespace ET
 namespace ET
 {
 {
-    [Callback]
-    public class GetAllConfigBytes: ACallbackHandler<ConfigComponent.GetAllConfigBytes, Dictionary<string, byte[]>>
+    [Invoke]
+    public class GetAllConfigBytes: AInvokeHandler<ConfigComponent.GetAllConfigBytes, Dictionary<string, byte[]>>
     {
     {
         public override Dictionary<string, byte[]> Handle(ConfigComponent.GetAllConfigBytes args)
         public override Dictionary<string, byte[]> Handle(ConfigComponent.GetAllConfigBytes args)
         {
         {
@@ -36,8 +36,8 @@ namespace ET
         }
         }
     }
     }
     
     
-    [Callback]
-    public class GetOneConfigBytes: ACallbackHandler<ConfigComponent.GetOneConfigBytes, byte[]>
+    [Invoke]
+    public class GetOneConfigBytes: AInvokeHandler<ConfigComponent.GetOneConfigBytes, byte[]>
     {
     {
         public override byte[] Handle(ConfigComponent.GetOneConfigBytes args)
         public override byte[] Handle(ConfigComponent.GetOneConfigBytes args)
         {
         {

+ 2 - 2
DotNet/ThirdParty/DotNet.ThirdParty.csproj

@@ -34,11 +34,11 @@
         <Link>ETTask/%(RecursiveDir)%(FileName)%(Extension)</Link>
         <Link>ETTask/%(RecursiveDir)%(FileName)%(Extension)</Link>
     </Compile>
     </Compile>
 
 
-    <Compile Include="..\..\Unity\Assets\Scripts\ThirdParty\ShareLib\Kcp\Kcp.cs">
+    <Compile Include="..\..\Unity\Assets\Scripts\ThirdParty\Kcp\Kcp.cs">
       <Link>Kcp\Kcp.cs</Link>
       <Link>Kcp\Kcp.cs</Link>
     </Compile>
     </Compile>
 
 
-    <Compile Include="..\..\Unity\Assets\Scripts\ThirdParty\ShareLib\Recast\Recast.cs">
+    <Compile Include="..\..\Unity\Assets\Scripts\ThirdParty\Recast\Recast.cs">
       <Link>Recast\Recast.cs</Link>
       <Link>Recast\Recast.cs</Link>
     </Compile>
     </Compile>
 
 

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Robot/Case/RobotCase_FirstCase.cs

@@ -2,7 +2,7 @@ using System;
 
 
 namespace ET.Server
 namespace ET.Server
 {
 {
-    [Callback(RobotCaseType.FirstCase)]
+    [Invoke(RobotCaseType.FirstCase)]
     public class RobotCase_FirstCase: ARobotCase
     public class RobotCase_FirstCase: ARobotCase
     {
     {
         protected override async ETTask Run(RobotCase robotCase)
         protected override async ETTask Run(RobotCase robotCase)

+ 2 - 2
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Robot/RobotConsoleHandler.cs

@@ -21,7 +21,7 @@ namespace ET.Server
                     try
                     try
                     {
                     {
                         RobotLog.Debug($"run case start: {caseType}");
                         RobotLog.Debug($"run case start: {caseType}");
-                        await EventSystem.Instance.Callback<RobotCallbackArgs, ETTask>(new RobotCallbackArgs() {Id = caseType, Content = content});
+                        await EventSystem.Instance.Invoke<RobotInvokeArgs, ETTask>(caseType, new RobotInvokeArgs() { Content = content });
                         RobotLog.Debug($"run case finish: {caseType}");
                         RobotLog.Debug($"run case finish: {caseType}");
                     }
                     }
                     catch (Exception e)
                     catch (Exception e)
@@ -44,7 +44,7 @@ namespace ET.Server
                         try
                         try
                         {
                         {
                             RobotLog.Debug($"run case start: {caseType}");
                             RobotLog.Debug($"run case start: {caseType}");
-                            await EventSystem.Instance.Callback<RobotCallbackArgs, ETTask>(new RobotCallbackArgs() {Id = caseType, Content = content});
+                            await EventSystem.Instance.Invoke<RobotInvokeArgs, ETTask>(caseType, new RobotInvokeArgs() { Content = content});
                             RobotLog.Debug($"---------run case finish: {caseType}");
                             RobotLog.Debug($"---------run case finish: {caseType}");
                         }
                         }
                         catch (Exception e)
                         catch (Exception e)

+ 2 - 2
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/Actor/ActorMessageSenderComponentSystem.cs

@@ -6,7 +6,7 @@ namespace ET.Server
     [FriendOf(typeof(ActorMessageSenderComponent))]
     [FriendOf(typeof(ActorMessageSenderComponent))]
     public static class ActorMessageSenderComponentSystem
     public static class ActorMessageSenderComponentSystem
     {
     {
-        [Callback(TimerCallbackId.ActorMessageSenderChecker)]
+        [Invoke(TimerInvokeType.ActorMessageSenderChecker)]
         public class ActorMessageSenderChecker: ATimer<ActorMessageSenderComponent>
         public class ActorMessageSenderChecker: ATimer<ActorMessageSenderComponent>
         {
         {
             protected override void Run(ActorMessageSenderComponent self)
             protected override void Run(ActorMessageSenderComponent self)
@@ -29,7 +29,7 @@ namespace ET.Server
             {
             {
                 ActorMessageSenderComponent.Instance = self;
                 ActorMessageSenderComponent.Instance = self;
 
 
-                self.TimeoutCheckTimer = TimerComponent.Instance.NewRepeatedTimer(1000, TimerCallbackId.ActorMessageSenderChecker, self);
+                self.TimeoutCheckTimer = TimerComponent.Instance.NewRepeatedTimer(1000, TimerInvokeType.ActorMessageSenderChecker, self);
             }
             }
         }
         }
 
 

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

@@ -4,7 +4,7 @@ using MongoDB.Bson;
 
 
 namespace ET.Server
 namespace ET.Server
 {
 {
-    [Callback(TimerCallbackId.ActorLocationSenderChecker)]
+    [Invoke(TimerInvokeType.ActorLocationSenderChecker)]
     public class ActorLocationSenderChecker: ATimer<ActorLocationSenderComponent>
     public class ActorLocationSenderChecker: ATimer<ActorLocationSenderComponent>
     {
     {
         protected override void Run(ActorLocationSenderComponent self)
         protected override void Run(ActorLocationSenderComponent self)
@@ -29,7 +29,7 @@ namespace ET.Server
 
 
             // 每10s扫描一次过期的actorproxy进行回收,过期时间是2分钟
             // 每10s扫描一次过期的actorproxy进行回收,过期时间是2分钟
             // 可能由于bug或者进程挂掉,导致ActorLocationSender发送的消息没有确认,结果无法自动删除,每一分钟清理一次这种ActorLocationSender
             // 可能由于bug或者进程挂掉,导致ActorLocationSender发送的消息没有确认,结果无法自动删除,每一分钟清理一次这种ActorLocationSender
-            self.CheckTimer = TimerComponent.Instance.NewRepeatedTimer(10 * 1000, TimerCallbackId.ActorLocationSenderChecker, self);
+            self.CheckTimer = TimerComponent.Instance.NewRepeatedTimer(10 * 1000, TimerInvokeType.ActorLocationSenderChecker, self);
         }
         }
     }
     }
 
 

+ 3 - 3
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/RobotCase/ARobotCase.cs

@@ -2,11 +2,11 @@ namespace ET.Server
 {
 {
     // 这里为什么能定义class呢?因为这里只有逻辑,热重载后新的handler替换旧的,仍然没有问题
     // 这里为什么能定义class呢?因为这里只有逻辑,热重载后新的handler替换旧的,仍然没有问题
     [EnableClass]
     [EnableClass]
-    public abstract class ARobotCase: ACallbackHandler<RobotCallbackArgs, ETTask>
+    public abstract class ARobotCase: AInvokeHandler<RobotInvokeArgs, ETTask>
     {
     {
         protected abstract ETTask Run(RobotCase robotCase);
         protected abstract ETTask Run(RobotCase robotCase);
 
 
-        public override async ETTask Handle(RobotCallbackArgs a)
+        public override async ETTask Handle(RobotInvokeArgs a)
         {
         {
             using RobotCase robotCase = await RobotCaseComponent.Instance.New();
             using RobotCase robotCase = await RobotCaseComponent.Instance.New();
             
             
@@ -17,7 +17,7 @@ namespace ET.Server
             catch (System.Exception e)
             catch (System.Exception e)
             {
             {
                 Log.Error($"{robotCase.DomainZone()} {e}");
                 Log.Error($"{robotCase.DomainZone()} {e}");
-                RobotLog.Console($"RobotCase Error {a.Id}:\n\t{e}");
+                RobotLog.Console($"RobotCase Error {this.GetType().Name}:\n\t{e}");
             }
             }
         }
         }
     }
     }

+ 2 - 2
Unity/Assets/Scripts/Codes/Hotfix/Share/Module/AI/AIComponentSystem.cs

@@ -6,7 +6,7 @@ namespace ET
     [FriendOf(typeof(AIDispatcherComponent))]
     [FriendOf(typeof(AIDispatcherComponent))]
     public static class AIComponentSystem
     public static class AIComponentSystem
     {
     {
-        [Callback(TimerCallbackId.AITimer)]
+        [Invoke(TimerInvokeType.AITimer)]
         public class AITimer: ATimer<AIComponent>
         public class AITimer: ATimer<AIComponent>
         {
         {
             protected override void Run(AIComponent self)
             protected override void Run(AIComponent self)
@@ -28,7 +28,7 @@ namespace ET
             protected override void Awake(AIComponent self, int aiConfigId)
             protected override void Awake(AIComponent self, int aiConfigId)
             {
             {
                 self.AIConfigId = aiConfigId;
                 self.AIConfigId = aiConfigId;
-                self.Timer = TimerComponent.Instance.NewRepeatedTimer(1000, TimerCallbackId.AITimer, self);
+                self.Timer = TimerComponent.Instance.NewRepeatedTimer(1000, TimerInvokeType.AITimer, self);
             }
             }
         }
         }
 
 

+ 2 - 2
Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Message/SessionAcceptTimeoutComponentSystem.cs

@@ -2,7 +2,7 @@
 
 
 namespace ET
 namespace ET
 {
 {
-    [Callback(TimerCallbackId.SessionAcceptTimeout)]
+    [Invoke(TimerInvokeType.SessionAcceptTimeout)]
     public class SessionAcceptTimeout: ATimer<SessionAcceptTimeoutComponent>
     public class SessionAcceptTimeout: ATimer<SessionAcceptTimeoutComponent>
     {
     {
         protected override void Run(SessionAcceptTimeoutComponent self)
         protected override void Run(SessionAcceptTimeoutComponent self)
@@ -23,7 +23,7 @@ namespace ET
     {
     {
         protected override void Awake(SessionAcceptTimeoutComponent self)
         protected override void Awake(SessionAcceptTimeoutComponent self)
         {
         {
-            self.Timer = TimerComponent.Instance.NewOnceTimer(TimeHelper.ServerNow() + 5000, TimerCallbackId.SessionAcceptTimeout, self);
+            self.Timer = TimerComponent.Instance.NewOnceTimer(TimeHelper.ServerNow() + 5000, TimerInvokeType.SessionAcceptTimeout, self);
         }
         }
     }
     }
 
 

+ 2 - 2
Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Message/SessionIdleCheckerComponentSystem.cs

@@ -2,7 +2,7 @@ using System;
 
 
 namespace ET
 namespace ET
 {
 {
-    [Callback(TimerCallbackId.SessionIdleChecker)]
+    [Invoke(TimerInvokeType.SessionIdleChecker)]
     public class SessionIdleChecker: ATimer<SessionIdleCheckerComponent>
     public class SessionIdleChecker: ATimer<SessionIdleCheckerComponent>
     {
     {
         protected override void Run(SessionIdleCheckerComponent self)
         protected override void Run(SessionIdleCheckerComponent self)
@@ -23,7 +23,7 @@ namespace ET
     {
     {
         protected override void Awake(SessionIdleCheckerComponent self)
         protected override void Awake(SessionIdleCheckerComponent self)
         {
         {
-            self.RepeatedTimer = TimerComponent.Instance.NewRepeatedTimer(SessionIdleCheckerComponentSystem.CheckInteral, TimerCallbackId.SessionIdleChecker, self);
+            self.RepeatedTimer = TimerComponent.Instance.NewRepeatedTimer(SessionIdleCheckerComponentSystem.CheckInteral, TimerInvokeType.SessionIdleChecker, self);
         }
         }
     }
     }
 
 

+ 2 - 2
Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Move/MoveComponentSystem.cs

@@ -7,7 +7,7 @@ namespace ET
     [FriendOf(typeof(MoveComponent))]
     [FriendOf(typeof(MoveComponent))]
     public static class MoveComponentSystem
     public static class MoveComponentSystem
     {
     {
-        [Callback(TimerCallbackId.MoveTimer)]
+        [Invoke(TimerInvokeType.MoveTimer)]
         public class MoveTimer: ATimer<MoveComponent>
         public class MoveTimer: ATimer<MoveComponent>
         {
         {
             protected override void Run(MoveComponent self)
             protected override void Run(MoveComponent self)
@@ -201,7 +201,7 @@ namespace ET
             self.StartTime = self.BeginTime;
             self.StartTime = self.BeginTime;
             self.SetNextTarget();
             self.SetNextTarget();
 
 
-            self.MoveTimer = TimerComponent.Instance.NewFrameTimer(TimerCallbackId.MoveTimer, self);
+            self.MoveTimer = TimerComponent.Instance.NewFrameTimer(TimerInvokeType.MoveTimer, self);
         }
         }
 
 
         private static void SetNextTarget(this MoveComponent self)
         private static void SetNextTarget(this MoveComponent self)

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Recast/NavmeshComponentSystem.cs

@@ -21,7 +21,7 @@ namespace ET
                 return ptr;
                 return ptr;
             }
             }
 
 
-            byte[] buffer = EventSystem.Instance.Callback<NavmeshComponent.RecastFileLoader, byte[]>(new NavmeshComponent.RecastFileLoader() {Name = name});
+            byte[] buffer = EventSystem.Instance.Invoke<NavmeshComponent.RecastFileLoader, byte[]>(0, new NavmeshComponent.RecastFileLoader() {Name = name});
             if (buffer.Length == 0)
             if (buffer.Length == 0)
             {
             {
                 throw new Exception($"no nav data: {name}");
                 throw new Exception($"no nav data: {name}");

+ 2 - 2
Unity/Assets/Scripts/Codes/Model/Server/Demo/Map/Recast/RecastFileReader.cs

@@ -2,8 +2,8 @@
 
 
 namespace ET.Server
 namespace ET.Server
 {
 {
-    [Callback]
-    public class RecastFileReader: ACallbackHandler<NavmeshComponent.RecastFileLoader, byte[]>
+    [Invoke]
+    public class RecastFileReader: AInvokeHandler<NavmeshComponent.RecastFileLoader, byte[]>
     {
     {
         public override byte[] Handle(NavmeshComponent.RecastFileLoader args)
         public override byte[] Handle(NavmeshComponent.RecastFileLoader args)
         {
         {

+ 0 - 8
Unity/Assets/Scripts/Codes/Model/Server/Module/RobotCase/RobotCallbackArgs.cs

@@ -1,8 +0,0 @@
-namespace ET.Server
-{
-    public struct RobotCallbackArgs: ICallback
-    {
-        public int Id { get; set; }
-        public string Content { get; set; }
-    }
-}

+ 7 - 0
Unity/Assets/Scripts/Codes/Model/Server/Module/RobotCase/RobotInvokeArgs.cs

@@ -0,0 +1,7 @@
+namespace ET.Server
+{
+    public struct RobotInvokeArgs
+    {
+        public string Content { get; set; }
+    }
+}

+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Share/TimerCallbackId.cs.meta → Unity/Assets/Scripts/Codes/Model/Server/Module/RobotCase/RobotInvokeArgs.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
 fileFormatVersion: 2
-guid: 7f805ddc768dd7340bdce6f934c915f8
+guid: 6f570483ab9a6f8458ab9346fa863a63
 MonoImporter:
 MonoImporter:
   externalObjects: {}
   externalObjects: {}
   serializedVersion: 2
   serializedVersion: 2

+ 0 - 22
Unity/Assets/Scripts/Codes/Model/Share/Module/Message/SessionStreamCallback.cs

@@ -1,22 +0,0 @@
-using System.IO;
-
-namespace ET
-{
-    public static class SessionStreamCallbackId
-    {
-        public const int NetClient = 1;
-        public const int NetServer = 2;
-        public const int NetInner = 3;
-    }
-    
-    public struct SessionStreamCallback: ICallback
-    {
-        public int Id { get; set; }
-
-        public Session Session;
-
-        public long ActorId;
-        
-        public object Message;
-    }
-}

+ 1 - 3
Unity/Assets/Scripts/Codes/Model/Share/Module/Recast/NavmeshComponent.cs

@@ -9,10 +9,8 @@ namespace ET
         [StaticField]
         [StaticField]
         public static NavmeshComponent Instance;
         public static NavmeshComponent Instance;
         
         
-        public struct RecastFileLoader: ICallback
+        public struct RecastFileLoader
         {
         {
-            public int Id { get; set; }
-            
             public string Name { get; set; }
             public string Name { get; set; }
         }
         }
         
         

+ 2 - 2
Unity/Assets/Scripts/Codes/Model/Share/TimerCallbackId.cs → Unity/Assets/Scripts/Codes/Model/Share/TimerInvokeType.cs

@@ -1,7 +1,7 @@
 namespace ET
 namespace ET
 {
 {
-    [UniqueId(1,10000)]
-    public static class TimerCallbackId
+    [UniqueId(100, 10000)]
+    public static class TimerInvokeType
     {
     {
         // 框架层100-200,逻辑层的timer type从200起
         // 框架层100-200,逻辑层的timer type从200起
         public const int WaitTimer = 100;
         public const int WaitTimer = 100;

+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Server/Module/RobotCase/RobotCallbackArgs.cs.meta → Unity/Assets/Scripts/Codes/Model/Share/TimerInvokeType.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
 fileFormatVersion: 2
-guid: d2c0dce0a8a880e46b85f18ee6004b92
+guid: e21dc85ec77863f499b5e84300f8aaa0
 MonoImporter:
 MonoImporter:
   externalObjects: {}
   externalObjects: {}
   serializedVersion: 2
   serializedVersion: 2

+ 4 - 4
Unity/Assets/Scripts/Codes/ModelView/Client/Demo/Config/ConfigLoader.cs

@@ -5,8 +5,8 @@ using UnityEngine;
 
 
 namespace ET.Client
 namespace ET.Client
 {
 {
-    [Callback]
-    public class GetAllConfigBytes: ACallbackHandler<ConfigComponent.GetAllConfigBytes, Dictionary<string, byte[]>>
+    [Invoke]
+    public class GetAllConfigBytes: AInvokeHandler<ConfigComponent.GetAllConfigBytes, Dictionary<string, byte[]>>
     {
     {
         public override Dictionary<string, byte[]> Handle(ConfigComponent.GetAllConfigBytes args)
         public override Dictionary<string, byte[]> Handle(ConfigComponent.GetAllConfigBytes args)
         {
         {
@@ -71,8 +71,8 @@ namespace ET.Client
         }
         }
     }
     }
     
     
-    [Callback]
-    public class GetOneConfigBytes: ACallbackHandler<ConfigComponent.GetOneConfigBytes, byte[]>
+    [Invoke]
+    public class GetOneConfigBytes: AInvokeHandler<ConfigComponent.GetOneConfigBytes, byte[]>
     {
     {
         public override byte[] Handle(ConfigComponent.GetOneConfigBytes args)
         public override byte[] Handle(ConfigComponent.GetOneConfigBytes args)
         {
         {

+ 0 - 0
Unity/Assets/Scripts/Core/Object/EnableClassAttribute.cs → Unity/Assets/Scripts/Core/Analyzer/EnableClassAttribute.cs


+ 0 - 0
Unity/Assets/Scripts/Core/Object/EnableClassAttribute.cs.meta → Unity/Assets/Scripts/Core/Analyzer/EnableClassAttribute.cs.meta


+ 5 - 7
Unity/Assets/Scripts/Core/Module/Config/ConfigComponent.cs

@@ -9,14 +9,12 @@ namespace ET
     /// </summary>
     /// </summary>
     public class ConfigComponent: Singleton<ConfigComponent>
     public class ConfigComponent: Singleton<ConfigComponent>
     {
     {
-        public struct GetAllConfigBytes: ICallback
+        public struct GetAllConfigBytes
         {
         {
-            public int Id { get; set; }
         }
         }
         
         
-        public struct GetOneConfigBytes: ICallback
+        public struct GetOneConfigBytes
         {
         {
-            public int Id { get; set; }
             public string ConfigName;
             public string ConfigName;
         }
         }
 		
 		
@@ -38,7 +36,7 @@ namespace ET
 				oneConfig.Destroy();
 				oneConfig.Destroy();
 			}
 			}
 			
 			
-			byte[] oneConfigBytes = EventSystem.Instance.Callback<GetOneConfigBytes, byte[]>(new GetOneConfigBytes() {ConfigName = configType.FullName});
+			byte[] oneConfigBytes = EventSystem.Instance.Invoke<GetOneConfigBytes, byte[]>(0, new GetOneConfigBytes() {ConfigName = configType.FullName});
 
 
 			object category = ProtobufHelper.FromBytes(configType, oneConfigBytes, 0, oneConfigBytes.Length);
 			object category = ProtobufHelper.FromBytes(configType, oneConfigBytes, 0, oneConfigBytes.Length);
 			ISingleton singleton = category as ISingleton;
 			ISingleton singleton = category as ISingleton;
@@ -54,7 +52,7 @@ namespace ET
 			HashSet<Type> types = EventSystem.Instance.GetTypes(typeof (ConfigAttribute));
 			HashSet<Type> types = EventSystem.Instance.GetTypes(typeof (ConfigAttribute));
 			
 			
 			Dictionary<string, byte[]> configBytes = 
 			Dictionary<string, byte[]> configBytes = 
-			EventSystem.Instance.Callback<GetAllConfigBytes, Dictionary<string, byte[]>>(
+			EventSystem.Instance.Invoke<GetAllConfigBytes, Dictionary<string, byte[]>>(0, 
 				new GetAllConfigBytes());
 				new GetAllConfigBytes());
 
 
 			foreach (Type type in types)
 			foreach (Type type in types)
@@ -69,7 +67,7 @@ namespace ET
 			HashSet<Type> types = EventSystem.Instance.GetTypes(typeof (ConfigAttribute));
 			HashSet<Type> types = EventSystem.Instance.GetTypes(typeof (ConfigAttribute));
 			
 			
 			Dictionary<string, byte[]> configBytes = 
 			Dictionary<string, byte[]> configBytes = 
-					EventSystem.Instance.Callback<GetAllConfigBytes, Dictionary<string, byte[]>>(
+					EventSystem.Instance.Invoke<GetAllConfigBytes, Dictionary<string, byte[]>>(0,
 						new GetAllConfigBytes());
 						new GetAllConfigBytes());
 
 
 			using ListComponent<Task> listTasks = ListComponent<Task>.Create();
 			using ListComponent<Task> listTasks = ListComponent<Task>.Create();

+ 1 - 1
Unity/Assets/Scripts/Core/Module/CoroutineLock/CoroutineLockQueue.cs

@@ -41,7 +41,7 @@ namespace ET
             if (time > 0)
             if (time > 0)
             {
             {
                 long tillTime = TimeHelper.ClientFrameTime() + time;
                 long tillTime = TimeHelper.ClientFrameTime() + time;
-                TimerComponent.Instance.NewOnceTimer(tillTime, TimerCoreCallbackId.CoroutineTimeout, waitCoroutineLock);
+                TimerComponent.Instance.NewOnceTimer(tillTime, TimerCoreInvokeType.CoroutineTimeout, waitCoroutineLock);
             }
             }
             this.currentCoroutineLock = await waitCoroutineLock.Wait();
             this.currentCoroutineLock = await waitCoroutineLock.Wait();
             return this.currentCoroutineLock;
             return this.currentCoroutineLock;

+ 1 - 1
Unity/Assets/Scripts/Core/Module/CoroutineLock/WaitCoroutineLock.cs

@@ -3,7 +3,7 @@ using System.Threading;
 
 
 namespace ET
 namespace ET
 {
 {
-    [Callback(TimerCoreCallbackId.CoroutineTimeout)]
+    [Invoke(TimerCoreInvokeType.CoroutineTimeout)]
     public class WaitCoroutineLockTimer: ATimer<WaitCoroutineLock>
     public class WaitCoroutineLockTimer: ATimer<WaitCoroutineLock>
     {
     {
         protected override void Run(WaitCoroutineLock waitCoroutineLock)
         protected override void Run(WaitCoroutineLock waitCoroutineLock)

+ 0 - 12
Unity/Assets/Scripts/Core/Module/EventSystem/CallbackAttribute.cs

@@ -1,12 +0,0 @@
-namespace ET
-{
-    public class CallbackAttribute: BaseAttribute
-    {
-        public int Id { get; }
-
-        public CallbackAttribute(int id = 0)
-        {
-            this.Id = id;
-        }
-    }
-}

+ 35 - 30
Unity/Assets/Scripts/Core/Module/EventSystem/EventSystem.cs

@@ -72,7 +72,7 @@ namespace ET
 
 
         private readonly Dictionary<Type, List<EventInfo>> allEvents = new();
         private readonly Dictionary<Type, List<EventInfo>> allEvents = new();
         
         
-        private Dictionary<Type, Dictionary<int, object>> allCallbacks = new Dictionary<Type, Dictionary<int, object>>(); 
+        private Dictionary<Type, Dictionary<int, object>> allInvokes = new(); 
 
 
         private TypeSystems typeSystems = new();
         private TypeSystems typeSystems = new();
 
 
@@ -169,7 +169,7 @@ namespace ET
                 {
                 {
                     EventAttribute eventAttribute = attr as EventAttribute;
                     EventAttribute eventAttribute = attr as EventAttribute;
 
 
-                    Type eventType = obj.GetEventType();
+                    Type eventType = obj.Type;
 
 
                     EventInfo eventInfo = new(obj, eventAttribute.SceneType);
                     EventInfo eventInfo = new(obj, eventAttribute.SceneType);
 
 
@@ -181,34 +181,34 @@ namespace ET
                 }
                 }
             }
             }
 
 
-            this.allCallbacks = new Dictionary<Type, Dictionary<int, object>>();
-            foreach (Type type in types[typeof (CallbackAttribute)])
+            this.allInvokes = new Dictionary<Type, Dictionary<int, object>>();
+            foreach (Type type in types[typeof (InvokeAttribute)])
             {
             {
                 object obj = Activator.CreateInstance(type);
                 object obj = Activator.CreateInstance(type);
-                ICallbackType iCallbackType = obj as ICallbackType;
-                if (iCallbackType == null)
+                IInvoke iInvoke = obj as IInvoke;
+                if (iInvoke == null)
                 {
                 {
                     throw new Exception($"type not is callback: {type.Name}");
                     throw new Exception($"type not is callback: {type.Name}");
                 }
                 }
                 
                 
-                object[] attrs = type.GetCustomAttributes(typeof(CallbackAttribute), false);
+                object[] attrs = type.GetCustomAttributes(typeof(InvokeAttribute), false);
                 foreach (object attr in attrs)
                 foreach (object attr in attrs)
                 {
                 {
-                    if (!this.allCallbacks.TryGetValue(iCallbackType.Type, out var dict))
+                    if (!this.allInvokes.TryGetValue(iInvoke.Type, out var dict))
                     {
                     {
                         dict = new Dictionary<int, object>();
                         dict = new Dictionary<int, object>();
-                        this.allCallbacks.Add(iCallbackType.Type, dict);
+                        this.allInvokes.Add(iInvoke.Type, dict);
                     }
                     }
                     
                     
-                    CallbackAttribute callbackAttribute = attr as CallbackAttribute;
+                    InvokeAttribute invokeAttribute = attr as InvokeAttribute;
                     
                     
                     try
                     try
                     {
                     {
-                        dict.Add(callbackAttribute.Id, obj);
+                        dict.Add(invokeAttribute.Type, obj);
                     }
                     }
                     catch (Exception e)
                     catch (Exception e)
                     {
                     {
-                        throw new Exception($"action type duplicate: {iCallbackType.Type.Name} {callbackAttribute.Id}", e);
+                        throw new Exception($"action type duplicate: {iInvoke.Type.Name} {invokeAttribute.Type}", e);
                     }
                     }
                     
                     
                 }
                 }
@@ -712,44 +712,49 @@ namespace ET
             }
             }
         }
         }
         
         
-        public void Callback<A>(A args) where A: struct, ICallback
+        // Invoke跟Publish的区别(特别注意)
+        // Invoke类似函数,必须有被调用方,否则异常,调用者跟被调用者属于同一模块,比如MoveComponent中的Timer计时器,调用跟被调用的代码均属于移动模块
+        // 既然Invoke跟函数一样,那么为什么不使用函数呢? 因为有时候不方便直接调用,比如Config加载,在客户端跟服务端加载方式不一样。比如TimerComponent需要根据Id分发
+        // 注意,不要把Invoke当函数使用,这样会造成代码可读性降低,能用函数不要用Invoke
+        // publish是事件,抛出去可以没人订阅,调用者跟被调用者属于两个模块,比如任务系统需要知道道具使用的信息,则订阅道具使用事件
+        public void Invoke<A>(int type, A args) where A: struct
         {
         {
-            if (!this.allCallbacks.TryGetValue(typeof(A), out var callbackHandlers))
+            if (!this.allInvokes.TryGetValue(typeof(A), out var invokeHandlers))
             {
             {
-                throw new Exception($"Callback error: {typeof(A).Name}");
+                throw new Exception($"Invoke error: {typeof(A).Name}");
             }
             }
-            if (!callbackHandlers.TryGetValue(args.Id, out var callbackHandler))
+            if (!invokeHandlers.TryGetValue(type, out var invokeHandler))
             {
             {
-                throw new Exception($"Callback error: {typeof(A).Name} {args.Id}");
+                throw new Exception($"Invoke error: {typeof(A).Name} {type}");
             }
             }
 
 
-            var aCallbackHandler = callbackHandler as ACallbackHandler<A>;
-            if (aCallbackHandler == null)
+            var aInvokeHandler = invokeHandler as AInvokeHandler<A>;
+            if (aInvokeHandler == null)
             {
             {
-                throw new Exception($"Callback error, not ACallbackHandler: {typeof(A).Name} {args.Id}");
+                throw new Exception($"Invoke error, not AInvokeHandler: {typeof(A).Name} {type}");
             }
             }
             
             
-            aCallbackHandler.Handle(args);
+            aInvokeHandler.Handle(args);
         }
         }
         
         
-        public T Callback<A, T>(A args) where A: struct, ICallback
+        public T Invoke<A, T>(int type, A args) where A: struct
         {
         {
-            if (!this.allCallbacks.TryGetValue(typeof(A), out var callbackHandlers))
+            if (!this.allInvokes.TryGetValue(typeof(A), out var invokeHandlers))
             {
             {
-                throw new Exception($"ResultCallback error: {typeof(A).Name}");
+                throw new Exception($"Invoke error: {typeof(A).Name}");
             }
             }
-            if (!callbackHandlers.TryGetValue(args.Id, out var callbackHandler))
+            if (!invokeHandlers.TryGetValue(type, out var invokeHandler))
             {
             {
-                throw new Exception($"ResultCallback error: {typeof(A).Name} {args.Id}");
+                throw new Exception($"Invoke error: {typeof(A).Name} {type}");
             }
             }
 
 
-            var aCallbackHandler = callbackHandler as ACallbackHandler<A, T>;
-            if (aCallbackHandler == null)
+            var aInvokeHandler = invokeHandler as AInvokeHandler<A, T>;
+            if (aInvokeHandler == null)
             {
             {
-                throw new Exception($"ResultCallback error, not AResultCallbackHandler: {typeof(T).Name} {args.Id}");
+                throw new Exception($"Invoke error, not AInvokeHandler: {typeof(T).Name} {type}");
             }
             }
             
             
-            return aCallbackHandler.Handle(args);
+            return aInvokeHandler.Handle(args);
         }
         }
 
 
         public override string ToString()
         public override string ToString()

+ 0 - 38
Unity/Assets/Scripts/Core/Module/EventSystem/ICallback.cs

@@ -1,38 +0,0 @@
-namespace ET
-{
-    public interface ICallback
-    {
-        public int Id { get; set; }
-    }
-    
-    public interface ICallbackType
-    {
-        public System.Type Type { get; }
-    }
-    
-    public abstract class ACallbackHandler<A>: ICallbackType where A: struct, ICallback
-    {
-        public System.Type Type
-        {
-            get
-            {
-                return typeof (A);
-            }
-        }
-
-        public abstract void Handle(A a);
-    }
-    
-    public abstract class ACallbackHandler<A, T>: ICallbackType where A: struct, ICallback
-    {
-        public System.Type Type
-        {
-            get
-            {
-                return typeof (A);
-            }
-        }
-
-        public abstract T Handle(A a);
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Core/Module/EventSystem/ICallback.cs.meta

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

+ 6 - 3
Unity/Assets/Scripts/Core/Module/EventSystem/IEvent.cs

@@ -4,14 +4,17 @@ namespace ET
 {
 {
 	public interface IEvent
 	public interface IEvent
 	{
 	{
-		Type GetEventType();
+		Type Type { get; }
 	}
 	}
 	
 	
 	public abstract class AEvent<A>: IEvent where A: struct
 	public abstract class AEvent<A>: IEvent where A: struct
 	{
 	{
-		public Type GetEventType()
+		public Type Type
 		{
 		{
-			return typeof (A);
+			get
+			{
+				return typeof (A);
+			}
 		}
 		}
 
 
 		protected abstract ETTask Run(Scene scene, A a);
 		protected abstract ETTask Run(Scene scene, A a);

+ 35 - 0
Unity/Assets/Scripts/Core/Module/EventSystem/IInvoke.cs

@@ -0,0 +1,35 @@
+using System;
+
+namespace ET
+{
+    public interface IInvoke
+    {
+        Type Type { get; }
+    }
+    
+    public abstract class AInvokeHandler<A>: IInvoke where A: struct
+    {
+        public Type Type
+        {
+            get
+            {
+                return typeof (A);
+            }
+        }
+
+        public abstract void Handle(A a);
+    }
+    
+    public abstract class AInvokeHandler<A, T>: IInvoke where A: struct
+    {
+        public Type Type
+        {
+            get
+            {
+                return typeof (A);
+            }
+        }
+
+        public abstract T Handle(A a);
+    }
+}

+ 1 - 1
Unity/Assets/Scripts/Core/Module/EventSystem/CallbackAttribute.cs.meta → Unity/Assets/Scripts/Core/Module/EventSystem/IInvoke.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
 fileFormatVersion: 2
-guid: 8be914ccd2f63584d863666be75df807
+guid: fec8a605631db024fa246feb87beb5d0
 MonoImporter:
 MonoImporter:
   externalObjects: {}
   externalObjects: {}
   serializedVersion: 2
   serializedVersion: 2

+ 12 - 0
Unity/Assets/Scripts/Core/Module/EventSystem/InvokeAttribute.cs

@@ -0,0 +1,12 @@
+namespace ET
+{
+    public class InvokeAttribute: BaseAttribute
+    {
+        public int Type { get; }
+
+        public InvokeAttribute(int type = 0)
+        {
+            this.Type = type;
+        }
+    }
+}

+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Share/Module/Message/SessionStreamCallback.cs.meta → Unity/Assets/Scripts/Core/Module/EventSystem/InvokeAttribute.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
 fileFormatVersion: 2
-guid: f1a30124f310e024c9e852d550190daf
+guid: 31ef4af33bd048f49b0b9b0d9a9a0547
 MonoImporter:
 MonoImporter:
   externalObjects: {}
   externalObjects: {}
   serializedVersion: 2
   serializedVersion: 2

+ 0 - 8
Unity/Assets/Scripts/Core/Module/Random.meta

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

+ 1 - 1
Unity/Assets/Scripts/Core/Module/Timer/ATimer.cs

@@ -1,6 +1,6 @@
 namespace ET
 namespace ET
 {
 {
-    public abstract class ATimer<T>: ACallbackHandler<TimerCallback> where T: class
+    public abstract class ATimer<T>: AInvokeHandler<TimerCallback> where T: class
     {
     {
         public override void Handle(TimerCallback a)
         public override void Handle(TimerCallback a)
         {
         {

+ 3 - 4
Unity/Assets/Scripts/Core/Module/Timer/TimerComponent.cs

@@ -48,9 +48,8 @@ namespace ET
         }
         }
     }
     }
 
 
-    public struct TimerCallback: ICallback
+    public struct TimerCallback
     {
     {
-        public int Id { get; set; }
         public object Args;
         public object Args;
     }
     }
 
 
@@ -139,7 +138,7 @@ namespace ET
             {
             {
                 case TimerClass.OnceTimer:
                 case TimerClass.OnceTimer:
                 {
                 {
-                    EventSystem.Instance.Callback(new TimerCallback() { Id = timerAction.Type, Args = timerAction.Object });
+                    EventSystem.Instance.Invoke(timerAction.Type, new TimerCallback() { Args = timerAction.Object });
                     timerAction.Recycle();
                     timerAction.Recycle();
                     break;
                     break;
                 }
                 }
@@ -155,7 +154,7 @@ namespace ET
                     long timeNow = GetNow();
                     long timeNow = GetNow();
                     timerAction.StartTime = timeNow;
                     timerAction.StartTime = timeNow;
                     this.AddTimer(timerAction);
                     this.AddTimer(timerAction);
-                    EventSystem.Instance.Callback(new TimerCallback() { Id = timerAction.Type, Args = timerAction.Object });
+                    EventSystem.Instance.Invoke(timerAction.Type, new TimerCallback() { Args = timerAction.Object });
                     break;
                     break;
                 }
                 }
             }
             }

+ 0 - 7
Unity/Assets/Scripts/Core/TimerCoreCallbackId.cs

@@ -1,7 +0,0 @@
-namespace ET
-{
-    public static class TimerCoreCallbackId
-    {
-        public const int CoroutineTimeout = 10000;
-    }
-}

+ 0 - 3
Unity/Assets/Scripts/Core/TimerCoreCallbackId.cs.meta

@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: 59d803dbcb374c81a7a39c4a4d6973f8
-timeCreated: 1662172614

+ 8 - 0
Unity/Assets/Scripts/Core/TimerCoreInvokeType.cs

@@ -0,0 +1,8 @@
+namespace ET
+{
+    [UniqueId(0, 100)]
+    public static class TimerCoreInvokeType
+    {
+        public const int CoroutineTimeout = 1;
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Core/TimerCoreInvokeType.cs.meta

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

+ 0 - 8
Unity/Assets/Scripts/Mono/HybridCLR.meta

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

+ 0 - 0
Unity/Assets/Scripts/ThirdParty/ShareLib/Kcp.meta → Unity/Assets/Scripts/ThirdParty/Kcp.meta


+ 0 - 0
Unity/Assets/Scripts/ThirdParty/ShareLib/Kcp/Kcp.cs → Unity/Assets/Scripts/ThirdParty/Kcp/Kcp.cs


+ 0 - 0
Unity/Assets/Scripts/ThirdParty/ShareLib/Kcp/Kcp.cs.meta → Unity/Assets/Scripts/ThirdParty/Kcp/Kcp.cs.meta


+ 0 - 0
Unity/Assets/Scripts/ThirdParty/ShareLib/Recast.meta → Unity/Assets/Scripts/ThirdParty/Recast.meta


+ 0 - 0
Unity/Assets/Scripts/ThirdParty/ShareLib/Recast/Recast.cs → Unity/Assets/Scripts/ThirdParty/Recast/Recast.cs


+ 0 - 0
Unity/Assets/Scripts/ThirdParty/ShareLib/Recast/Recast.cs.meta → Unity/Assets/Scripts/ThirdParty/Recast/Recast.cs.meta


+ 0 - 8
Unity/Assets/Scripts/ThirdParty/ShareLib.meta

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