Просмотр исходного кода

把actorlocation做成了一个模块

tanghai 1 год назад
Родитель
Сommit
04fd4d76e3
40 измененных файлов с 112 добавлено и 28 удалено
  1. 0 0
      Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/FiberInit_Location.cs
  2. 0 0
      Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/LocationOneTypeSystem.cs
  3. 1 1
      Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/LocationProxyComponentSystem.cs
  4. 0 0
      Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/MessageLocationHandler.cs
  5. 0 0
      Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/MessageLocationSenderComponentSystem.cs
  6. 0 0
      Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/MessageLocationSenderSystem.cs
  7. 0 0
      Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/ObjectAddRequestHandler.cs
  8. 0 0
      Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/ObjectGetRequestHandler.cs
  9. 0 0
      Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/ObjectLockRequestHandler.cs
  10. 0 0
      Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/ObjectRemoveRequestHandler.cs
  11. 0 0
      Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/ObjectUnLockRequestHandler.cs
  12. 0 0
      Unity/Packages/com.et.actorlocation/Runtime~/Model/Server/LocationComponent.cs
  13. 26 0
      Unity/Packages/com.et.actorlocation/Runtime~/Model/Server/LocationConfigSingleton.cs
  14. 0 0
      Unity/Packages/com.et.actorlocation/Runtime~/Model/Server/LocationProxyComponent.cs
  15. 0 0
      Unity/Packages/com.et.actorlocation/Runtime~/Model/Server/MessageLocationSender.cs
  16. 0 0
      Unity/Packages/com.et.actorlocation/Runtime~/Model/Server/MessageLocationSenderOneType.cs
  17. 18 0
      Unity/Packages/com.et.actorlocation/package.json
  18. 7 0
      Unity/Packages/com.et.actorlocation/package.json.meta
  19. 1 1
      Unity/Packages/com.et.core/Editor/AsmdefEditor/AsmdefEditor.cs
  20. 1 1
      Unity/Packages/com.et.core/Runtime/Entity/EntitySystemSingleton.cs
  21. 1 1
      Unity/Packages/com.et.core/Runtime/Fiber/Message/MessageSessionDispatcher.cs
  22. 1 1
      Unity/Packages/com.et.core/Runtime/World/Actor/MessageDispatcher.cs
  23. 0 7
      Unity/Packages/com.et.core/Runtime/World/Code/CodeAttribute.cs
  24. 7 0
      Unity/Packages/com.et.core/Runtime/World/Code/CodeProcessAttribute.cs
  25. 1 1
      Unity/Packages/com.et.core/Runtime/World/Code/CodeProcessAttribute.cs.meta
  26. 2 2
      Unity/Packages/com.et.core/Runtime/World/Code/CodeTypes.cs
  27. 14 0
      Unity/Packages/com.et.core/Runtime/World/Config/ConfigLoader.cs
  28. 7 0
      Unity/Packages/com.et.core/Runtime/World/Config/ConfigProcessAttribute.cs
  29. 11 0
      Unity/Packages/com.et.core/Runtime/World/Config/ConfigProcessAttribute.cs.meta
  30. 1 1
      Unity/Packages/com.et.core/Runtime/World/EventSystem/EventSystem.cs
  31. 0 0
      Unity/Packages/com.et.core/Runtime~/Hotfix/Server/FiberInit_NetInner.cs
  32. 1 1
      Unity/Packages/com.et.core/Runtime~/Model/Share/Entry.cs
  33. 1 1
      Unity/Packages/com.et.loader/DotNet~/CodeLoader.cs
  34. 1 1
      Unity/Packages/com.et.loader/Runtime/CodeLoader.cs
  35. 0 5
      Unity/Packages/com.et.statesync/Runtime~/CodeMode/ClientServer/StartSceneConfig.cs
  36. 1 1
      Unity/Packages/com.et.statesync/Runtime~/Model/Server/Module/Http/HttpDispatcher.cs
  37. 1 1
      Unity/Packages/com.et.statesync/Runtime~/Model/Share/Module/Console/ConsoleDispatcher.cs
  38. 1 1
      Unity/Packages/com.et.statesync/Runtime~/Model/Share/Module/Numeric/NumericWatcherComponent.cs
  39. 1 1
      Unity/Packages/com.et.statesync/Runtime~/ModelView/Client/Module/UI/UIEventComponent.cs
  40. 6 0
      Unity/Packages/packages-lock.json

