diff --git a/.gitignore b/.gitignore
index 8175b3c067910a12033195fec9574c52a853953a..0630ab5d40cfbf76e9ff593a2e900764e0e2b6ca 100644
--- a/.gitignore
+++ b/.gitignore
@@ -49,4 +49,4 @@ Server/.DS_Store
.objs/
/Unity/.gradle
/*.user
-/ToolApp
+/ToolsApp/
diff --git a/Client-Server.sln.DotSettings b/Client-Server.sln.DotSettings
index e63dbcc1e3121f6766cce6bc89db2b081c24f072..4ab0dc670fc1ba00ba045b8033acc3c06722abfb 100644
--- a/Client-Server.sln.DotSettings
+++ b/Client-Server.sln.DotSettings
@@ -377,6 +377,10 @@ II.2.12 <HandlesEvent />
79
True
False
+ Never
+ Never
+ False
+ Never
False
@@ -400,6 +404,10 @@ II.2.12 <HandlesEvent />
True
True
True
+ True
+ True
+ True
+ True
True
True
True
diff --git a/Server/Hotfix/AppStart_Init.cs b/Server/Hotfix/AppStart_Init.cs
index 9004f321b446ecb6f5045cb1ecfe0eea903c62ea..040010384619a4e8ffb3346638a8cd3a1992d35f 100644
--- a/Server/Hotfix/AppStart_Init.cs
+++ b/Server/Hotfix/AppStart_Init.cs
@@ -8,7 +8,10 @@ namespace ET
{
public override async ETTask Run(EventType.AppStart args)
{
+ FunctionCallback.GetAllConfigBytes = LoadConfigHelper.LoadAllConfigBytes;
+
Game.Scene.AddComponent();
+ await ConfigComponent.Instance.LoadAsync();
StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(Game.Options.Process);
diff --git a/Server/Hotfix/Helper/LoadConfigHelper.cs b/Server/Hotfix/Helper/LoadConfigHelper.cs
new file mode 100644
index 0000000000000000000000000000000000000000..5e696ab6d202bdf16123853de0373f4cf743b863
--- /dev/null
+++ b/Server/Hotfix/Helper/LoadConfigHelper.cs
@@ -0,0 +1,17 @@
+using System.Collections.Generic;
+using System.IO;
+
+namespace ET
+{
+ public static class LoadConfigHelper
+ {
+ public static void LoadAllConfigBytes(Dictionary output)
+ {
+ foreach (string file in Directory.GetFiles($"../Generate/Server/Proto", "*.bytes"))
+ {
+ string key = $"{Path.GetFileName(file)}.bytes";
+ output[key] = File.ReadAllBytes(file);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Server/Hotfix/Module/Config/ConfigComponentSystem.cs b/Server/Hotfix/Module/Config/ConfigComponentSystem.cs
deleted file mode 100644
index ae9362a9923a779f0b7d44500248c4e3068ac07b..0000000000000000000000000000000000000000
--- a/Server/Hotfix/Module/Config/ConfigComponentSystem.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-
-namespace ET
-{
- public class ConfigAwakeSystem : AwakeSystem
- {
- public override void Awake(ConfigComponent self)
- {
- ConfigComponent.Instance = self;
- self.Awake();
- }
- }
-
- public class ConfigLoadSystem : LoadSystem
- {
- public override void Load(ConfigComponent self)
- {
- self.Load();
- }
- }
-
- public class ConfigDestroySystem : DestroySystem
- {
- public override void Destroy(ConfigComponent self)
- {
- ConfigComponent.Instance = null;
- }
- }
-
- public static class ConfigComponentSystem
- {
- public static void Awake(this ConfigComponent self)
- {
- self.Load();
- }
-
- public static void Load(this ConfigComponent self)
- {
- self.AllConfig.Clear();
- HashSet types = Game.EventSystem.GetTypes(typeof(ConfigAttribute));
-
- foreach (Type type in types)
- {
- object obj = Activator.CreateInstance(type);
-
- ACategory iCategory = obj as ACategory;
- if (iCategory == null)
- {
- throw new Exception($"class: {type.Name} not inherit from ACategory");
- }
- iCategory.BeginInit();
- iCategory.EndInit();
-
- self.AllConfig[iCategory.ConfigType] = iCategory;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Server/Hotfix/Server.Hotfix.csproj b/Server/Hotfix/Server.Hotfix.csproj
index 1d2598e1759c1e28913c045788be4fa43fa20a76..fd5116cee8ed8bff9c6d45a6323c1ca34eb7cd8e 100644
--- a/Server/Hotfix/Server.Hotfix.csproj
+++ b/Server/Hotfix/Server.Hotfix.csproj
@@ -20,6 +20,9 @@
+
+ Module\Config\ConfigComponentSystem.cs
+
Module\Message\MessageDispatcherComponentSystem.cs
diff --git a/Server/Model/Module/Config/ConfigComponent.cs b/Server/Model/Module/Config/ConfigComponent.cs
deleted file mode 100644
index 41257d620c57911c87a505eaccce6459f51aa1f7..0000000000000000000000000000000000000000
--- a/Server/Model/Module/Config/ConfigComponent.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace ET
-{
- ///
- /// Config组件会扫描所有的有ConfigAttribute标签的配置,加载进来
- ///
- public class ConfigComponent: Entity
- {
- public static ConfigComponent Instance;
-
- public Dictionary AllConfig = new Dictionary();
- }
-}
\ No newline at end of file
diff --git a/Server/Model/Module/Config/ConfigHelper.cs b/Server/Model/Module/Config/ConfigHelper.cs
deleted file mode 100644
index 539b147c221214573afb70f857ec89e95466d9f9..0000000000000000000000000000000000000000
--- a/Server/Model/Module/Config/ConfigHelper.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using System.IO;
-
-namespace ET
-{
- public static class ConfigHelper
- {
- public static string GetText(string key)
- {
- string path = $"../Config/{key}.txt";
- try
- {
- string configStr = File.ReadAllText(path);
- return configStr;
- }
- catch (Exception e)
- {
- throw new Exception($"load config file fail, path: {path} {e}");
- }
- }
-
- public static T ToObject(string str)
- {
- return JsonHelper.FromJson(str);
- }
- }
-}
diff --git a/Server/Model/Server.Model.csproj b/Server/Model/Server.Model.csproj
index 986143988504420757e6b19af87f2a25240069dc..a1e67d6a5887cc73d365b59b1f3f3aa0b8d0cdd1 100644
--- a/Server/Model/Server.Model.csproj
+++ b/Server/Model/Server.Model.csproj
@@ -29,6 +29,10 @@
Core\%(RecursiveDir)%(FileName)%(Extension)
+
+
+ Module\Config\%(RecursiveDir)%(FileName)%(Extension)
+
@@ -41,9 +45,6 @@
Module\Actor\IActorMessage.cs
-
- Module\Config\AConfigComponent.cs
-
Module\CoroutineLock\CoroutineLock.cs
@@ -92,11 +93,13 @@
+
+
+
+
+
-
-
-
diff --git a/Tools/ExcelExporter/Program.cs b/Tools/ExcelExporter/Program.cs
index 0ecf23a438e093c657aaad0772b1ab3ff9f77767..53909597490998b493a0852587fa793792bf748f 100644
--- a/Tools/ExcelExporter/Program.cs
+++ b/Tools/ExcelExporter/Program.cs
@@ -310,7 +310,7 @@ namespace ET
string json = File.ReadAllText(Path.Combine(string.Format(jsonDir, configType), $"{protoName}.txt"));
object deserialize = BsonSerializer.Deserialize(json, type);
- string path = Path.Combine(dir, $"{protoName}.bytes");
+ string path = Path.Combine(dir, $"{protoName}Category.bytes");
using FileStream file = File.Create(path);
Serializer.Serialize(file, deserialize);
diff --git a/Unity/Assets/Hotfix/Module/Config/ConfigComponentSystem.cs b/Unity/Assets/Hotfix/Module/Config/ConfigComponentSystem.cs
index 612d7de869c1be772c1b4a1d555699655cd603ed..9839608490ba691551a308d6b98cb54d9b8a4bb0 100644
--- a/Unity/Assets/Hotfix/Module/Config/ConfigComponentSystem.cs
+++ b/Unity/Assets/Hotfix/Module/Config/ConfigComponentSystem.cs
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
-
+using System.Threading.Tasks;
namespace ET
{
@@ -21,7 +21,6 @@ namespace ET
}
}
-
public class ConfigDestroySystem : DestroySystem
{
public override void Destroy(ConfigComponent self)
@@ -40,21 +39,51 @@ namespace ET
public static void Load(this ConfigComponent self)
{
self.AllConfig.Clear();
- HashSet types = Game.EventSystem.GetTypes(typeof(ConfigAttribute));
+ HashSet types = Game.EventSystem.GetTypes(typeof (ConfigAttribute));
+
+ Dictionary configBytes = new Dictionary();
+ FunctionCallback.GetAllConfigBytes(configBytes);
+
+ List listTasks = new List();
+
+ foreach (Type type in types)
+ {
+ Task task = Task.Run(() => self.LoadOneInThread(type, configBytes));
+ listTasks.Add(task);
+ }
+
+ Task.WaitAll(listTasks.ToArray());
+ }
+
+
+ public static async ETTask LoadAsync(this ConfigComponent self)
+ {
+ self.AllConfig.Clear();
+ HashSet types = Game.EventSystem.GetTypes(typeof (ConfigAttribute));
+
+ Dictionary configBytes = new Dictionary();
+ FunctionCallback.GetAllConfigBytes(configBytes);
+
+ List listTasks = new List();
foreach (Type type in types)
{
- object obj = Activator.CreateInstance(type);
+ Task task = Task.Run(() => self.LoadOneInThread(type, configBytes));
+ listTasks.Add(task);
+ }
- ACategory iCategory = obj as ACategory;
- if (iCategory == null)
- {
- throw new Exception($"class: {type.Name} not inherit from ACategory");
- }
- iCategory.BeginInit();
- iCategory.EndInit();
+ await Task.WhenAll(listTasks.ToArray());
+ }
- self.AllConfig[iCategory.ConfigType] = iCategory;
+ private static void LoadOneInThread(this ConfigComponent self, Type configType, Dictionary configBytes)
+ {
+ byte[] oneConfigBytes = configBytes[configType.Name];
+
+ object category = ProtobufHelper.FromBytes(configType, oneConfigBytes, 0, oneConfigBytes.Length);
+
+ lock (self)
+ {
+ self.AllConfig[configType] = category;
}
}
}
diff --git a/Unity/Assets/HotfixView/AppStart_Init.cs b/Unity/Assets/HotfixView/AppStart_Init.cs
index 57931d4d8d0550fd8be2de04eb4a6f89fe4e5358..1eefe324487ec3997e9fc5c44d09509c613643ca 100644
--- a/Unity/Assets/HotfixView/AppStart_Init.cs
+++ b/Unity/Assets/HotfixView/AppStart_Init.cs
@@ -4,6 +4,8 @@ namespace ET
{
public override async ETTask Run(EventType.AppStart args)
{
+ FunctionCallback.GetAllConfigBytes = LoadConfigHelper.LoadAllConfigBytes;
+
Game.Scene.AddComponent();
@@ -16,6 +18,7 @@ namespace ET
ResourcesComponent.Instance.LoadBundle("config.unity3d");
Game.Scene.AddComponent();
ResourcesComponent.Instance.UnloadBundle("config.unity3d");
+ await ConfigComponent.Instance.LoadAsync();
Game.Scene.AddComponent();
Game.Scene.AddComponent();
diff --git a/Unity/Assets/HotfixView/Helper/LoadConfigHelper.cs b/Unity/Assets/HotfixView/Helper/LoadConfigHelper.cs
new file mode 100644
index 0000000000000000000000000000000000000000..73827792c91dd1015974ef666d04c1922f67fad9
--- /dev/null
+++ b/Unity/Assets/HotfixView/Helper/LoadConfigHelper.cs
@@ -0,0 +1,21 @@
+using System.Collections.Generic;
+using System.IO;
+using UnityEngine;
+
+namespace ET
+{
+ public static class LoadConfigHelper
+ {
+ public static void LoadAllConfigBytes(Dictionary output)
+ {
+ Dictionary keys = ResourcesComponent.Instance.GetBundleAll("config.unity3d");
+
+ foreach (var kv in keys)
+ {
+ TextAsset v = kv.Value as TextAsset;
+ string key = $"{kv.Key}.bytes";
+ output[key] = v.bytes;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Unity/Assets/Model/Core/FunctionCallback.cs b/Unity/Assets/Model/Core/FunctionCallback.cs
new file mode 100644
index 0000000000000000000000000000000000000000..3742e80d426d3e6792e826c110be99b859c50e91
--- /dev/null
+++ b/Unity/Assets/Model/Core/FunctionCallback.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+
+namespace ET
+{
+ public static class FunctionCallback
+ {
+ public static Action> GetAllConfigBytes;
+ }
+}
\ No newline at end of file
diff --git a/Unity/Assets/Model/Module/Config/ACategory.cs b/Unity/Assets/Model/Module/Config/ACategory.cs
deleted file mode 100644
index 31272c9a2ec23b17d46c74800c6c727f2718f457..0000000000000000000000000000000000000000
--- a/Unity/Assets/Model/Module/Config/ACategory.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-
-namespace ET
-{
- public abstract class ACategory: ProtoObject
- {
- public abstract Type ConfigType { get; }
- }
-
- ///
- /// 管理该所有的配置
- ///
- ///
- public abstract class ACategory : ACategory where T : IConfig
- {
- protected Dictionary dict;
-
- public override void BeginInit()
- {
- string configStr = ConfigHelper.GetText(typeof(T).Name);
-
- try
- {
- this.dict = ConfigHelper.ToObject>(configStr);
- }
- catch (Exception e)
- {
- throw new Exception($"parser json fail: {configStr}", e);
- }
- }
-
- public override Type ConfigType
- {
- get
- {
- return typeof(T);
- }
- }
-
- public override void EndInit()
- {
- }
-
- public T Get(int id)
- {
- T t;
- if (!this.dict.TryGetValue(id, out t))
- {
- throw new Exception($"not found config: {typeof(T)} id: {id}");
- }
- return t;
- }
-
- public Dictionary GetAll()
- {
- return this.dict;
- }
-
- public T GetOne()
- {
- return this.dict.Values.First();
- }
- }
-}
\ No newline at end of file
diff --git a/Unity/Assets/Model/Module/Config/AConfigComponent.cs b/Unity/Assets/Model/Module/Config/AConfigComponent.cs
deleted file mode 100644
index 868049811bec2ff63303cb38ba0c0ade702fbf68..0000000000000000000000000000000000000000
--- a/Unity/Assets/Model/Module/Config/AConfigComponent.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-#if !SERVER
-using UnityEngine;
-#endif
-
-namespace ET
-{
- ///
- /// 每个Config的基类
- ///
-#if !SERVER
- [HideInHierarchy]
-#endif
- public abstract class AConfigComponent: Entity, ISerializeToEntity
- {
- }
-}
\ No newline at end of file
diff --git a/Unity/Assets/Model/Module/Config/ConfigComponent.cs b/Unity/Assets/Model/Module/Config/ConfigComponent.cs
index 459388ced4408b7186980f085894646b32fc9c46..7891147a357c8650ce89e90685d81e21243d1d98 100644
--- a/Unity/Assets/Model/Module/Config/ConfigComponent.cs
+++ b/Unity/Assets/Model/Module/Config/ConfigComponent.cs
@@ -10,6 +10,6 @@ namespace ET
{
public static ConfigComponent Instance;
- public Dictionary AllConfig = new Dictionary();
+ public Dictionary AllConfig = new Dictionary();
}
}
\ No newline at end of file
diff --git a/Unity/Assets/Model/Module/Config/ConfigHelper.cs b/Unity/Assets/Model/Module/Config/ConfigHelper.cs
deleted file mode 100644
index 42a405a8cb6a2d35d3a79d6088c0dfabf98c4409..0000000000000000000000000000000000000000
--- a/Unity/Assets/Model/Module/Config/ConfigHelper.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-using UnityEngine;
-
-namespace ET
-{
- public static class ConfigHelper
- {
- public static string GetText(string key)
- {
- try
- {
- string configStr = ((TextAsset)Game.Scene.GetComponent().GetAsset("config.unity3d", key)).text;
- return configStr;
- }
- catch (Exception e)
- {
- throw new Exception($"load config file fail, key: {key}", e);
- }
- }
-
- public static T ToObject(string str)
- {
- return JsonHelper.FromJson(str);
- }
- }
-}
\ No newline at end of file
diff --git a/Unity/Unity.Hotfix.csproj b/Unity/Unity.Hotfix.csproj
index 371a6d45f13e6126dae09010645d5867e18df7da..df20026f1f77188dd1ec72643fb3dcaac2bee404 100644
--- a/Unity/Unity.Hotfix.csproj
+++ b/Unity/Unity.Hotfix.csproj
@@ -52,11 +52,11 @@
false
+
-
diff --git a/Unity/Unity.HotfixView.csproj b/Unity/Unity.HotfixView.csproj
index a82d600338edf1e7950aef2fce0cb437ceb8f320..5bbbc160c0de263f25409a408a8cb2b176df3b34 100644
--- a/Unity/Unity.HotfixView.csproj
+++ b/Unity/Unity.HotfixView.csproj
@@ -52,6 +52,7 @@
false
+
diff --git a/Unity/Unity.Model.csproj b/Unity/Unity.Model.csproj
index f06ffbd97d420ad4e259f96cbfd7e4289967c364..694f2b25a03e239d600eefc60dcfc20638348963 100644
--- a/Unity/Unity.Model.csproj
+++ b/Unity/Unity.Model.csproj
@@ -52,6 +52,7 @@
false
+
@@ -91,7 +92,6 @@
-
@@ -165,12 +165,10 @@
-
-