Browse Source

增加CommonAI等战斗相关dll导入,并且支持热更新

大爷 2 years ago
parent
commit
9dbdbe15cd
42 changed files with 629 additions and 43 deletions
  1. 19 7
      Unity/Assets/AssetBundleCollectorSetting.asset
  2. 15 0
      Unity/Assets/Editor/YooAsset/FilterRule/CollectConfigAsset.cs
  3. 11 0
      Unity/Assets/Editor/YooAsset/FilterRule/CollectConfigAsset.cs.meta
  4. 16 0
      Unity/Assets/Editor/YooAsset/FilterRule/CollectGameEditorBin.cs
  5. 11 0
      Unity/Assets/Editor/YooAsset/FilterRule/CollectGameEditorBin.cs.meta
  6. BIN
      Unity/Assets/Res/CodeDll/CommonAI.dll.bytes
  7. 7 0
      Unity/Assets/Res/CodeDll/CommonAI.dll.bytes.meta
  8. BIN
      Unity/Assets/Res/CodeDll/CommonLang.dll.bytes
  9. 7 0
      Unity/Assets/Res/CodeDll/CommonLang.dll.bytes.meta
  10. BIN
      Unity/Assets/Res/CodeDll/XmdsCommon.dll.bytes
  11. 7 0
      Unity/Assets/Res/CodeDll/XmdsCommon.dll.bytes.meta
  12. 2 2
      Unity/Assets/Res/Config/HotUpdateAOTDlls.asset
  13. 0 0
      Unity/Assets/Res/Config/HotUpdateAOTDlls.asset.meta
  14. 18 0
      Unity/Assets/Res/Config/HotupdateBattleDlls.asset
  15. 8 0
      Unity/Assets/Res/Config/HotupdateBattleDlls.asset.meta
  16. 21 0
      Unity/Assets/Res/Config/HotupdateDlls.asset
  17. 8 0
      Unity/Assets/Res/Config/HotupdateDlls.asset.meta
  18. 8 0
      Unity/Assets/Res/GameEditor.meta
  19. BIN
      Unity/Assets/Res/GameEditor/e1.bin
  20. 7 0
      Unity/Assets/Res/GameEditor/e1.bin.meta
  21. BIN
      Unity/Assets/Res/GameEditor/ex.bin
  22. 7 0
      Unity/Assets/Res/GameEditor/ex.bin.meta
  23. 0 0
      Unity/Assets/Resources/Fonts/SourceHanSansCN-Regular.asset
  24. 8 0
      Unity/Assets/Scripts/Codes/HotfixView/Client/BattleMgr.meta
  25. 229 0
      Unity/Assets/Scripts/Codes/HotfixView/Client/BattleMgr/BattleResourceMgr.cs
  26. 11 0
      Unity/Assets/Scripts/Codes/HotfixView/Client/BattleMgr/BattleResourceMgr.cs.meta
  27. 6 3
      Unity/Assets/Scripts/Codes/HotfixView/Client/EntryLoadCfg_Client.cs
  28. 8 0
      Unity/Assets/Scripts/Codes/HotfixView/Client/Helper.meta
  29. 60 0
      Unity/Assets/Scripts/Codes/HotfixView/Client/Helper/ObjectPool.cs
  30. 11 0
      Unity/Assets/Scripts/Codes/HotfixView/Client/Helper/ObjectPool.cs.meta
  31. 8 0
      Unity/Assets/Scripts/Codes/ModelView/Client/BattleRes.meta
  32. 13 0
      Unity/Assets/Scripts/Codes/ModelView/Client/BattleRes/BattleResComponent.cs
  33. 11 0
      Unity/Assets/Scripts/Codes/ModelView/Client/BattleRes/BattleResComponent.cs.meta
  34. 44 19
      Unity/Assets/Scripts/Loader/CodeLoader.cs
  35. 18 0
      Unity/Assets/Scripts/Loader/Helper/ConfigKeyValueMap.cs
  36. 11 0
      Unity/Assets/Scripts/Loader/Helper/ConfigKeyValueMap.cs.meta
  37. 9 0
      Unity/Assets/Scripts/Loader/Helper/ConfigStringList.cs
  38. 0 0
      Unity/Assets/Scripts/Loader/Helper/ConfigStringList.cs.meta
  39. 0 10
      Unity/Assets/Scripts/Loader/MonoBehaviour/HotUpdateAssemblyManifest.cs
  40. 5 0
      Unity/Assets/link.xml
  41. 3 0
      Unity/ProjectSettings/HybridCLRSettings.asset
  42. 2 2
      Unity/ProjectSettings/ProjectSettings.asset