+ 0 - 0
Unity/Packages/com.et.statesync/Runtime~/Hotfix/Server/Module/ActorLocation/FiberInit_Location.cs → Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/FiberInit_Location.cs


+ 0 - 0
Unity/Packages/com.et.statesync/Runtime~/Hotfix/Server/Module/ActorLocation/LocationOneTypeSystem.cs → Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/LocationOneTypeSystem.cs


+ 1 - 1
Unity/Packages/com.et.statesync/Runtime~/Hotfix/Server/Module/ActorLocation/LocationProxyComponentSystem.cs → Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/LocationProxyComponentSystem.cs

@@ -6,7 +6,7 @@ namespace ET.Server
     {
         private static ActorId GetLocationSceneId(long key)
         {
-            return StartSceneConfigCategory.Instance.LocationConfig.ActorId;
+            return LocationConfigSingleton.Instance.GetLocation(key).ActorId;
         }
 
         public static async ETTask Add(this LocationProxyComponent self, int type, long key, ActorId actorId)

+ 0 - 0
Unity/Packages/com.et.statesync/Runtime~/Hotfix/Server/Module/ActorLocation/MessageLocationHandler.cs → Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/MessageLocationHandler.cs


+ 0 - 0
Unity/Packages/com.et.statesync/Runtime~/Hotfix/Server/Module/ActorLocation/MessageLocationSenderComponentSystem.cs → Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/MessageLocationSenderComponentSystem.cs


+ 0 - 0
Unity/Packages/com.et.statesync/Runtime~/Hotfix/Server/Module/ActorLocation/MessageLocationSenderSystem.cs → Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/MessageLocationSenderSystem.cs


+ 0 - 0
Unity/Packages/com.et.statesync/Runtime~/Hotfix/Server/Module/ActorLocation/ObjectAddRequestHandler.cs → Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/ObjectAddRequestHandler.cs


+ 0 - 0
Unity/Packages/com.et.statesync/Runtime~/Hotfix/Server/Module/ActorLocation/ObjectGetRequestHandler.cs → Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/ObjectGetRequestHandler.cs


+ 0 - 0
Unity/Packages/com.et.statesync/Runtime~/Hotfix/Server/Module/ActorLocation/ObjectLockRequestHandler.cs → Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/ObjectLockRequestHandler.cs


+ 0 - 0
Unity/Packages/com.et.statesync/Runtime~/Hotfix/Server/Module/ActorLocation/ObjectRemoveRequestHandler.cs → Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/ObjectRemoveRequestHandler.cs


+ 0 - 0
Unity/Packages/com.et.statesync/Runtime~/Hotfix/Server/Module/ActorLocation/ObjectUnLockRequestHandler.cs → Unity/Packages/com.et.actorlocation/Runtime~/Hotfix/Server/ObjectUnLockRequestHandler.cs


+ 0 - 0
Unity/Packages/com.et.statesync/Runtime~/Model/Server/Module/ActorLocation/LocationComponent.cs → Unity/Packages/com.et.actorlocation/Runtime~/Model/Server/LocationComponent.cs


+ 26 - 0
Unity/Packages/com.et.actorlocation/Runtime~/Model/Server/LocationConfigSingleton.cs

@@ -0,0 +1,26 @@
+using System.Collections.Generic;
+
+namespace ET.Server
+{
+    [ConfigProcess]
+    public class LocationConfigSingleton: Singleton<LocationConfigSingleton>, ISingletonAwake
+    {
+        private readonly List<StartSceneConfig> locations = new();
+        
+        public void Awake()
+        {
+            foreach (StartSceneConfig startSceneConfig in StartSceneConfigCategory.Instance.GetAll().Values)
+            {
+                if (startSceneConfig.Type == SceneType.Location)
+                {
+                    this.locations.Add(startSceneConfig);
+                }
+            }
+        }
+
+        public StartSceneConfig GetLocation(long key)
+        {
+            return this.locations[(int)((ulong)key % (ulong)this.locations.Count)];
+        }
+    }
+}

+ 0 - 0
Unity/Packages/com.et.statesync/Runtime~/Model/Server/Module/ActorLocation/LocationProxyComponent.cs → Unity/Packages/com.et.actorlocation/Runtime~/Model/Server/LocationProxyComponent.cs


+ 0 - 0
Unity/Packages/com.et.statesync/Runtime~/Model/Server/Module/ActorLocation/MessageLocationSender.cs → Unity/Packages/com.et.actorlocation/Runtime~/Model/Server/MessageLocationSender.cs


+ 0 - 0
Unity/Packages/com.et.statesync/Runtime~/Model/Server/Module/ActorLocation/MessageLocationSenderOneType.cs → Unity/Packages/com.et.actorlocation/Runtime~/Model/Server/MessageLocationSenderOneType.cs


+ 18 - 0
Unity/Packages/com.et.actorlocation/package.json

@@ -0,0 +1,18 @@
+{
+  "name": "com.et.actorlocation",
+  "displayName": "ET.ActorLocation",
+  "version": "0.0.1",
+  "unity": "2022.3",
+  "description": "et actorlocation",
+  "author": {
+    "name": "tanghai",
+    "url": "https://github.com/egametang/ET"
+  },
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/egametang/ET"
+  },
+  "relatedPackages": {},
+  "dependencies": {
+  }
+}

