Explorar o código

1.Config跟Navmesh的加载改成统一回调
2.TimerType删除,使用统一回调,避免冲突

tanghai %!s(int64=3) %!d(string=hai) anos
pai
achega
6f793859d7
Modificáronse 42 ficheiros con 109 adicións e 145 borrados
  1. 5 5
      Apps/Hotfix/AppStart_Init.cs
  2. 2 2
      Apps/Hotfix/Module/Actor/ActorMessageSenderComponentSystem.cs
  3. 2 2
      Apps/Hotfix/Module/ActorLocation/ActorLocationSenderComponentSystem.cs
  4. 2 2
      Apps/Hotfix/Server/Scene/SceneFactory.cs
  5. 1 1
      Apps/Hotfix/Server/Session/SessionStreamDispatcherServerInner.cs
  6. 1 1
      Apps/Hotfix/Server/Session/SessionStreamDispatcherServerOuter.cs
  7. 2 7
      Apps/Model/Apps.Model.csproj
  8. 9 4
      Apps/Model/Base/ConfigLoader.cs
  9. 3 2
      Apps/Model/Server/RecastLoader/RecastFileReader.cs
  10. 5 5
      Apps/Tool/Apps.Tool.csproj
  11. 0 0
      Unity/Assets/Core/Entity/SceneHelper.cs
  12. 0 0
      Unity/Assets/Core/Entity/SceneHelper.cs.meta
  13. 9 9
      Unity/Assets/Core/Object/EventSystem.cs
  14. 9 9
      Unity/Assets/Core/Object/ICallback.cs
  15. 0 8
      Unity/Assets/Core/Scene.meta
  16. 1 1
      Unity/Codes/Hotfix/Client/Router/HttpClientHelper.cs
  17. 1 1
      Unity/Codes/Hotfix/Client/Router/RouterAddressComponentSystem.cs
  18. 1 1
      Unity/Codes/Hotfix/Client/Scene/SceneFactory.cs
  19. 1 1
      Unity/Codes/Hotfix/Client/Session/SessionStreamDispatcherClientOuter.cs
  20. 2 2
      Unity/Codes/Hotfix/Module/AI/AIComponentSystem.cs
  21. 3 3
      Unity/Codes/Hotfix/Module/Config/ConfigComponentSystem.cs
  22. 2 2
      Unity/Codes/Hotfix/Module/Message/SessionAcceptTimeoutComponentSystem.cs
  23. 2 2
      Unity/Codes/Hotfix/Module/Message/SessionIdleCheckerComponentSystem.cs
  24. 3 4
      Unity/Codes/Hotfix/Module/Recast/NavmeshComponentSystem.cs
  25. 2 2
      Unity/Codes/Hotfix/Share/Move/MoveComponentSystem.cs
  26. 1 1
      Unity/Codes/HotfixView/AppStart_Init.cs
  27. 0 11
      Unity/Codes/HotfixView/Client/Config/ConfigComponent_SetConfigLoader_Awake.cs
  28. 1 1
      Unity/Codes/Model/Client/Router/RouterAddressComponent.cs
  29. 1 1
      Unity/Codes/Model/Client/Router/RouterCheckComponent.cs
  30. 1 1
      Unity/Codes/Model/Client/Scene/ClientSceneFlagComponent.cs
  31. 0 0
      Unity/Codes/Model/Client/Scene/ClientSceneFlagComponent.cs.meta
  32. 1 1
      Unity/Codes/Model/Client/Scene/ClientSceneManagerComponent.cs
  33. 0 0
      Unity/Codes/Model/Client/Scene/ClientSceneManagerComponent.cs.meta
  34. 0 2
      Unity/Codes/Model/Module/Config/ConfigComponent.cs
  35. 0 10
      Unity/Codes/Model/Module/Config/IConfigLoader.cs
  36. 1 4
      Unity/Codes/Model/Module/Recast/NavmeshComponent.cs
  37. 0 11
      Unity/Codes/Model/Module/Timer/TimerType.cs
  38. 25 0
      Unity/Codes/Model/Share/CallbackType.cs
  39. 0 9
      Unity/Codes/Model/Share/SessionStreamDispatcherType.cs
  40. 0 10
      Unity/Codes/Model/Share/TimerType.cs
  41. 9 4
      Unity/Codes/ModelView/Client/Config/ConfigLoader.cs
  42. 1 3
      Unity/Unity.Core.csproj