+ 19 - 7
Unity/Assets/AssetBundleCollectorSetting.asset

@@ -31,13 +31,6 @@ MonoBehaviour:
     AssetTags: 
     ActiveRuleName: EnableGroup
     Collectors:
-    - CollectPath: Assets/Res/Config/HotUpdateAssemblyManifest.asset
-      CollectorGUID: 
-      CollectorType: 0
-      AddressRuleName: AddressByFileName
-      PackRuleName: PackDirectory
-      FilterRuleName: CollectAll
-      AssetTags: 
     - CollectPath: Assets/Res/Config/GenFromExcel
       CollectorGUID: 725aac85bed52854fa84201325907197
       CollectorType: 0
@@ -45,6 +38,13 @@ MonoBehaviour:
       PackRuleName: PackRawFile
       FilterRuleName: CollectAll
       AssetTags: 
+    - CollectPath: Assets/Res/Config
+      CollectorGUID: e3ee806e88634b941962f665fd74f7ce
+      CollectorType: 0
+      AddressRuleName: AddressByFileName
+      PackRuleName: PackDirectory
+      FilterRuleName: CollectConfigAsset
+      AssetTags: 
   - GroupName: Scene
     GroupDesc: "\u573A\u666F"
     AssetTags: 
@@ -124,3 +124,15 @@ MonoBehaviour:
       PackRuleName: PackDirectory
       FilterRuleName: CollectPrefab
       AssetTags: 
+  - GroupName: GameEditor
+    GroupDesc: "\u7F16\u8F91\u5668\u5BFC\u51FA"
+    AssetTags: 
+    ActiveRuleName: EnableGroup
+    Collectors:
+    - CollectPath: Assets/Res/GameEditor
+      CollectorGUID: a80497b2db2245c4d84212d650f4a19c
+      CollectorType: 0
+      AddressRuleName: AddressByGroupAndFileName
+      PackRuleName: PackRawFile
+      FilterRuleName: CollectGameEditorBin
+      AssetTags: 

+ 15 - 0
Unity/Assets/Editor/YooAsset/FilterRule/CollectConfigAsset.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using YooAsset.Editor;
+
+public class CollectConfigAsset : IFilterRule
+{
+    public bool IsCollectAsset(FilterRuleData data)
+    {
+        return Path.GetExtension(data.AssetPath) == ".asset";
+    }
+}

+ 11 - 0
Unity/Assets/Editor/YooAsset/FilterRule/CollectConfigAsset.cs.meta

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

+ 16 - 0
Unity/Assets/Editor/YooAsset/FilterRule/CollectGameEditorBin.cs

@@ -0,0 +1,16 @@
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using UnityEngine;
+using YooAsset.Editor;
+
+namespace ET
+{
+    public class CollectGameEditorBin : IFilterRule
+    {
+        public bool IsCollectAsset(FilterRuleData data)
+        {
+            return Path.GetExtension(data.AssetPath) == ".bin";
+        }
+    }
+}

+ 11 - 0
Unity/Assets/Editor/YooAsset/FilterRule/CollectGameEditorBin.cs.meta

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