+ 7 - 0
Unity/Packages/com.et.actorlocation/package.json.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 2a4fc5deda80df54eb5b3f11146f015d
+PackageManifestImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 1 - 1
Unity/Packages/com.et.core/Editor/AsmdefEditor/AsmdefEditor.cs

@@ -73,7 +73,7 @@ namespace ET.Loader
                         }
                         catch (Exception e)
                         {
-                            throw new Exception($"parse json error: {p} {json}");
+                            throw new Exception($"parse json error: {p} {json}", e);
                         }
                     }
                 }

+ 1 - 1
Unity/Packages/com.et.core/Runtime/Entity/EntitySystemSingleton.cs

@@ -3,7 +3,7 @@ using System.Collections.Generic;
 
 namespace ET
 {
-    [Code]
+    [CodeProcess]
     public class EntitySystemSingleton: Singleton<EntitySystemSingleton>, ISingletonAwake
     {
         private readonly DoubleMap<Type, long> entityTypeLongHashCode = new();

+ 1 - 1
Unity/Packages/com.et.core/Runtime/Fiber/Message/MessageSessionDispatcher.cs

@@ -15,7 +15,7 @@ namespace ET
         }
     }
     
-    [Code]
+    [CodeProcess]
     public class MessageSessionDispatcher: Singleton<MessageSessionDispatcher>, ISingletonAwake
     {
         private readonly Dictionary<ushort, List<MessageSessionDispatcherInfo>> handlers = new();

+ 1 - 1
Unity/Packages/com.et.core/Runtime/World/Actor/MessageDispatcher.cs

@@ -19,7 +19,7 @@ namespace ET
     /// <summary>
     /// Actor消息分发组件
     /// </summary>
-    [Code]
+    [CodeProcess]
     public class MessageDispatcher: Singleton<MessageDispatcher>, ISingletonAwake
     {
         private readonly Dictionary<Type, List<MessageDispatcherInfo>> messageHandlers = new();

+ 0 - 7
Unity/Packages/com.et.core/Runtime/World/Code/CodeAttribute.cs

@@ -1,7 +0,0 @@
-namespace ET
-{
-    public class CodeAttribute: BaseAttribute
-    {
-
-    }
-}

+ 7 - 0
Unity/Packages/com.et.core/Runtime/World/Code/CodeProcessAttribute.cs

@@ -0,0 +1,7 @@
+namespace ET
+{
+    public class CodeProcessAttribute: BaseAttribute
+    {
+
+    }
+}

+ 1 - 1
Unity/Packages/com.et.core/Runtime/World/Code/CodeAttribute.cs.meta → Unity/Packages/com.et.core/Runtime/World/Code/CodeProcessAttribute.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: a185eabfe6444eb4ca26ea4ec073f578
+guid: 12b6f9a2933e838458d670ec93315a4a
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 2 - 2
Unity/Packages/com.et.core/Runtime/World/Code/CodeTypes.cs

@@ -51,9 +51,9 @@ namespace ET
             return this.allTypes[typeName];
         }
         
-        public void CreateCode()
+        public void CodeProcess()
         {
-            var hashSet = this.GetTypes(typeof (CodeAttribute));
+            var hashSet = this.GetTypes(typeof (CodeProcessAttribute));
             foreach (Type type in hashSet)
             {
                 object obj = Activator.CreateInstance(type);

+ 14 - 0
Unity/Packages/com.et.core/Runtime/World/Config/ConfigLoader.cs

@@ -29,6 +29,7 @@ namespace ET
             GetOneConfigBytes getOneConfigBytes = new() { ConfigName = configType.Name };
             byte[] oneConfigBytes = await EventSystem.Instance.Invoke<GetOneConfigBytes, ETTask<byte[]>>(getOneConfigBytes);
             LoadOneConfig(configType, oneConfigBytes);
+            ConfigProcess();
         }
 
         public async ETTask LoadAsync()
@@ -52,6 +53,8 @@ namespace ET
                 LoadOneConfig(type, configBytes[type]);
             }
 #endif
+
+            ConfigProcess();
         }
 
         private static void LoadOneConfig(Type configType, byte[] oneConfigBytes)