+ 5 - 5
Apps/Hotfix/AppStart_Init.cs

@@ -8,7 +8,7 @@ namespace ET
     {
         protected override async ETTask Run(Scene scene, EventType.AppStart args)
         {
-            Game.Scene.AddComponent<ConfigComponent>().ConfigLoader = new ConfigLoader();
+            Game.Scene.AddComponent<ConfigComponent>();
             await ConfigComponent.Instance.LoadAsync();
 
             StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(Game.Options.Process);
@@ -31,7 +31,7 @@ namespace ET
 
             #region 机器人使用
 
-            Game.Scene.AddComponent<ClientSceneManagerComponent>();
+            Game.Scene.AddComponent<Client.ClientSceneManagerComponent>();
             Game.Scene.AddComponent<RobotCaseDispatcherComponent>();
             Game.Scene.AddComponent<RobotCaseComponent>();
 
@@ -40,13 +40,13 @@ namespace ET
             
             Game.Scene.AddComponent<NetThreadComponent>();
             
-            Game.Scene.AddComponent<NavmeshComponent, Func<string, byte[]>>(Server.RecastFileReader.Read);
+            Game.Scene.AddComponent<NavmeshComponent>();
 
             switch (Game.Options.AppType)
             {
                 case AppType.Server:
                 {
-                    Game.Scene.AddComponent<NetInnerComponent, IPEndPoint, int>(processConfig.InnerIPPort, SessionStreamDispatcherType.SessionStreamDispatcherServerInner);
+                    Game.Scene.AddComponent<NetInnerComponent, IPEndPoint, int>(processConfig.InnerIPPort, CallbackType.SessionStreamDispatcherServerInner);
 
                     var processScenes = StartSceneConfigCategory.Instance.GetByProcess(Game.Options.Process);
                     foreach (StartSceneConfig startConfig in processScenes)
@@ -62,7 +62,7 @@ namespace ET
                     StartMachineConfig startMachineConfig = WatcherHelper.GetThisMachineConfig();
                     WatcherComponent watcherComponent = Game.Scene.AddComponent<WatcherComponent>();
                     watcherComponent.Start(Game.Options.CreateScenes);
-                    Game.Scene.AddComponent<NetInnerComponent, IPEndPoint, int>(NetworkHelper.ToIPEndPoint($"{startMachineConfig.InnerIP}:{startMachineConfig.WatcherPort}"), SessionStreamDispatcherType.SessionStreamDispatcherServerInner);
+                    Game.Scene.AddComponent<NetInnerComponent, IPEndPoint, int>(NetworkHelper.ToIPEndPoint($"{startMachineConfig.InnerIP}:{startMachineConfig.WatcherPort}"), CallbackType.SessionStreamDispatcherServerInner);
                     break;
                 }
                 case AppType.GameTool:

+ 2 - 2
Apps/Hotfix/Module/Actor/ActorMessageSenderComponentSystem.cs

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

+ 2 - 2
Apps/Hotfix/Module/ActorLocation/ActorLocationSenderComponentSystem.cs

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

+ 2 - 2
Apps/Hotfix/Server/Scene/SceneFactory.cs

@@ -28,10 +28,10 @@ namespace ET.Server
                     scene.AddComponent<HttpComponent, string>($"http://{startSceneConfig.OuterIPPort}/");
                     break;
                 case SceneType.Realm:
-                    scene.AddComponent<NetKcpComponent, IPEndPoint, int>(startSceneConfig.InnerIPOutPort, SessionStreamDispatcherType.SessionStreamDispatcherServerOuter);
+                    scene.AddComponent<NetKcpComponent, IPEndPoint, int>(startSceneConfig.InnerIPOutPort, CallbackType.SessionStreamDispatcherServerOuter);
                     break;
                 case SceneType.Gate:
-                    scene.AddComponent<NetKcpComponent, IPEndPoint, int>(startSceneConfig.InnerIPOutPort, SessionStreamDispatcherType.SessionStreamDispatcherServerOuter);
+                    scene.AddComponent<NetKcpComponent, IPEndPoint, int>(startSceneConfig.InnerIPOutPort, CallbackType.SessionStreamDispatcherServerOuter);
                     scene.AddComponent<PlayerComponent>();
                     scene.AddComponent<GateSessionKeyComponent>();
                     break;

+ 1 - 1
Apps/Hotfix/Server/Session/SessionStreamDispatcherServerInner.cs

@@ -3,7 +3,7 @@ using System.IO;
 
 namespace ET.Server
 {
-    [Callback(SessionStreamDispatcherType.SessionStreamDispatcherServerInner)]
+    [Callback(CallbackType.SessionStreamDispatcherServerInner)]
     public class SessionStreamDispatcherServerInner: IAction<Session, MemoryStream>
     {
         public void Handle(Session session, MemoryStream memoryStream)

+ 1 - 1
Apps/Hotfix/Server/Session/SessionStreamDispatcherServerOuter.cs

@@ -3,7 +3,7 @@ using System.IO;
 
 namespace ET.Server
 {
-    [Callback(SessionStreamDispatcherType.SessionStreamDispatcherServerOuter)]
+    [Callback(CallbackType.SessionStreamDispatcherServerOuter)]
     public class SessionStreamDispatcherServerOuter: IAction<Session, MemoryStream>
     {
         public void Handle(Session session, MemoryStream memoryStream)

+ 2 - 7
Apps/Model/Apps.Model.csproj

@@ -42,7 +42,7 @@
             <Link>Module\ObjectWait\%(RecursiveDir)%(FileName)%(Extension)</Link>
         </Compile>
 
-        <Compile Include="..\..\Unity\Codes\Model\Module\Timer\**\*.cs">
+        <Compile Include="..\..\Unity\Codes\Model\Module\Timer\**\*.cs"> 
             <Link>Module\Timer\%(RecursiveDir)%(FileName)%(Extension)</Link>
         </Compile>
 
@@ -54,12 +54,7 @@
             <Link>Module\CoroutineLock\%(RecursiveDir)%(FileName)%(Extension)</Link>
         </Compile>
 
-        <Compile Remove="Libs\**" />
-
-    </ItemGroup>
-    <ItemGroup>
-
-        <Compile Include="..\..\Unity\Codes\Model\Module\Actor\**\*.cs">
+        <Compile Include="..\..\Unity\Codes\Model\Module\Actor\**\*.cs"> 
             <Link>Module\Actor\%(RecursiveDir)%(FileName)%(Extension)</Link>
         </Compile>
 

+ 9 - 4
Apps/Model/Base/ConfigLoader.cs

@@ -3,9 +3,10 @@ using System.IO;
 
 namespace ET
 {
-    public class ConfigLoader: IConfigLoader
+    [Callback(CallbackType.GetAllConfigBytes)]
+    public class GetAllConfigBytes: IAction<Dictionary<string, byte[]>>
     {
-        public void GetAllConfigBytes(Dictionary<string, byte[]> output)
+        public void Handle(Dictionary<string, byte[]> output)
         {
             foreach (string file in Directory.GetFiles($"../Config", "*.bytes"))
             {
@@ -17,8 +18,12 @@ namespace ET
             output["StartSceneConfigCategory"] = File.ReadAllBytes($"../Config/{Game.Options.StartConfig}/StartSceneConfigCategory.bytes");
             output["StartZoneConfigCategory"] = File.ReadAllBytes($"../Config/{Game.Options.StartConfig}/StartZoneConfigCategory.bytes");
         }
-        
-        public byte[] GetOneConfigBytes(string configName)
+    }
+    
+    [Callback(CallbackType.GetOneConfigBytes)]
+    public class GetOneConfigBytes: IFunc<string, byte[]>
+    {
+        public byte[] Handle(string configName)
         {
             byte[] configBytes = File.ReadAllBytes($"../Config/{configName}.bytes");
             return configBytes;

+ 3 - 2
Apps/Model/Server/RecastLoader/RecastFileReader.cs

@@ -2,9 +2,10 @@
 
 namespace ET.Server
 {
-    public static class RecastFileReader
+    [Callback(CallbackType.RecastFileLoader)]
+    public class RecastFileReader: IFunc<string, byte[]>
     {
-        public static byte[] Read(string name)
+        public byte[] Handle(string name)
         {
             return File.ReadAllBytes(Path.Combine("../Config/Recast", name));
         }

+ 5 - 5
Apps/Tool/Apps.Tool.csproj

@@ -37,11 +37,7 @@
         <Compile Include="..\..\Unity\Assets\Mono\Core\**\*.cs">
             <Link>Core\%(RecursiveDir)%(FileName)%(Extension)</Link>
         </Compile>
-
-        <Compile Include="..\..\Apps\Model\Base\**\*.cs">
-            <Link>Base\%(RecursiveDir)%(FileName)%(Extension)</Link>
-        </Compile>
-
+        
         <Compile Include="..\..\Unity\Codes\Model\Module\Config\**\*.cs">
             <Link>Module\Config\%(RecursiveDir)%(FileName)%(Extension)</Link>
         </Compile>
@@ -49,6 +45,10 @@
         <Compile Include="..\..\Unity\Codes\Model\Module\Message\OpcodeRangeDefine.cs">
             <Link>Module\Message\OpcodeRangeDefine.cs</Link>
         </Compile>
+
+        <Compile Include="..\Model\Base\NLogger.cs">
+          <Link>Base\NLogger.cs</Link>
+        </Compile>
     </ItemGroup>
     
     <ItemGroup>

+ 0 - 0
Unity/Assets/Core/Scene/SceneHelper.cs → Unity/Assets/Core/Entity/SceneHelper.cs


+ 0 - 0
Unity/Assets/Core/Scene/SceneHelper.cs.meta → Unity/Assets/Core/Entity/SceneHelper.cs.meta


+ 9 - 9
Unity/Assets/Core/Object/EventSystem.cs

@@ -200,7 +200,7 @@ namespace ET
                 object obj = Activator.CreateInstance(type);
                 if (obj == null)
                 {
-                    throw new Exception($"type not is AEvent: {type.Name}");
+                    throw new Exception($"type not is callback: {type.Name}");
                 }
                 
                 object[] attrs = type.GetCustomAttributes(typeof(CallbackAttribute), false);
@@ -761,24 +761,24 @@ namespace ET
             return (this.allCallbacks[type] as IFunc<T>).Handle();
         }
 
-        public T Callback<T, A>(int type, A a)
+        public T Callback<A, T>(int type, A a)
         {
-            return (this.allCallbacks[type] as IFunc<T, A>).Handle(a);
+            return (this.allCallbacks[type] as IFunc<A, T>).Handle(a);
         }
         
-        public T Callback<T, A, B>(int type, A a, B b)
+        public T Callback<A, B, T>(int type, A a, B b)
         {
-            return (this.allCallbacks[type] as IFunc<T, A, B>).Handle(a, b);
+            return (this.allCallbacks[type] as IFunc<A, B, T>).Handle(a, b);
         }
         
-        public T Callback<T, A, B, C>(int type, A a, B b, C c)
+        public T Callback<A, B, C, T>(int type, A a, B b, C c)
         {
-            return (this.allCallbacks[type] as IFunc<T, A, B, C>).Handle(a, b, c);
+            return (this.allCallbacks[type] as IFunc<A, B, C, T>).Handle(a, b, c);
         }
         
-        public T Callback<T, A, B, C, D>(int type, A a, B b, C c, D d)
+        public T Callback<A, B, C, D, T>(int type, A a, B b, C c, D d)
         {
-            return (this.allCallbacks[type] as IFunc<T, A, B, C, D>).Handle(a, b, c, d);
+            return (this.allCallbacks[type] as IFunc<A, B, C, D, T>).Handle(a, b, c, d);
         }
 
         public override string ToString()

+ 9 - 9
Unity/Assets/Core/Object/ICallback.cs

@@ -6,47 +6,47 @@
         public void Handle();
     }
 
-    public interface IAction<A>
+    public interface IAction<in A>
     {
         public void Handle(A a);
     }
 
-    public interface IAction<A, B>
+    public interface IAction<in A, in B>
     {
         public void Handle(A a, B b);
     }
 
-    public interface IAction<A, B, C>
+    public interface IAction<in A, in B, in C>
     {
         public void Handle(A a, B b, C c);
     }
 
-    public interface IAction<A, B, C, D>
+    public interface IAction<in A, in B, in C, in D>
     {
         public void Handle(A a, B b, C c, D d);
     }
 
-    public interface IFunc<T>
+    public interface IFunc<out T>
     {
         public T Handle();
     }
 
-    public interface IFunc<T, A>
+    public interface IFunc<in A, out T>
     {
         public T Handle(A a);
     }
 
-    public interface IFunc<T, A, B>
+    public interface IFunc<in A, in B, out T>
     {
         public T Handle(A a, B b);
     }
 
-    public interface IFunc<T, A, B, C>
+    public interface IFunc<in A, in B, in C, out T>
     {
         public T Handle(A a, B b, C c);
     }
 
-    public interface IFunc<T, A, B, C, D>
+    public interface IFunc<in A, in B, in C, in D, out T>
     {
         public T Handle(A a, B b, C c, D d);
     }

+ 0 - 8
Unity/Assets/Core/Scene.meta

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

+ 1 - 1
Unity/Codes/Hotfix/Client/Router/HttpClientHelper.cs

@@ -2,7 +2,7 @@ using System;
 using System.IO;
 using System.Net.Http;
 
-namespace ET
+namespace ET.Client
 {
     public static class HttpClientHelper
     {

+ 1 - 1
Unity/Codes/Hotfix/Client/Router/RouterAddressComponentSystem.cs

@@ -4,7 +4,7 @@ using System.Net;
 using System.Net.Sockets;
 using System.Runtime.InteropServices;
 
-namespace ET
+namespace ET.Client
 {
     [FriendClass(typeof(RouterAddressComponent))]
     public static class RouterAddressComponentSystem

+ 1 - 1
Unity/Codes/Hotfix/Client/Scene/SceneFactory.cs

@@ -6,7 +6,7 @@ namespace ET.Client
         {
             Scene clientScene = EntitySceneFactory.CreateScene(zone, SceneType.Client, name, parent);
             clientScene.AddComponent<ClientSceneFlagComponent>();
-            clientScene.AddComponent<NetKcpComponent, int>(SessionStreamDispatcherType.SessionStreamDispatcherClientOuter);
+            clientScene.AddComponent<NetKcpComponent, int>(CallbackType.SessionStreamDispatcherClientOuter);
 			clientScene.AddComponent<CurrentScenesComponent>();
             clientScene.AddComponent<ObjectWait>();
             clientScene.AddComponent<PlayerComponent>();

+ 1 - 1
Unity/Codes/Hotfix/Client/Session/SessionStreamDispatcherClientOuter.cs

@@ -3,7 +3,7 @@ using System.IO;
 
 namespace ET.Client
 {
-    [Callback(SessionStreamDispatcherType.SessionStreamDispatcherClientOuter)]
+    [Callback(CallbackType.SessionStreamDispatcherClientOuter)]
     public class SessionStreamDispatcherClientOuter: IAction<Session, MemoryStream>
     {
         public void Handle(Session session, MemoryStream memoryStream)

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

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

+ 3 - 3
Unity/Codes/Hotfix/Module/Config/ConfigComponentSystem.cs

@@ -27,7 +27,7 @@ namespace ET
 		
 		public static void LoadOneConfig(this ConfigComponent self, Type configType)
 		{
-			byte[] oneConfigBytes = self.ConfigLoader.GetOneConfigBytes(configType.FullName);
+			byte[] oneConfigBytes = Game.EventSystem.Callback<string, byte[]>(CallbackType.GetOneConfigBytes, configType.FullName);
 
 			object category = ProtobufHelper.FromBytes(configType, oneConfigBytes, 0, oneConfigBytes.Length);
 
@@ -40,7 +40,7 @@ namespace ET
 			HashSet<Type> types = Game.EventSystem.GetTypes(typeof (ConfigAttribute));
 			
 			Dictionary<string, byte[]> configBytes = new Dictionary<string, byte[]>();
-			self.ConfigLoader.GetAllConfigBytes(configBytes);
+			Game.EventSystem.Callback(CallbackType.GetAllConfigBytes, configBytes);
 
 			foreach (Type type in types)
 			{
@@ -54,7 +54,7 @@ namespace ET
 			HashSet<Type> types = Game.EventSystem.GetTypes(typeof (ConfigAttribute));
 			
 			Dictionary<string, byte[]> configBytes = new Dictionary<string, byte[]>();
-			self.ConfigLoader.GetAllConfigBytes(configBytes);
+			Game.EventSystem.Callback(CallbackType.GetAllConfigBytes, configBytes);
 
 			using (ListComponent<Task> listTasks = ListComponent<Task>.Create())
 			{

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

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

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

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

+ 3 - 4
Unity/Codes/Hotfix/Module/Recast/NavmeshComponentSystem.cs

@@ -5,12 +5,11 @@ namespace ET
     [FriendClass(typeof(NavmeshComponent))]
     public static class NavmeshComponentSystem
     {
-        public class AwakeSystem: AwakeSystem<NavmeshComponent, Func<string, byte[]>>
+        public class AwakeSystem: AwakeSystem<NavmeshComponent>
         {
-            public override void Awake(NavmeshComponent self, Func<string, byte[]> loader)
+            public override void Awake(NavmeshComponent self)
             {
                 NavmeshComponent.Instance = self;
-                self.Loader = loader;
             }
         }
         
@@ -22,7 +21,7 @@ namespace ET
                 return ptr;
             }
 
-            byte[] buffer = self.Loader(name);
+            byte[] buffer = Game.EventSystem.Callback<string, byte[]>(CallbackType.RecastFileLoader, name);
             if (buffer.Length == 0)
             {
                 throw new Exception($"no nav data: {name}");

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

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

+ 1 - 1
Unity/Codes/HotfixView/AppStart_Init.cs

@@ -11,7 +11,7 @@ namespace ET.Client
             // 加载配置
             Game.Scene.AddComponent<ResourcesComponent>();
             await ResourcesComponent.Instance.LoadBundleAsync("config.unity3d");
-            Game.Scene.AddComponent<ConfigComponent>().ConfigLoader = new ConfigLoader();
+            Game.Scene.AddComponent<ConfigComponent>();
             ConfigComponent.Instance.Load();
             ResourcesComponent.Instance.UnloadBundle("config.unity3d");
             

+ 0 - 11
Unity/Codes/HotfixView/Client/Config/ConfigComponent_SetConfigLoader_Awake.cs

@@ -1,11 +0,0 @@
-namespace ET.Client
-{
-    [ObjectSystem]
-    public class ConfigComponent_SetConfigLoader_Awake: AwakeSystem<ConfigComponent>
-    {
-        public override void Awake(ConfigComponent self)
-        {
-            self.ConfigLoader = new ConfigLoader();
-        }
-    }
-}

+ 1 - 1
Unity/Codes/Model/Client/Router/RouterAddressComponent.cs

@@ -1,7 +1,7 @@
 using System.Collections.Generic;
 using System.Net;
 
-namespace ET
+namespace ET.Client
 {
     [ComponentOf(typeof(Scene))]
     public class RouterAddressComponent: Entity, IAwake<string>

+ 1 - 1
Unity/Codes/Model/Client/Router/RouterCheckComponent.cs

@@ -1,4 +1,4 @@
-namespace ET
+namespace ET.Client
 {
     [ComponentOf(typeof(Session))]
     public class RouterCheckComponent: Entity, IAwake

+ 1 - 1
Unity/Assets/Core/Scene/ClientSceneFlagComponent.cs → Unity/Codes/Model/Client/Scene/ClientSceneFlagComponent.cs

@@ -1,6 +1,6 @@
 using System.Collections.Generic;
 
-namespace ET
+namespace ET.Client
 {
     [ComponentOf(typeof(Scene))]
     public class ClientSceneFlagComponent: Entity, IAwake, IDestroy

+ 0 - 0
Unity/Assets/Core/Scene/ClientSceneFlagComponent.cs.meta → Unity/Codes/Model/Client/Scene/ClientSceneFlagComponent.cs.meta


+ 1 - 1
Unity/Assets/Core/Scene/ClientSceneManagerComponent.cs → Unity/Codes/Model/Client/Scene/ClientSceneManagerComponent.cs

@@ -1,6 +1,6 @@
 using System.Collections.Generic;
 
-namespace ET
+namespace ET.Client
 {
     [ComponentOf(typeof(Scene))]
     public class ClientSceneManagerComponent: Entity, IAwake, IDestroy

+ 0 - 0
Unity/Assets/Core/Scene/ClientSceneManagerComponent.cs.meta → Unity/Codes/Model/Client/Scene/ClientSceneManagerComponent.cs.meta


+ 0 - 2
Unity/Codes/Model/Module/Config/ConfigComponent.cs

@@ -9,8 +9,6 @@ namespace ET
     [ComponentOf(typeof(Scene))]
     public class ConfigComponent: Entity, IAwake, IDestroy
     {
-        public IConfigLoader ConfigLoader { get; set; }
-        
         public static ConfigComponent Instance;
 		
         public Dictionary<Type, object> AllConfig = new Dictionary<Type, object>();

+ 0 - 10
Unity/Codes/Model/Module/Config/IConfigLoader.cs

@@ -1,10 +0,0 @@
-using System.Collections.Generic;
-
-namespace ET
-{
-    public interface IConfigLoader
-    {
-        void GetAllConfigBytes(Dictionary<string, byte[]> output);
-        byte[] GetOneConfigBytes(string configName);
-    }
-}

+ 1 - 4
Unity/Codes/Model/Module/Recast/NavmeshComponent.cs

@@ -4,13 +4,10 @@ using System.Collections.Generic;
 namespace ET
 {
     [ComponentOf(typeof(Scene))]
-    public class NavmeshComponent: Entity, IAwake<Func<string, byte[]>>
+    public class NavmeshComponent: Entity, IAwake
     {
         public static NavmeshComponent Instance;
         
-        // 为了区分客户端跟服务端还有机器人的加载方式,客户端是加载ab包,服务端跟机器人是加载bytes
-        public Func<string, byte[]> Loader;
-        
         public Dictionary<string, long> Navmeshs = new Dictionary<string, long>();
     }
 }

+ 0 - 11
Unity/Codes/Model/Module/Timer/TimerType.cs

@@ -1,11 +0,0 @@
-namespace ET
-{
-    public static partial class TimerType
-    {
-        // 框架层100-200,逻辑层的timer type从200起
-        public const int WaitTimer = 100;
-        public const int SessionIdleChecker = 101;
-        public const int ActorLocationSenderChecker = 102;
-        public const int ActorMessageSenderChecker = 103;
-    }
-}

+ 25 - 0
Unity/Codes/Model/Share/CallbackType.cs

@@ -0,0 +1,25 @@
+namespace ET
+{
+    public static class CallbackType
+    {
+        public const int SessionStreamDispatcherClientOuter = 1;
+        public const int SessionStreamDispatcherServerOuter = 2;
+        public const int SessionStreamDispatcherServerInner = 3;
+
+        public const int GetAllConfigBytes = 11;
+        public const int GetOneConfigBytes = 12;
+
+        public const int RecastFileLoader = 13;
+        
+        // 框架层100-200,逻辑层的timer type从200起
+        public const int WaitTimer = 100;
+        public const int SessionIdleChecker = 101;
+        public const int ActorLocationSenderChecker = 102;
+        public const int ActorMessageSenderChecker = 103;
+        
+        // 框架层100-200,逻辑层的timer type 200-300
+        public const int MoveTimer = 201;
+        public const int AITimer = 202;
+        public const int SessionAcceptTimeout = 203;
+    }
+}

+ 0 - 9
Unity/Codes/Model/Share/SessionStreamDispatcherType.cs

@@ -1,9 +0,0 @@
-namespace ET
-{
-    public static class SessionStreamDispatcherType
-    {
-        public const int SessionStreamDispatcherClientOuter = 1;
-        public const int SessionStreamDispatcherServerOuter = 2;
-        public const int SessionStreamDispatcherServerInner = 3;
-    }
-}

+ 0 - 10
Unity/Codes/Model/Share/TimerType.cs

@@ -1,10 +0,0 @@
-namespace ET
-{
-    public static partial class TimerType
-    {
-        // 框架层0-100,逻辑层的timer type 200-300
-        public const int MoveTimer = 201;
-        public const int AITimer = 202;
-        public const int SessionAcceptTimeout = 203;
-    }
-}

+ 9 - 4
Unity/Codes/ModelView/Client/Config/ConfigLoader.cs

@@ -3,9 +3,10 @@ using UnityEngine;
 
 namespace ET.Client
 {
-    public class ConfigLoader: IConfigLoader
+    [Callback(CallbackType.GetAllConfigBytes)]
+    public class GetAllConfigBytes: IAction<Dictionary<string, byte[]>>
     {
-        public void GetAllConfigBytes(Dictionary<string, byte[]> output)
+        public void Handle(Dictionary<string, byte[]> output)
         {
             Dictionary<string, UnityEngine.Object> keys = ResourcesComponent.Instance.GetBundleAll("config.unity3d");
 
@@ -16,8 +17,12 @@ namespace ET.Client
                 output[key] = v.bytes;
             }
         }
-
-        public byte[] GetOneConfigBytes(string configName)
+    }
+    
+    [Callback(CallbackType.GetOneConfigBytes)]
+    public class GetOneConfigBytes: IFunc<string, byte[]>
+    {
+        public byte[] Handle(string configName)
         {
             TextAsset v = ResourcesComponent.Instance.GetAsset("config.unity3d", configName) as TextAsset;
             return v.bytes;

+ 1 - 3
Unity/Unity.Core.csproj

@@ -52,7 +52,7 @@
      <Compile Include="Assets\Core\Object\IAwakeSystem.cs" />
      <Compile Include="Assets\Core\HashSetComponent.cs" />
      <Compile Include="Assets\Core\ThreadSynchronizationContext.cs" />
-     <Compile Include="Assets\Core\Scene\SceneHelper.cs" />
+     <Compile Include="Assets\Core\Entity\SceneHelper.cs" />
      <Compile Include="Assets\Core\Network\RpcException.cs" />
      <Compile Include="Assets\Core\Entity\Scene.cs" />
      <Compile Include="Assets\Core\Object\Entity.cs" />
@@ -66,7 +66,6 @@
      <Compile Include="Assets\Core\JsonHelper.cs" />
      <Compile Include="Assets\Core\Object\IdGenerater.cs" />
      <Compile Include="Assets\Core\Helper\MD5Helper.cs" />
-     <Compile Include="Assets\Core\Scene\ClientSceneManagerComponent.cs" />
      <Compile Include="Assets\Core\Network\AService.cs" />
      <Compile Include="Assets\Core\Helper\ObjectHelper.cs" />
      <Compile Include="Assets\Core\Object\Object.cs" />
@@ -82,7 +81,6 @@
      <Compile Include="Assets\Core\QueueDictionary.cs" />
      <Compile Include="Assets\Core\Object\FriendClassAttribute.cs" />
      <Compile Include="Assets\Core\Object\ILoadSystem.cs" />
-     <Compile Include="Assets\Core\Scene\ClientSceneFlagComponent.cs" />
      <Compile Include="Assets\Core\Entity\Game.cs" />
      <Compile Include="Assets\Core\Object\ICallback.cs" />
      <Compile Include="Assets\Core\Object\ObjectPool.cs" />