BIN
Unity/Assets/Res/CodeDll/CommonAI.dll.bytes


+ 7 - 0
Unity/Assets/Res/CodeDll/CommonAI.dll.bytes.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 6375de4041440374f8be1e1edf4b3d51
+TextScriptImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Unity/Assets/Res/CodeDll/CommonLang.dll.bytes


+ 7 - 0
Unity/Assets/Res/CodeDll/CommonLang.dll.bytes.meta

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

BIN
Unity/Assets/Res/CodeDll/XmdsCommon.dll.bytes


+ 7 - 0
Unity/Assets/Res/CodeDll/XmdsCommon.dll.bytes.meta

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

+ 2 - 2
Unity/Assets/Res/Config/HotUpdateAssemblyManifest.asset → Unity/Assets/Res/Config/HotUpdateAOTDlls.asset

@@ -10,9 +10,9 @@ MonoBehaviour:
   m_Enabled: 1
   m_EditorHideFlags: 0
   m_Script: {fileID: 11500000, guid: 59f9ce34f47e4ed4827c54fe59e948d5, type: 3}
-  m_Name: HotUpdateAssemblyManifest
+  m_Name: Assets/Res/Config/HotUpdateAOTDlls.asset
   m_EditorClassIdentifier: 
-  AOTMetadataDlls:
+  List:
   - System.dll
   - mscorlib.dll
   - System.Core.dll

+ 0 - 0
Unity/Assets/Res/Config/HotUpdateAssemblyManifest.asset.meta → Unity/Assets/Res/Config/HotUpdateAOTDlls.asset.meta


+ 18 - 0
Unity/Assets/Res/Config/HotupdateBattleDlls.asset

@@ -0,0 +1,18 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 59f9ce34f47e4ed4827c54fe59e948d5, type: 3}
+  m_Name: HotupdateBattleDlls
+  m_EditorClassIdentifier: 
+  List:
+  - CommonLang.dll
+  - CommonAI.dll
+  - XmdsCommon.dll

+ 8 - 0
Unity/Assets/Res/Config/HotupdateBattleDlls.asset.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: f0feb0a1df49eae46b14d7f0e0888167
+NativeFormatImporter:
+  externalObjects: {}
+  mainObjectFileID: 11400000
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 21 - 0
Unity/Assets/Res/Config/HotupdateDlls.asset

@@ -0,0 +1,21 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &11400000
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: d99f802755d1f314b9a8fefec3007c6a, type: 3}
+  m_Name: Assets/Res/Config/HotupdateDlls.asset
+  m_EditorClassIdentifier: 
+  keyValueMaps:
+  - Key: Unity.Mono.dll
+    Value: 
+  - Key: Model.dll
+    Value: Model.pdb
+  - Key: Hotfix.dll
+    Value: Hotfix.pdb

+ 8 - 0
Unity/Assets/Res/Config/HotupdateDlls.asset.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: c0773d4c9332e5f4a9850187cbf442eb
+NativeFormatImporter:
+  externalObjects: {}
+  mainObjectFileID: 11400000
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Unity/Assets/Res/GameEditor.meta

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

BIN
Unity/Assets/Res/GameEditor/e1.bin


+ 7 - 0
Unity/Assets/Res/GameEditor/e1.bin.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 3293d7685f5c5e94faf1a7a7cd94655b
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Unity/Assets/Res/GameEditor/ex.bin


+ 7 - 0
Unity/Assets/Res/GameEditor/ex.bin.meta

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

File diff suppressed because it is too large
+ 0 - 0
Unity/Assets/Resources/Fonts/SourceHanSansCN-Regular.asset


+ 8 - 0
Unity/Assets/Scripts/Codes/HotfixView/Client/BattleMgr.meta

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

+ 229 - 0
Unity/Assets/Scripts/Codes/HotfixView/Client/BattleMgr/BattleResourceMgr.cs