@@ -60,5 +63,16 @@ namespace ET
             ASingleton singleton = category as ASingleton;
             World.Instance.AddSingleton(singleton);
         }
+
+        private void ConfigProcess()
+        {
+            var hashSet = CodeTypes.Instance.GetTypes(typeof (ConfigProcessAttribute));
+            foreach (Type type in hashSet)
+            {
+                object obj = Activator.CreateInstance(type);
+                ((ISingletonAwake)obj).Awake();
+                World.Instance.AddSingleton((ASingleton)obj);
+            }
+        }
     }
 }

+ 7 - 0
Unity/Packages/com.et.core/Runtime/World/Config/ConfigProcessAttribute.cs

@@ -0,0 +1,7 @@
+namespace ET
+{
+    public class ConfigProcessAttribute: BaseAttribute
+    {
+
+    }
+}

+ 11 - 0
Unity/Packages/com.et.core/Runtime/World/Config/ConfigProcessAttribute.cs.meta

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

+ 1 - 1
Unity/Packages/com.et.core/Runtime/World/EventSystem/EventSystem.cs

@@ -3,7 +3,7 @@ using System.Collections.Generic;
 
 namespace ET
 {
-    [Code]
+    [CodeProcess]
     public class EventSystem: Singleton<EventSystem>, ISingletonAwake
     {
         private class EventInfo

+ 0 - 0
Unity/Packages/com.et.statesync/Runtime~/Hotfix/Server/Module/NetInner/FiberInit_NetInner.cs → Unity/Packages/com.et.core/Runtime~/Hotfix/Server/FiberInit_NetInner.cs


+ 1 - 1
Unity/Packages/com.et.core/Runtime~/Model/Share/Entry.cs

@@ -48,7 +48,7 @@ namespace ET
             World.Instance.AddSingleton<LogMsg>();
             
             // 创建需要reload的code singleton
-            CodeTypes.Instance.CreateCode();
+            CodeTypes.Instance.CodeProcess();
             
             await World.Instance.AddSingleton<ConfigLoader>().LoadAsync();
             

+ 1 - 1
Unity/Packages/com.et.loader/DotNet~/CodeLoader.cs

@@ -49,7 +49,7 @@ namespace ET
             CodeTypes codeTypes = World.Instance.AddSingleton<CodeTypes, Assembly[]>([typeof (World).Assembly, typeof(Init).Assembly, this.assembly, hotfixAssembly
             ]);
 
-            codeTypes.CreateCode();
+            codeTypes.CodeProcess();
             Log.Debug($"reload dll finish!");
         }
     }

+ 1 - 1
Unity/Packages/com.et.loader/Runtime/CodeLoader.cs

@@ -124,7 +124,7 @@ namespace ET
                 typeof (World).Assembly, typeof (Init).Assembly, this.modelAssembly, this.modelViewAssembly, hotfixAssembly,
                 hotfixViewAssembly
             });
-            codeTypes.CreateCode();
+            codeTypes.CodeProcess();
 
             Log.Info($"reload dll finish!");
         }

+ 0 - 5
Unity/Packages/com.et.statesync/Runtime~/CodeMode/ClientServer/StartSceneConfig.cs

@@ -12,8 +12,6 @@ namespace ET
         
         public Dictionary<long, Dictionary<string, StartSceneConfig>> ClientScenesByName = new();
 
-        public StartSceneConfig LocationConfig;
-
         public List<StartSceneConfig> Realms = new();
         
         public List<StartSceneConfig> Routers = new();
@@ -50,9 +48,6 @@ namespace ET
                     case SceneType.Gate:
                         this.Gates.Add(startSceneConfig.Zone, startSceneConfig);
                         break;
-                    case SceneType.Location:
-                        this.LocationConfig = startSceneConfig;
-                        break;
                     case SceneType.Router:
                         this.Routers.Add(startSceneConfig);
                         break;

+ 1 - 1
Unity/Packages/com.et.statesync/Runtime~/Model/Server/Module/Http/HttpDispatcher.cs

@@ -3,7 +3,7 @@ using System.Collections.Generic;
 
 namespace ET.Server
 {
-    [Code]
+    [CodeProcess]
     public class HttpDispatcher: Singleton<HttpDispatcher>, ISingletonAwake
     {
         private readonly Dictionary<string, Dictionary<int, IHttpHandler>> dispatcher = new();

+ 1 - 1
Unity/Packages/com.et.statesync/Runtime~/Model/Share/Module/Console/ConsoleDispatcher.cs

@@ -3,7 +3,7 @@ using System.Collections.Generic;
 
 namespace ET
 {
-    [Code]
+    [CodeProcess]
     public class ConsoleDispatcher: Singleton<ConsoleDispatcher>, ISingletonAwake
     {
         private readonly Dictionary<string, IConsoleHandler> handlers = new();

+ 1 - 1
Unity/Packages/com.et.statesync/Runtime~/Model/Share/Module/Numeric/NumericWatcherComponent.cs

@@ -18,7 +18,7 @@ namespace ET
     /// <summary>
     /// 监视数值变化组件,分发监听
     /// </summary>
-    [Code]
+    [CodeProcess]
     public class NumericWatcherComponent : Singleton<NumericWatcherComponent>, ISingletonAwake
     {
         private readonly Dictionary<int, List<NumericWatcherInfo>> allWatchers = new();

+ 1 - 1
Unity/Packages/com.et.statesync/Runtime~/ModelView/Client/Module/UI/UIEventComponent.cs

@@ -6,7 +6,7 @@ namespace ET.Client
 	/// <summary>
 	/// 管理所有UI GameObject
 	/// </summary>
-	[Code]
+	[CodeProcess]
 	public class UIEventComponent: Singleton<UIEventComponent>, ISingletonAwake
 	{
 		public Dictionary<string, AUIEvent> UIEvents { get; } = new();

+ 6 - 0
Unity/Packages/packages-lock.json

@@ -14,6 +14,12 @@
       "dependencies": {},
       "hash": "2554e81f0315ddf835026940ccc4ba8175edfda3"
     },
+    "com.et.actorlocation": {
+      "version": "file:com.et.actorlocation",
+      "depth": 0,
+      "source": "embedded",
+      "dependencies": {}
+    },
     "com.et.core": {
       "version": "file:com.et.core",
       "depth": 0,