@@ -0,0 +1,229 @@
+using CommonAI.RTS.Manhattan;
+using CommonAI.Zone;
+using CommonAI.Zone.Helper;
+using CommonAI.Zone.ZoneEditor;
+using CommonAI.ZoneClient;
+using CommonLang.Geometry.SceneGraph2D;
+using ET;
+using NLog.Fluent;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using UnityEngine.Scripting;
+using XmdsCommon.EditorData;
+using XmdsCommon.Plugin;
+using Log = ET.Log;
+
+[FriendOf(typeof(BattleResComponent))]
+public static class BattleResourceMgr
+{
+    [ObjectSystem]
+    public class BattleResComponentAwakeSystem : AwakeSystem<BattleResComponent>
+    {
+        protected override void Awake(BattleResComponent self)
+        {
+            self.GameEditorData = new EditorTemplates("", TemplateManager.MessageCodec);
+            TemplateManager.setFactory(new XmdsUnityLocalFactory());
+
+            LoadGameEditorBin(self).Coroutine();
+        }
+    }
+
+    private static async ETTask LoadGameEditorBin(BattleResComponent self)
+    {
+        var op = await YooAssetProxy.GetRawFileAsync("GameEditor_e1");
+        var e1 = op.GetRawBytes();
+        if (e1 == null)
+        {
+            Log.Error("not found GameEditor e1 data.");
+            return;
+        }
+        Log.Debug("to load e1");
+
+        //var zippedStream = new MemoryStream(e1);
+        var binLoadStream = new MemoryStream(e1);
+        //LZMAHelper.Decompress(zippedStream, e1.Length, binLoadStream);
+        var binMemDic = InitBinFilePostionDic(binLoadStream);
+
+        var editorData = self.GameEditorData;
+        editorData.LoadAllCFG(binMemDic["config"]);
+        LoadTemplates<CommonAI.Zone.UnitInfo>(editorData, binMemDic["units"]);
+        LoadTemplates<SkillTemplate>(editorData, binMemDic["skills"]);
+        LoadTemplates<SpellTemplate>(editorData, binMemDic["spells"]);
+        LoadTemplates<BuffTemplate>(editorData, binMemDic["buffs"]);
+        LoadTemplates<ItemTemplate>(editorData, binMemDic["items"]);
+        LoadTemplates<UnitEventTemplate>(editorData, binMemDic["unit_events"]);
+        LoadTemplates<UnitTriggerTemplate>(editorData, binMemDic["unit_triggers"]);
+        LoadSceneSnapData(binMemDic["snaps"]);
+        LoadNewSceneSnapData(binMemDic["newsnaps"]);
+
+        TemplateManager.Formula.InitPluginsData(editorData);
+        editorData.Templates.RehashAll();
+        Log.Info("load e1 end");
+    }
+
+    private static Dictionary<string, MemoryStream> InitBinFilePostionDic(MemoryStream binLoadStream)
+    {
+        var binMemDic = new Dictionary<string, MemoryStream>();
+        var br = new BinaryReader(binLoadStream);
+        binLoadStream.Position = 0;
+        var count = br.ReadByte();
+        var names = new string[count];
+        var sizes = new int[count];
+        for (int i = 0; i < count; i++)
+        {
+            names[i] = br.ReadString();
+            sizes[i] = br.ReadInt32();
+        }
+
+        var offset = (int) binLoadStream.Position;
+        for (int i = 0; i < count; i++)
+        {
+            var name = names[i];
+            var size = sizes[i];
+            binMemDic[name] = new MemoryStream();
+            binLoadStream.Position = offset;
+            binLoadStream.CopyTo(binMemDic[name], size);
+            binMemDic[name].Position = 0;
+            offset += size;
+        }
+
+        return binMemDic;
+    }
+
+    public static void LoadTemplates<T>(EditorTemplates template, Stream stream) where T : class, ITemplateData
+    {
+        try
+        {
+            var br = new BinaryReader(stream);
+            var n = br.ReadInt32();
+            for (var i = 0; i < n; i++)
+            {
+                var name = br.ReadString();
+                var len = br.ReadInt32();
+                var rpos = stream.Position;
+                try
+                {
+                    template.LoadTemplate<T>(stream);
+                }
+                catch (Exception err)
+                {
+                    Log.Error("LoadTemplate:{0},{1}", typeof(T), name);
+                    Log.Error(err);
+                }
+                finally
+                {
+                    stream.Position = rpos + len;
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            Log.Error(e);
+        }
+    }
+
+    public static void LoadSceneSnapData(Stream stream)
+    {
+        try
+        {
+            var br = new BinaryReader(stream);
+            var n = br.ReadInt32();
+            for (var i = 0; i < n; i++)
+            {
+                var _id = br.ReadInt32();
+                var _len = br.ReadInt32();
+                var _dat = br.ReadBytes(_len);
+                try
+                {
+                    SceneSnapManager.LoadSceneSnapData(_id, _dat);
+                }
+                catch (Exception err)
+                {
+                    Log.Error(err);
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            Log.Error(e);
+        }
+    }
+
+    public static void LoadNewSceneSnapData(Stream stream)
+    {
+        try
+        {
+            var br = new BinaryReader(stream);
+            var n = br.ReadInt32();
+            for (var i = 0; i < n; i++)
+            {
+                var _id = br.ReadInt32();
+                var _len = br.ReadInt32();
+                var _dat = br.ReadBytes(_len);
+                try
+                {
+                    SceneSnapManager.LoadBinUnitSnapData(_id, _dat);
+                }
+                catch (Exception err)
+                {
+                    Log.Error(err);
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            Log.Error(e);
+        }
+    }
+
+    public class XmdsUnityLocalFactory : XmdsZoneFactory
+    {
+        public override ZoneLayer CreateClientZoneLayer(EditorTemplates templates, ILayerClient listener)
+        {
+            return new HZUnityZoneLayer(templates, listener);
+        }
+    }
+
+    //-----------------------------------------------------------------------------------------------------
+    #region 接入Untiy寻路
+    public class HZUnityZoneLayer : XmdsCommon.ZoneClient.HZZoneLayer
+    {
+        public HZUnityZoneLayer(EditorTemplates dataroot, ILayerClient client)
+            : base(dataroot, client)
+        {
+            Log.Debug("in=====================");
+
+        }
+
+        protected override void InitTerrain(ClientEnterScene msg, out ZoneManhattanMap terrain_data,
+            out AstarManhattan path_finder, out ManhattanMapAreaGenerator area_gen)
+        {
+            var data = TerrainSrc.Clone() as ZoneInfo;
+            terrain_data = new ZoneManhattanMap(data, Templates.TerrainDefinition);
+            path_finder = new HZUnityAstarManhattan(msg.sceneID, terrain_data, true, 0);
+            area_gen = new ManhattanMapAreaGenerator(terrain_data.Data);
+            this.Data.Terrain = null;
+            this.IsShareTerrain = false;
+            this.IsIgnoreTerrainTouch = false;
+        }
+    }
+
+    public class HZUnityAstarManhattan : AstarManhattan
+    {
+        public HZUnityAstarManhattan(int sceneId, IManhattanMap map_data, bool inclined = true, int space_size = 0)
+            : base(sceneId, map_data, inclined, space_size)
+        {
+        }
+
+        public override FindPathResult findPath(float sx, float sy, float dx, float dy, out MWayPoint ret,
+            bool optimize = true)
+        {
+            // TODO 接入Untiy寻路
+            // NavMesh.CalculatePath();
+            return base.findPath(sx, sy, dx, dy, out ret, optimize);
+        }
+    }
+
+    #endregion
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/HotfixView/Client/BattleMgr/BattleResourceMgr.cs.meta

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

+ 6 - 3
Unity/Assets/Scripts/Codes/HotfixView/Client/EntryLoadCfg_Client.cs

@@ -1,4 +1,4 @@
-using System.Collections;
+using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using System;
@@ -12,7 +12,10 @@ namespace ET
     public class EntryLoadCfg_Client : AEvent<ET.EventType.EntryLoadCfg>
     {
         protected override async ETTask Run(Scene scene, EntryLoadCfg args)
-        { 
+        {
+            //加载战斗相关资源
+            Root.Instance.Scene.AddComponent<BattleResComponent>();
+
             Dictionary<Type, byte[]> configBytes = new Dictionary<Type, byte[]>();
 
             HashSet<Type> configTypes = EventSystem.Instance.GetTypes(typeof(ConfigAttribute));
@@ -24,7 +27,7 @@ namespace ET
                 {
                     configBytes[configType] = cfg;
                     Log.Debug($"load config {configType} ok.");
-                }
+                } 
                 else
                 {
                     Log.Error($"load config {configType} failed.");

+ 8 - 0
Unity/Assets/Scripts/Codes/HotfixView/Client/Helper.meta

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

+ 60 - 0
Unity/Assets/Scripts/Codes/HotfixView/Client/Helper/ObjectPool.cs

@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+public class ObjectPool<T> where T : class
+{
+    private readonly Stack<T> _objects = new Stack<T>();
+    private readonly Func<T> _objectGenerator;
+
+    public ObjectPool(Func<T> objectGenerator)
+    {
+        if (objectGenerator == null)
+        {
+            throw new ArgumentNullException("objectGenerator");
+        }
+        _objectGenerator = objectGenerator;
+    }
+
+    public T Get()
+    {
+        lock (_objects)
+        {
+            if (_objects.Count > 0)
+            {
+                return _objects.Pop();
+            }
+        }
+        return _objectGenerator();
+    }
+
+    public void Put(T item)
+    {
+        lock (_objects)
+        {
+            _objects.Push(item);
+        }
+    }
+
+    public override string ToString()
+    {
+        lock (_objects)
+        {
+            StringBuilder sb = new StringBuilder();
+            foreach (T o in _objects)
+            {
+                sb.Append(o.ToString()).Append('\n');
+            }
+            return sb.ToString();
+        }
+    }
+
+    public void Clear()
+    {
+        lock (_objects)
+        {
+            _objects.Clear();
+        }
+    }
+
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/HotfixView/Client/Helper/ObjectPool.cs.meta

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

+ 8 - 0
Unity/Assets/Scripts/Codes/ModelView/Client/BattleRes.meta

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

+ 13 - 0
Unity/Assets/Scripts/Codes/ModelView/Client/BattleRes/BattleResComponent.cs

@@ -0,0 +1,13 @@
+using CommonAI.Zone.ZoneEditor;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace ET
+{
+    [ComponentOf(typeof(Scene))]
+    public class BattleResComponent : Entity, IAwake
+    {
+        public EditorTemplates GameEditorData;
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/ModelView/Client/BattleRes/BattleResComponent.cs.meta

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

+ 44 - 19
Unity/Assets/Scripts/Loader/CodeLoader.cs

@@ -1,5 +1,6 @@
 using Cysharp.Threading.Tasks;
 using HybridCLR;
+using Sirenix.Utilities;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
@@ -61,13 +62,12 @@ namespace ET
 		private async UniTask LoadMetadataForAOT()
 		{
             //AOT dll列表的配置也可以通过热更新下下来,这样增加了新的泛型就不怕了
-            HotUpdateAssemblyManifest mainfest =
-                (await YooAssetProxy.LoadAssetAsync<HotUpdateAssemblyManifest>("HotUpdateAssemblyManifest"))
-                .GetAssetObject<HotUpdateAssemblyManifest>();
-            var DLLNameList_ForABLoad = mainfest.AOTMetadataDlls;
+            ConfigStringList hotUpdateAOTDlls =
+                (await YooAssetProxy.LoadAssetAsync<ConfigStringList>("HotUpdateAOTDlls"))
+                .GetAssetObject<ConfigStringList>();
 
 			List<UniTask<RawFileOperation>> tasks = new List<UniTask<RawFileOperation>>();
-            foreach (var aotDll in DLLNameList_ForABLoad)
+            foreach (var aotDll in hotUpdateAOTDlls.List)
             {
                 tasks.Add(YooAssetProxy.GetRawFileAsync(aotDll));
             }
@@ -86,25 +86,50 @@ namespace ET
         //热更加载 model.dll & hotfix.dll
         private async UniTask LoadHotfixCode()
         {
-            var mdll = await YooAssetProxy.GetRawFileAsync("Unity.Mono.dll");
-            var mAssembly = Assembly.Load(mdll.GetRawBytes());
-            Log.Info("loaded unity.mono.");
+            Dictionary<string, Type> typesInAssembly = new Dictionary<string, Type>();
+            Assembly modelAss = null;
 
-            var rawfile_modeldll = await YooAssetProxy.GetRawFileAsync("Model.dll");
-            var rawfile_modelpdb = await YooAssetProxy.GetRawFileAsync("Model.pdb");
-            var modelAssembly = Assembly.Load(rawfile_modeldll.GetRawBytes(), rawfile_modelpdb.GetRawBytes());
-            Log.Info("loaded model.");
+            var battleDlls = (await YooAssetProxy.LoadAssetAsync<ConfigStringList>("HotupdateBattleDlls")).GetAssetObject<ConfigStringList>();
+            foreach (var dll in battleDlls.List)
+            {
+                Log.Info($"to load: {dll}");
+                Assembly.Load((await YooAssetProxy.GetRawFileAsync(dll)).GetRawBytes());
+            }
 
-            var rawfile_hotfixdll = await YooAssetProxy.GetRawFileAsync("Hotfix.dll");
-            var rawfile_hotfixpdb = await YooAssetProxy.GetRawFileAsync("Hotfix.pdb");
-            var hotfixAssembly = Assembly.Load(rawfile_hotfixdll.GetRawBytes(), rawfile_hotfixpdb.GetRawBytes());
-            Log.Info("loaded hotfix.");
+            var hotDlls = (await YooAssetProxy.LoadAssetAsync<ConfigKeyValueMap>("HotupdateDlls")).GetAssetObject<ConfigKeyValueMap>();
+            foreach(var kv in hotDlls.keyValueMaps)
+            {
+                Assembly ass;
+                if(kv.Value.IsNullOrWhitespace())
+                {
+                    Log.Info($"to load: {kv.Key}");
+                    ass = Assembly.Load((await YooAssetProxy.GetRawFileAsync(kv.Key)).GetRawBytes());
+                }
+                else
+                {
+                    Log.Info($"to load: {kv.Key}");
+                    ass = Assembly.Load((await YooAssetProxy.GetRawFileAsync(kv.Key)).GetRawBytes(),
+                        (await YooAssetProxy.GetRawFileAsync(kv.Value)).GetRawBytes());
+                }
 
-            Dictionary<string, Type> types = AssemblyHelper.GetAssemblyTypes(typeof(Game).Assembly, typeof(Init).Assembly, modelAssembly, hotfixAssembly, mAssembly);
-            EventSystem.Instance.Add(types);
+                foreach (Type type in ass.GetTypes())
+                {
+                    typesInAssembly[type.FullName] = type;
+                }
+                if(kv.Key.Equals("Model.dll"))
+                {
+                    modelAss = ass;
+                }
+            }
+            EventSystem.Instance.Add(typesInAssembly);
 
+            if(modelAss == null)
+            {
+                Log.Error("Not Found 'Model.dll'! ");
+                return;
+            }
             Log.Info("to call Client.Entry.");
-            IStaticMethod start = new MonoStaticMethod(modelAssembly, "ET.Entry", "Start");
+            IStaticMethod start = new MonoStaticMethod(modelAss, "ET.Entry", "Start");
             start.Run();
         }
 

+ 18 - 0
Unity/Assets/Scripts/Loader/Helper/ConfigKeyValueMap.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using UnityEngine;
+
+[CreateAssetMenu(fileName = "Config1", menuName = "Config/ConfigKeyValueMap")]
+public class ConfigKeyValueMap : ScriptableObject
+{
+    [Serializable]
+    public struct KeyValueMap
+    {
+        public string Key;
+        public string Value;
+    }
+    public KeyValueMap[] keyValueMaps = new KeyValueMap[1];
+}

+ 11 - 0
Unity/Assets/Scripts/Loader/Helper/ConfigKeyValueMap.cs.meta

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

+ 9 - 0
Unity/Assets/Scripts/Loader/Helper/ConfigStringList.cs

@@ -0,0 +1,9 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+[CreateAssetMenu(fileName = "Config1", menuName = "Config/StringList")]
+public class ConfigStringList : ScriptableObject
+{
+    public string[] List = new string[] {};
+}

+ 0 - 0
Unity/Assets/Scripts/Loader/MonoBehaviour/HotUpdateAssemblyManifest.cs.meta → Unity/Assets/Scripts/Loader/Helper/ConfigStringList.cs.meta


+ 0 - 10
Unity/Assets/Scripts/Loader/MonoBehaviour/HotUpdateAssemblyManifest.cs

@@ -1,10 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-[CreateAssetMenu(fileName = "HotUpdateAssemblyManifest", menuName = "HybridCLR/HotUpdateAssemblyManifest")]
-public class HotUpdateAssemblyManifest : ScriptableObject
-{
-    [Header("AOT 补充元数据dll列表")]
-    public string[] AOTMetadataDlls = new string[] {};
-}

+ 5 - 0
Unity/Assets/link.xml

@@ -6,4 +6,9 @@
   <assembly fullname="Unity.HotfixView" preserve="all"/>
   <assembly fullname="Unity.Mono" preserve="all"/>
   <assembly fullname="Unity.ThirdParty" preserve="all"/>
+  <assembly fullname="Model" preserve="all"/>
+  <assembly fullname="Hotfix" preserve="all"/>
+  <assembly fullname="CommonLang" preserve="all"/>
+  <assembly fullname="CommonAI" preserve="all"/>
+  <assembly fullname="XmdsCommon" preserve="all"/>
 </linker>

+ 3 - 0
Unity/ProjectSettings/HybridCLRSettings.asset

@@ -21,6 +21,9 @@ MonoBehaviour:
   - Model
   - Hotfix
   - Unity.Mono
+  - CommonLang
+  - CommonAI
+  - XmdsCommon
   preserveHotUpdateAssemblies: []
   hotUpdateDllCompileOutputRootDir: HybridCLRData/HotUpdateDlls
   externalHotUpdateAssembliyDirs:

+ 2 - 2
Unity/ProjectSettings/ProjectSettings.asset

@@ -860,7 +860,7 @@ PlayerSettings:
     iPhone: 1
   scriptingBackend:
     Android: 1
-    Server: 0
+    Server: 1
     Standalone: 1
     iPhone: 1
   il2cppCompilerConfiguration: {}
@@ -870,7 +870,7 @@ PlayerSettings:
   allowUnsafeCode: 1
   useDeterministicCompilation: 1
   enableRoslynAnalyzers: 1
-  selectedPlatform: 0
+  selectedPlatform: 1
   additionalIl2CppArgs: 
   scriptingRuntimeVersion: 1
   gcIncremental: 0

Some files were not shown because too many files changed in this diff