From e071c20214c03c9c4ecda1027f0e92e3e266f0ec Mon Sep 17 00:00:00 2001 From: ALEXTANG <574809918@qq.com> Date: Thu, 17 Aug 2023 23:07:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=93=E5=B1=95=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E9=B2=81=E7=8F=AD=E5=8A=A0=E8=BD=BD=E9=85=8D=E7=BD=AE,?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=87=92=E5=8A=A0=E8=BD=BD=20=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E4=BD=BF=E7=94=A8=E6=87=92=E5=8A=A0=E8=BD=BD=EF=BC=8C?= =?UTF-8?q?=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84=E9=85=8D=E7=BD=AE=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E8=BD=BD=E5=85=A5=E5=86=85=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 拓展自定义鲁班加载配置,支持懒加载 默认使用懒加载,未使用的配置不会载入内存 --- Assets/AssetRaw/Configs/bidx.meta | 8 + .../HotFix/GameProto/ConfigLoader.cs | 34 +- .../GameProto/GameConfig/Battle/TbBuff.cs | 143 ++++-- .../GameProto/GameConfig/Battle/TbBuffAttr.cs | 143 ++++-- .../GameProto/GameConfig/Battle/TbSkill.cs | 143 ++++-- .../HotFix/GameProto/GameConfig/Tables.cs | 32 +- .../HotFix/GameProto/GameConfig/item/Item.cs | 6 - .../GameProto/GameConfig/item/TbItem.cs | 143 ++++-- Luban/CustomTemplate_Client/ConfigLoader.cs | 10 +- .../ConfigLoader.cs | 72 +++ .../config/cs_bin/_.tpl | 87 ++++ .../config/cs_bin/table.tpl | 413 ++++++++++++++++++ .../config/cs_bin/tables.tpl | 40 ++ .../ConfigLoader.cs | 18 +- Luban/gen_code_bin_to_project.bat | 6 +- Luban/gen_code_bin_to_project_lazyload.bat | 39 ++ Luban/gen_code_bin_to_project_unitask.bat | 2 +- 17 files changed, 1123 insertions(+), 216 deletions(-) create mode 100644 Assets/AssetRaw/Configs/bidx.meta create mode 100644 Luban/CustomTemplate_Client_LazyLoad/ConfigLoader.cs create mode 100644 Luban/CustomTemplate_Client_LazyLoad/config/cs_bin/_.tpl create mode 100644 Luban/CustomTemplate_Client_LazyLoad/config/cs_bin/table.tpl create mode 100644 Luban/CustomTemplate_Client_LazyLoad/config/cs_bin/tables.tpl create mode 100644 Luban/gen_code_bin_to_project_lazyload.bat diff --git a/Assets/AssetRaw/Configs/bidx.meta b/Assets/AssetRaw/Configs/bidx.meta new file mode 100644 index 00000000..b2bef400 --- /dev/null +++ b/Assets/AssetRaw/Configs/bidx.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6a824de3af698c34bb4343dbb911498b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameScripts/HotFix/GameProto/ConfigLoader.cs b/Assets/GameScripts/HotFix/GameProto/ConfigLoader.cs index 1df552c3..01c9a325 100644 --- a/Assets/GameScripts/HotFix/GameProto/ConfigLoader.cs +++ b/Assets/GameScripts/HotFix/GameProto/ConfigLoader.cs @@ -7,12 +7,12 @@ using UnityEngine; /// /// 配置加载器。 /// -public class ConfigLoader:Singleton +public class ConfigLoader : Singleton { private bool _init = false; - + private Tables _tables; - + public Tables Tables { get @@ -21,6 +21,7 @@ public class ConfigLoader:Singleton { Load(); } + return _tables; } } @@ -30,7 +31,7 @@ public class ConfigLoader:Singleton /// public void Load() { - _tables = new Tables(LoadByteBuf); + _tables = new Tables(LoadIdxByteBuf, LoadByteBuf); _init = true; } @@ -41,7 +42,19 @@ public class ConfigLoader:Singleton /// ByteBuf private ByteBuf LoadByteBuf(string file) { - var textAssets = GameModule.Resource.LoadAsset($"{SettingsUtils.FrameworkGlobalSettings.ConfigFolderName}{file}.bytes"); + var textAssets = GameModule.Resource.LoadAsset(file); + byte[] ret = textAssets.bytes; + return new ByteBuf(ret); + } + + /// + /// 加载懒加载Index。 + /// + /// + /// + private ByteBuf LoadIdxByteBuf(string file) + { + var textAssets = GameModule.Resource.LoadAsset($"Idx_{file}"); byte[] ret = textAssets.bytes; return new ByteBuf(ret); } @@ -49,16 +62,11 @@ public class ConfigLoader:Singleton public class ConfigSystem : BaseLogicSys { + public Tables Tables => ConfigLoader.Instance.Tables; + public override bool OnInit() { Log.Warning("ConfigSystem OnInit"); - InitConfig(); return base.OnInit(); } - - private void InitConfig() - { - ConfigLoader.Instance.Load(); - } -} - +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameProto/GameConfig/Battle/TbBuff.cs b/Assets/GameScripts/HotFix/GameProto/GameConfig/Battle/TbBuff.cs index 45b50559..8df02755 100644 --- a/Assets/GameScripts/HotFix/GameProto/GameConfig/Battle/TbBuff.cs +++ b/Assets/GameScripts/HotFix/GameProto/GameConfig/Battle/TbBuff.cs @@ -7,57 +7,120 @@ //------------------------------------------------------------------------------ using Bright.Serialization; using System.Collections.Generic; - +using System.Linq; namespace GameConfig.Battle { -public partial class TbBuff -{ - private readonly Dictionary _dataMap; - private readonly List _dataList; - - public TbBuff(ByteBuf _buf) + public partial class TbBuff { - _dataMap = new Dictionary(); - _dataList = new List(); - - for(int n = _buf.ReadSize() ; n > 0 ; --n) + public static TbBuff Instance { get; private set; } + private bool _readAll = false; + private Dictionary _dataMap; + private List _dataList; + public Dictionary DataMap + { + get + { + if(!_readAll) + { + ReadAll(); + _readAll = true; + } + return _dataMap; + } + } + public List DataList + { + get + { + if(!_readAll) + { + ReadAll(); + _readAll = true; + } + return _dataList; + } + } + private Dictionary _indexMap; + public List Indexes; + private System.Func _dataLoader; + + private void ReadAll() + { + _dataList.Clear(); + foreach(var index in Indexes) + { + var v = Get(index); + _dataMap[index] = v; + _dataList.Add(v); + } + } + + public TbBuff(ByteBuf _buf, string _tbName, System.Func _loader) + { + Instance = this; + _dataMap = new Dictionary(); + _dataList = new List(); + _indexMap = new Dictionary(); + _dataLoader = new System.Func(() => _loader(_tbName)); + + for (int n = _buf.ReadSize(); n > 0; --n) + { + int key; + key = _buf.ReadInt(); + int index = _buf.ReadInt(); + _indexMap[key] = index; + } + Indexes = _indexMap.Keys.ToList(); + PostInit(); + } + + public Battle.BuffConfig this[int key] => Get(key); + public Battle.BuffConfig Get(int key) { Battle.BuffConfig _v; + if(_dataMap.TryGetValue(key, out _v)) + { + return _v; + } + ResetByteBuf(_indexMap[key]); _v = Battle.BuffConfig.DeserializeBuffConfig(_buf); - _dataList.Add(_v); - _dataMap.Add(_v.BuffID, _v); + _dataMap[_v.BuffID] = _v; + _v.Resolve(tables); + if(_indexMap.Count == _dataMap.Count) + { + _buf = null; + } + return _v; } - PostInit(); - } - - public Dictionary DataMap => _dataMap; - public List DataList => _dataList; - - public Battle.BuffConfig GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null; - public Battle.BuffConfig Get(int key) => _dataMap[key]; - public Battle.BuffConfig this[int key] => _dataMap[key]; - - public void Resolve(Dictionary _tables) - { - foreach(var v in _dataList) + public Battle.BuffConfig GetOrDefault(int key) { - v.Resolve(_tables); + if(_indexMap.TryGetValue(key,out var _)) + { + return Get(key); + } + return null; } - PostResolve(); - } - - public void TranslateText(System.Func translator) - { - foreach(var v in _dataList) + + private void ResetByteBuf(int readerInex = 0) { - v.TranslateText(translator); + if( _buf == null) + { + if (_buf == null) + { + _buf = _dataLoader(); + } + } + _buf.ReaderIndex = readerInex; } - } - partial void PostInit(); - partial void PostResolve(); -} - -} \ No newline at end of file + private ByteBuf _buf = null; + private Dictionary tables; + public void CacheTables(Dictionary _tables) + { + tables = _tables; + } + partial void PostInit(); + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameProto/GameConfig/Battle/TbBuffAttr.cs b/Assets/GameScripts/HotFix/GameProto/GameConfig/Battle/TbBuffAttr.cs index 5841b95e..710b0241 100644 --- a/Assets/GameScripts/HotFix/GameProto/GameConfig/Battle/TbBuffAttr.cs +++ b/Assets/GameScripts/HotFix/GameProto/GameConfig/Battle/TbBuffAttr.cs @@ -7,57 +7,120 @@ //------------------------------------------------------------------------------ using Bright.Serialization; using System.Collections.Generic; - +using System.Linq; namespace GameConfig.Battle { -public partial class TbBuffAttr -{ - private readonly Dictionary _dataMap; - private readonly List _dataList; - - public TbBuffAttr(ByteBuf _buf) + public partial class TbBuffAttr { - _dataMap = new Dictionary(); - _dataList = new List(); - - for(int n = _buf.ReadSize() ; n > 0 ; --n) + public static TbBuffAttr Instance { get; private set; } + private bool _readAll = false; + private Dictionary _dataMap; + private List _dataList; + public Dictionary DataMap + { + get + { + if(!_readAll) + { + ReadAll(); + _readAll = true; + } + return _dataMap; + } + } + public List DataList + { + get + { + if(!_readAll) + { + ReadAll(); + _readAll = true; + } + return _dataList; + } + } + private Dictionary _indexMap; + public List Indexes; + private System.Func _dataLoader; + + private void ReadAll() + { + _dataList.Clear(); + foreach(var index in Indexes) + { + var v = Get(index); + _dataMap[index] = v; + _dataList.Add(v); + } + } + + public TbBuffAttr(ByteBuf _buf, string _tbName, System.Func _loader) + { + Instance = this; + _dataMap = new Dictionary(); + _dataList = new List(); + _indexMap = new Dictionary(); + _dataLoader = new System.Func(() => _loader(_tbName)); + + for (int n = _buf.ReadSize(); n > 0; --n) + { + int key; + key = _buf.ReadInt(); + int index = _buf.ReadInt(); + _indexMap[key] = index; + } + Indexes = _indexMap.Keys.ToList(); + PostInit(); + } + + public Battle.BuffAttrConfig this[int key] => Get(key); + public Battle.BuffAttrConfig Get(int key) { Battle.BuffAttrConfig _v; + if(_dataMap.TryGetValue(key, out _v)) + { + return _v; + } + ResetByteBuf(_indexMap[key]); _v = Battle.BuffAttrConfig.DeserializeBuffAttrConfig(_buf); - _dataList.Add(_v); - _dataMap.Add(_v.BuffID, _v); + _dataMap[_v.BuffID] = _v; + _v.Resolve(tables); + if(_indexMap.Count == _dataMap.Count) + { + _buf = null; + } + return _v; } - PostInit(); - } - - public Dictionary DataMap => _dataMap; - public List DataList => _dataList; - - public Battle.BuffAttrConfig GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null; - public Battle.BuffAttrConfig Get(int key) => _dataMap[key]; - public Battle.BuffAttrConfig this[int key] => _dataMap[key]; - - public void Resolve(Dictionary _tables) - { - foreach(var v in _dataList) + public Battle.BuffAttrConfig GetOrDefault(int key) { - v.Resolve(_tables); + if(_indexMap.TryGetValue(key,out var _)) + { + return Get(key); + } + return null; } - PostResolve(); - } - - public void TranslateText(System.Func translator) - { - foreach(var v in _dataList) + + private void ResetByteBuf(int readerInex = 0) { - v.TranslateText(translator); + if( _buf == null) + { + if (_buf == null) + { + _buf = _dataLoader(); + } + } + _buf.ReaderIndex = readerInex; } - } - partial void PostInit(); - partial void PostResolve(); -} - -} \ No newline at end of file + private ByteBuf _buf = null; + private Dictionary tables; + public void CacheTables(Dictionary _tables) + { + tables = _tables; + } + partial void PostInit(); + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameProto/GameConfig/Battle/TbSkill.cs b/Assets/GameScripts/HotFix/GameProto/GameConfig/Battle/TbSkill.cs index 9b59613f..991eee70 100644 --- a/Assets/GameScripts/HotFix/GameProto/GameConfig/Battle/TbSkill.cs +++ b/Assets/GameScripts/HotFix/GameProto/GameConfig/Battle/TbSkill.cs @@ -7,57 +7,120 @@ //------------------------------------------------------------------------------ using Bright.Serialization; using System.Collections.Generic; - +using System.Linq; namespace GameConfig.Battle { -public partial class TbSkill -{ - private readonly Dictionary _dataMap; - private readonly List _dataList; - - public TbSkill(ByteBuf _buf) + public partial class TbSkill { - _dataMap = new Dictionary(); - _dataList = new List(); - - for(int n = _buf.ReadSize() ; n > 0 ; --n) + public static TbSkill Instance { get; private set; } + private bool _readAll = false; + private Dictionary _dataMap; + private List _dataList; + public Dictionary DataMap + { + get + { + if(!_readAll) + { + ReadAll(); + _readAll = true; + } + return _dataMap; + } + } + public List DataList + { + get + { + if(!_readAll) + { + ReadAll(); + _readAll = true; + } + return _dataList; + } + } + private Dictionary _indexMap; + public List Indexes; + private System.Func _dataLoader; + + private void ReadAll() + { + _dataList.Clear(); + foreach(var index in Indexes) + { + var v = Get(index); + _dataMap[index] = v; + _dataList.Add(v); + } + } + + public TbSkill(ByteBuf _buf, string _tbName, System.Func _loader) + { + Instance = this; + _dataMap = new Dictionary(); + _dataList = new List(); + _indexMap = new Dictionary(); + _dataLoader = new System.Func(() => _loader(_tbName)); + + for (int n = _buf.ReadSize(); n > 0; --n) + { + int key; + key = _buf.ReadInt(); + int index = _buf.ReadInt(); + _indexMap[key] = index; + } + Indexes = _indexMap.Keys.ToList(); + PostInit(); + } + + public Battle.SkillBaseConfig this[int key] => Get(key); + public Battle.SkillBaseConfig Get(int key) { Battle.SkillBaseConfig _v; + if(_dataMap.TryGetValue(key, out _v)) + { + return _v; + } + ResetByteBuf(_indexMap[key]); _v = Battle.SkillBaseConfig.DeserializeSkillBaseConfig(_buf); - _dataList.Add(_v); - _dataMap.Add(_v.Id, _v); + _dataMap[_v.Id] = _v; + _v.Resolve(tables); + if(_indexMap.Count == _dataMap.Count) + { + _buf = null; + } + return _v; } - PostInit(); - } - - public Dictionary DataMap => _dataMap; - public List DataList => _dataList; - - public Battle.SkillBaseConfig GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null; - public Battle.SkillBaseConfig Get(int key) => _dataMap[key]; - public Battle.SkillBaseConfig this[int key] => _dataMap[key]; - - public void Resolve(Dictionary _tables) - { - foreach(var v in _dataList) + public Battle.SkillBaseConfig GetOrDefault(int key) { - v.Resolve(_tables); + if(_indexMap.TryGetValue(key,out var _)) + { + return Get(key); + } + return null; } - PostResolve(); - } - - public void TranslateText(System.Func translator) - { - foreach(var v in _dataList) + + private void ResetByteBuf(int readerInex = 0) { - v.TranslateText(translator); + if( _buf == null) + { + if (_buf == null) + { + _buf = _dataLoader(); + } + } + _buf.ReaderIndex = readerInex; } - } - partial void PostInit(); - partial void PostResolve(); -} - -} \ No newline at end of file + private ByteBuf _buf = null; + private Dictionary tables; + public void CacheTables(Dictionary _tables) + { + tables = _tables; + } + partial void PostInit(); + } +} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameProto/GameConfig/Tables.cs b/Assets/GameScripts/HotFix/GameProto/GameConfig/Tables.cs index fc20ad45..2090f2da 100644 --- a/Assets/GameScripts/HotFix/GameProto/GameConfig/Tables.cs +++ b/Assets/GameScripts/HotFix/GameProto/GameConfig/Tables.cs @@ -8,9 +8,9 @@ using Bright.Serialization; - namespace GameConfig -{ +{ + public partial class Tables { public item.TbItem TbItem {get; } @@ -18,36 +18,26 @@ public partial class Tables public Battle.TbBuff TbBuff {get; } public Battle.TbBuffAttr TbBuffAttr {get; } - public Tables(System.Func loader) + public Tables(System.Func idxLoader,System.Func dataLoader) { var tables = new System.Collections.Generic.Dictionary(); - TbItem = new item.TbItem(loader("item_tbitem")); + TbItem = new item.TbItem(idxLoader("item_tbitem"),"item_tbitem",dataLoader); tables.Add("item.TbItem", TbItem); - TbSkill = new Battle.TbSkill(loader("battle_tbskill")); + TbSkill = new Battle.TbSkill(idxLoader("battle_tbskill"),"battle_tbskill",dataLoader); tables.Add("Battle.TbSkill", TbSkill); - TbBuff = new Battle.TbBuff(loader("battle_tbbuff")); + TbBuff = new Battle.TbBuff(idxLoader("battle_tbbuff"),"battle_tbbuff",dataLoader); tables.Add("Battle.TbBuff", TbBuff); - TbBuffAttr = new Battle.TbBuffAttr(loader("battle_tbbuffattr")); + TbBuffAttr = new Battle.TbBuffAttr(idxLoader("battle_tbbuffattr"),"battle_tbbuffattr",dataLoader); tables.Add("Battle.TbBuffAttr", TbBuffAttr); PostInit(); - TbItem.Resolve(tables); - TbSkill.Resolve(tables); - TbBuff.Resolve(tables); - TbBuffAttr.Resolve(tables); - PostResolve(); - } - - public void TranslateText(System.Func translator) - { - TbItem.TranslateText(translator); - TbSkill.TranslateText(translator); - TbBuff.TranslateText(translator); - TbBuffAttr.TranslateText(translator); + TbItem.CacheTables(tables); + TbSkill.CacheTables(tables); + TbBuff.CacheTables(tables); + TbBuffAttr.CacheTables(tables); } partial void PostInit(); - partial void PostResolve(); } } \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameProto/GameConfig/item/Item.cs b/Assets/GameScripts/HotFix/GameProto/GameConfig/item/Item.cs index 11d2813a..6a313ae5 100644 --- a/Assets/GameScripts/HotFix/GameProto/GameConfig/item/Item.cs +++ b/Assets/GameScripts/HotFix/GameProto/GameConfig/item/Item.cs @@ -22,7 +22,6 @@ public sealed partial class Item : Bright.Config.BeanBase UpgradeToItemId = _buf.ReadInt(); if(_buf.ReadBool()){ ExpireTime = _buf.ReadInt(); } else { ExpireTime = null; } BatchUseable = _buf.ReadBool(); - Quality = (item.EQuality)_buf.ReadInt(); ExchangeStream = item.ItemExchange.DeserializeItemExchange(_buf); {int n0 = System.Math.Min(_buf.ReadSize(), _buf.Size);ExchangeList = new System.Collections.Generic.List(n0);for(var i0 = 0 ; i0 < n0 ; i0++) { item.ItemExchange _e0; _e0 = item.ItemExchange.DeserializeItemExchange(_buf); ExchangeList.Add(_e0);}} ExchangeColumn = item.ItemExchange.DeserializeItemExchange(_buf); @@ -64,10 +63,6 @@ public sealed partial class Item : Bright.Config.BeanBase /// public bool BatchUseable { get; private set; } /// - /// 品质 - /// - public item.EQuality Quality { get; private set; } - /// /// 道具兑换配置 /// public item.ItemExchange ExchangeStream { get; private set; } @@ -106,7 +101,6 @@ public sealed partial class Item : Bright.Config.BeanBase + "UpgradeToItemId:" + UpgradeToItemId + "," + "ExpireTime:" + ExpireTime + "," + "BatchUseable:" + BatchUseable + "," - + "Quality:" + Quality + "," + "ExchangeStream:" + ExchangeStream + "," + "ExchangeList:" + Bright.Common.StringUtil.CollectionToString(ExchangeList) + "," + "ExchangeColumn:" + ExchangeColumn + "," diff --git a/Assets/GameScripts/HotFix/GameProto/GameConfig/item/TbItem.cs b/Assets/GameScripts/HotFix/GameProto/GameConfig/item/TbItem.cs index 7386009b..07b1f246 100644 --- a/Assets/GameScripts/HotFix/GameProto/GameConfig/item/TbItem.cs +++ b/Assets/GameScripts/HotFix/GameProto/GameConfig/item/TbItem.cs @@ -7,57 +7,120 @@ //------------------------------------------------------------------------------ using Bright.Serialization; using System.Collections.Generic; - +using System.Linq; namespace GameConfig.item { -public partial class TbItem -{ - private readonly Dictionary _dataMap; - private readonly List _dataList; - - public TbItem(ByteBuf _buf) + public partial class TbItem { - _dataMap = new Dictionary(); - _dataList = new List(); - - for(int n = _buf.ReadSize() ; n > 0 ; --n) + public static TbItem Instance { get; private set; } + private bool _readAll = false; + private Dictionary _dataMap; + private List _dataList; + public Dictionary DataMap + { + get + { + if(!_readAll) + { + ReadAll(); + _readAll = true; + } + return _dataMap; + } + } + public List DataList + { + get + { + if(!_readAll) + { + ReadAll(); + _readAll = true; + } + return _dataList; + } + } + private Dictionary _indexMap; + public List Indexes; + private System.Func _dataLoader; + + private void ReadAll() + { + _dataList.Clear(); + foreach(var index in Indexes) + { + var v = Get(index); + _dataMap[index] = v; + _dataList.Add(v); + } + } + + public TbItem(ByteBuf _buf, string _tbName, System.Func _loader) + { + Instance = this; + _dataMap = new Dictionary(); + _dataList = new List(); + _indexMap = new Dictionary(); + _dataLoader = new System.Func(() => _loader(_tbName)); + + for (int n = _buf.ReadSize(); n > 0; --n) + { + int key; + key = _buf.ReadInt(); + int index = _buf.ReadInt(); + _indexMap[key] = index; + } + Indexes = _indexMap.Keys.ToList(); + PostInit(); + } + + public item.Item this[int key] => Get(key); + public item.Item Get(int key) { item.Item _v; + if(_dataMap.TryGetValue(key, out _v)) + { + return _v; + } + ResetByteBuf(_indexMap[key]); _v = item.Item.DeserializeItem(_buf); - _dataList.Add(_v); - _dataMap.Add(_v.Id, _v); + _dataMap[_v.Id] = _v; + _v.Resolve(tables); + if(_indexMap.Count == _dataMap.Count) + { + _buf = null; + } + return _v; } - PostInit(); - } - - public Dictionary DataMap => _dataMap; - public List DataList => _dataList; - - public item.Item GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null; - public item.Item Get(int key) => _dataMap[key]; - public item.Item this[int key] => _dataMap[key]; - - public void Resolve(Dictionary _tables) - { - foreach(var v in _dataList) + public item.Item GetOrDefault(int key) { - v.Resolve(_tables); + if(_indexMap.TryGetValue(key,out var _)) + { + return Get(key); + } + return null; } - PostResolve(); - } - - public void TranslateText(System.Func translator) - { - foreach(var v in _dataList) + + private void ResetByteBuf(int readerInex = 0) { - v.TranslateText(translator); + if( _buf == null) + { + if (_buf == null) + { + _buf = _dataLoader(); + } + } + _buf.ReaderIndex = readerInex; } - } - partial void PostInit(); - partial void PostResolve(); -} - -} \ No newline at end of file + private ByteBuf _buf = null; + private Dictionary tables; + public void CacheTables(Dictionary _tables) + { + tables = _tables; + } + partial void PostInit(); + } +} \ No newline at end of file diff --git a/Luban/CustomTemplate_Client/ConfigLoader.cs b/Luban/CustomTemplate_Client/ConfigLoader.cs index 1df552c3..b336216c 100644 --- a/Luban/CustomTemplate_Client/ConfigLoader.cs +++ b/Luban/CustomTemplate_Client/ConfigLoader.cs @@ -7,12 +7,12 @@ using UnityEngine; /// /// 配置加载器。 /// -public class ConfigLoader:Singleton +public class ConfigLoader : Singleton { private bool _init = false; - + private Tables _tables; - + public Tables Tables { get @@ -41,7 +41,7 @@ public class ConfigLoader:Singleton /// ByteBuf private ByteBuf LoadByteBuf(string file) { - var textAssets = GameModule.Resource.LoadAsset($"{SettingsUtils.FrameworkGlobalSettings.ConfigFolderName}{file}.bytes"); + var textAssets = GameModule.Resource.LoadAsset(file); byte[] ret = textAssets.bytes; return new ByteBuf(ret); } @@ -49,6 +49,8 @@ public class ConfigLoader:Singleton public class ConfigSystem : BaseLogicSys { + public Tables Tables => ConfigLoader.Instance.Tables; + public override bool OnInit() { Log.Warning("ConfigSystem OnInit"); diff --git a/Luban/CustomTemplate_Client_LazyLoad/ConfigLoader.cs b/Luban/CustomTemplate_Client_LazyLoad/ConfigLoader.cs new file mode 100644 index 00000000..01c9a325 --- /dev/null +++ b/Luban/CustomTemplate_Client_LazyLoad/ConfigLoader.cs @@ -0,0 +1,72 @@ +using Bright.Serialization; +using GameBase; +using GameConfig; +using TEngine; +using UnityEngine; + +/// +/// 配置加载器。 +/// +public class ConfigLoader : Singleton +{ + private bool _init = false; + + private Tables _tables; + + public Tables Tables + { + get + { + if (!_init) + { + Load(); + } + + return _tables; + } + } + + /// + /// 加载配置。 + /// + public void Load() + { + _tables = new Tables(LoadIdxByteBuf, LoadByteBuf); + _init = true; + } + + /// + /// 加载二进制配置。 + /// + /// FileName + /// ByteBuf + private ByteBuf LoadByteBuf(string file) + { + var textAssets = GameModule.Resource.LoadAsset(file); + byte[] ret = textAssets.bytes; + return new ByteBuf(ret); + } + + /// + /// 加载懒加载Index。 + /// + /// + /// + private ByteBuf LoadIdxByteBuf(string file) + { + var textAssets = GameModule.Resource.LoadAsset($"Idx_{file}"); + byte[] ret = textAssets.bytes; + return new ByteBuf(ret); + } +} + +public class ConfigSystem : BaseLogicSys +{ + public Tables Tables => ConfigLoader.Instance.Tables; + + public override bool OnInit() + { + Log.Warning("ConfigSystem OnInit"); + return base.OnInit(); + } +} \ No newline at end of file diff --git a/Luban/CustomTemplate_Client_LazyLoad/config/cs_bin/_.tpl b/Luban/CustomTemplate_Client_LazyLoad/config/cs_bin/_.tpl new file mode 100644 index 00000000..43ab323c --- /dev/null +++ b/Luban/CustomTemplate_Client_LazyLoad/config/cs_bin/_.tpl @@ -0,0 +1,87 @@ +using Bright.Serialization; +using System.Collections.Generic; +{{ + name = x.name + parent_def_type = x.parent_def_type + export_fields = x.export_fields + hierarchy_export_fields = x.hierarchy_export_fields +}} + + +namespace {{x.namespace_with_top_module}} +{ + +{{~if x.comment != '' ~}} +/// +/// {{x.escape_comment}} +/// +{{~end~}} +public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {{x.parent}} {{else}} Bright.Config.BeanBase {{end}} +{ + public {{name}}(ByteBuf _buf) {{if parent_def_type}} : base(_buf) {{end}} + { + {{~ for field in export_fields ~}} + {{cs_deserialize '_buf' field.convention_name field.ctype}} + {{~if field.index_field~}} + foreach(var _v in {{field.convention_name}}) + { + {{field.convention_name}}_Index.Add(_v.{{field.index_field.convention_name}}, _v); + } + {{~end~}} + {{~end~}} + PostInit(); + } + + public static {{name}} Deserialize{{name}}(ByteBuf _buf) + { + {{~if x.is_abstract_type~}} + switch (_buf.ReadInt()) + { + {{~for child in x.hierarchy_not_abstract_children~}} + case {{child.full_name}}.__ID__: return new {{child.full_name}}(_buf); + {{~end~}} + default: throw new SerializationException(); + } + {{~else~}} + return new {{x.full_name}}(_buf); + {{~end~}} + } + + {{~ for field in export_fields ~}} +{{~if field.comment != '' ~}} + /// + /// {{field.escape_comment}} + /// +{{~end~}} + public {{cs_define_type field.ctype}} {{field.convention_name}} { get; private set; } + {{~if field.index_field~}} + public readonly Dictionary<{{cs_define_type field.index_field.ctype}}, {{cs_define_type field.ctype.element_type}}> {{field.convention_name}}_Index = new Dictionary<{{cs_define_type field.index_field.ctype}}, {{cs_define_type field.ctype.element_type}}>(); + {{~end~}} + {{~if field.gen_ref~}} + public {{field.cs_ref_validator_define}} + {{~end~}} + {{~if (gen_datetime_mills field.ctype) ~}} + public long {{field.convention_name}}_Millis => {{field.convention_name}} * 1000L; + {{~end~}} + {{~if field.gen_text_key~}} + public {{cs_define_text_key_field field}} { get; } + {{~end~}} + {{~end~}} + +{{~if !x.is_abstract_type~}} + public const int __ID__ = {{x.id}}; + public override int GetTypeId() => __ID__; +{{~end~}} + public override string ToString() + { + return "{{full_name}}{ " + {{~for field in hierarchy_export_fields ~}} + + "{{field.convention_name}}:" + {{cs_to_string field.convention_name field.ctype}} + "," + {{~end~}} + + "}"; + } + + partial void PostInit(); +} + +} diff --git a/Luban/CustomTemplate_Client_LazyLoad/config/cs_bin/table.tpl b/Luban/CustomTemplate_Client_LazyLoad/config/cs_bin/table.tpl new file mode 100644 index 00000000..ff3f2bee --- /dev/null +++ b/Luban/CustomTemplate_Client_LazyLoad/config/cs_bin/table.tpl @@ -0,0 +1,413 @@ +using Bright.Serialization; +using System.Collections.Generic; +using System.Linq; + +namespace {{x.namespace_with_top_module}} +{ + {{ + name = x.name + key_type = x.key_ttype + key_type1 = x.key_ttype1 + key_type2 = x.key_ttype2 + value_type = x.value_ttype + }} +{{~if x.comment != '' ~}} +/// +/// {{x.escape_comment}} +/// +{{~end~}} + public partial class {{name}} + { + public static {{name}} Instance { get; private set; } + {{~if x.is_map_table ~}} + private bool _readAll = false; + private Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> _dataMap; + private List<{{cs_define_type value_type}}> _dataList; + public Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> DataMap + { + get + { + if(!_readAll) + { + ReadAll(); + _readAll = true; + } + return _dataMap; + } + } + public List<{{cs_define_type value_type}}> DataList + { + get + { + if(!_readAll) + { + ReadAll(); + _readAll = true; + } + return _dataList; + } + } + private Dictionary<{{cs_define_type key_type}},int> _indexMap; + public List<{{cs_define_type key_type}}> Indexes; + private System.Func _dataLoader; + + private void ReadAll() + { + _dataList.Clear(); + foreach(var index in Indexes) + { + var v = Get(index); + _dataMap[index] = v; + _dataList.Add(v); + } + } + + public {{name}}(ByteBuf _buf, string _tbName, System.Func _loader) + { + Instance = this; + _dataMap = new Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}>(); + _dataList = new List<{{cs_define_type value_type}}>(); + _indexMap = new Dictionary<{{cs_define_type key_type}}, int>(); + _dataLoader = new System.Func(() => _loader(_tbName)); + + for (int n = _buf.ReadSize(); n > 0; --n) + { + {{cs_define_type key_type}} key; + {{cs_deserialize '_buf' 'key' key_type}} + int index = _buf.ReadInt(); + _indexMap[key] = index; + } + Indexes = _indexMap.Keys.ToList(); + PostInit(); + } + + {{~if value_type.is_dynamic~}} + public T GetOrDefaultAs({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} + { + if(_indexMap.TryGetValue(key,out var _)) + { + return (T)Get(key); + } + return default(T); + } + public T GetAs({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} => (T)Get(key); + {{~end~}} + public {{cs_define_type value_type}} this[{{cs_define_type key_type}} key] => Get(key); + public {{cs_define_type value_type}} Get({{cs_define_type key_type}} key) + { + {{cs_define_type value_type}} _v; + if(_dataMap.TryGetValue(key, out _v)) + { + return _v; + } + ResetByteBuf(_indexMap[key]); + {{cs_deserialize '_buf' '_v' value_type}} + _dataMap[_v.{{x.index_field.convention_name}}] = _v; + _v.Resolve(tables); + if(_indexMap.Count == _dataMap.Count) + { + _buf = null; + } + return _v; + } + public {{cs_define_type value_type}} GetOrDefault({{cs_define_type key_type}} key) + { + if(_indexMap.TryGetValue(key,out var _)) + { + return Get(key); + } + return null; + } + {{~else if x.is_list_table ~}} + private bool _readAllList = false; + private List<{{cs_define_type value_type}}> _dataList; + public List<{{cs_define_type value_type}}> DataList + { + get + { + if(!_readAllList) + { + ReadAllList(); + _readAllList = true; + } + return _dataList; + } + } + private System.Func _dataLoader; + + {{~if x.is_union_index~}} + private bool _readAll; + private {{cs_table_union_map_type_name x}} _dataMapUnion; + public {{cs_table_union_map_type_name x}} DataMapUnion + { + get + { + if(!_readAll) + { + ReadAll(); + _readAll = true; + } + return _dataMapUnion; + } + } + private void ReadAll() + { + foreach(var index in Indexes) + { + var ({{cs_table_get_param_name_list x}}) = index; + var v = Get({{cs_table_get_param_name_list x}}); + _dataMapUnion[({{cs_table_get_param_name_list x}})] = v; + } + } + private void ReadAllList() + { + _dataList.Clear(); + foreach(var index in Indexes) + { + var ({{cs_table_get_param_name_list x}}) = index; + var v = Get({{cs_table_get_param_name_list x}}); + _dataList.Add(v); + } + } + private Dictionary<({{cs_table_get_param_def_list x}}),int> _indexMap; + public List<({{cs_table_get_param_def_list x}})> Indexes; + + {{~else if !x.index_list.empty?~}} + {{~for idx in x.index_list~}} + private bool _readAll{{idx.index_field.convention_name}} = false; + private Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}> _dataMap_{{idx.index_field.name}}; + public Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}> DataMap_{{idx.index_field.name}} + { + get + { + if(!_readAll{{idx.index_field.convention_name}}) + { + ReadAll{{idx.index_field.convention_name}}(); + _readAll{{idx.index_field.convention_name}} = true; + } + return _dataMap_{{idx.index_field.name}}; + } + } + {{~if for.first ~}} + private void ReadAllList() + { + _dataList.Clear(); + foreach(var index in Indexes_{{idx.index_field.name}}) + { + var v = GetBy{{idx.index_field.convention_name}}(index); + _dataList.Add(v); + } + } + {{~end~}} + private void ReadAll{{idx.index_field.convention_name}}() + { + foreach(var index in Indexes_{{idx.index_field.name}}) + { + var v = GetBy{{idx.index_field.convention_name}}(index); + _dataMap_{{idx.index_field.name}}[index] = v; + } + } + private Dictionary<{{cs_define_type idx.type}},int> _indexMap_{{idx.index_field.name}}; + public List<{{cs_define_type idx.type}}> Indexes_{{idx.index_field.name}}; + {{~end~}} + {{~else~}} + private bool _readAll = false; + private Dictionary _indexMap; + public List Indexes; + private Dictionary _dataMap; + private Dictionary DataMap + { + get + { + if(!_readAll) + { + ReadAllList(); + } + return _dataMap; + } + } + private void ReadAllList() + { + _dataList.Clear(); + foreach(var index in Indexes) + { + var v = Get(index); + _dataList.Add(v); + } + } + {{~end~}} + public {{name}}(ByteBuf _buf, string _tbName, System.Func _loader) + { + Instance = this; + _dataList = new List<{{cs_define_type value_type}}>(); + _dataLoader = new System.Func(()=> _loader(_tbName)); + {{~if x.is_union_index~}} + _dataMapUnion = new {{cs_table_union_map_type_name x}}(); + _indexMap = new Dictionary<({{cs_table_get_param_def_list x}}),int>(); + {{key_value ='('}} + for (int i = _buf.ReadSize(); i > 0; i--) + { + {{~for idx in x.index_list~}} + {{field_name = 'key'+for.index}} + {{cs_define_type idx.type}} {{field_name}}; + {{cs_deserialize '_buf' field_name idx.type}} + {{~if for.last~}} + {{key_value=key_value+field_name+')'}} + {{~else~}} + {{key_value=key_value+field_name+', '}} + {{~end~}} + {{~end~}} + _indexMap.Add({{key_value}}, _buf.ReadInt()); + } + Indexes = _indexMap.Keys.ToList(); + {{~else if !x.index_list.empty?~}} + {{~for idx in x.index_list~}} + _dataMap_{{idx.index_field.name}} = new Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}>(); + _indexMap_{{idx.index_field.name}} = new Dictionary<{{cs_define_type idx.type}},int>(); + {{~end~}} + + + int size = _buf.ReadSize(); + for(int i = 0; i < size; i++) + { + {{~for idx in x.index_list~}} + {{cs_define_type idx.type}} key_{{idx.index_field.name}}; + {{cs_deserialize '_buf' 'key_'+idx.index_field.name idx.type}} + {{~end~}} + int index = _buf.ReadInt(); + {{~for idx in x.index_list~}} + _indexMap_{{idx.index_field.name}}.Add(key_{{idx.index_field.name}},index); + {{~end~}} + } + {{~for idx in x.index_list~}} + Indexes_{{idx.index_field.name}} = _indexMap_{{idx.index_field.name}}.Keys.ToList(); + {{~end~}} + {{~else~}} + _indexMap = new Dictionary(); + _dataMap = new Dictionary(); + int size = _buf.ReadSize(); + for(int i = 0; i < size; i++) + { + _indexMap.Add(i,_buf.ReadInt()); + } + Indexes = _indexMap.Keys.ToList(); + {{~end~}} + } + + + + {{~if x.is_union_index~}} + public {{cs_define_type value_type}} Get({{cs_table_get_param_def_list x}}) + { + {{cs_define_type value_type}} __v; + if(_dataMapUnion.TryGetValue(({{cs_table_get_param_name_list x}}), out __v)) + { + return __v; + } + ResetByteBuf(_indexMap[({{cs_table_get_param_name_list x}})]); + + {{cs_deserialize '_buf' '__v' value_type}} + _dataList.Add(__v); + _dataMapUnion.Add(({{cs_table_get_param_name_list x}}), __v); + __v.Resolve(tables); + if(_indexMap.Count == _dataMapUnion.Count) + { + _buf = null; + } + return __v; + } + {{~else if !x.index_list.empty? ~}} + {{~for idx in x.index_list~}} + public {{cs_define_type value_type}} GetBy{{idx.index_field.convention_name}}({{cs_define_type idx.type}} key) + { + if(_dataMap_{{idx.index_field.name}}.TryGetValue(key,out var value)) + { + return value; + } + int index = _indexMap_{{idx.index_field.name}}[key]; + ResetByteBuf(index); + {{cs_define_type value_type}} _v; + {{cs_deserialize '_buf' '_v' value_type}} + _dataMap_{{idx.index_field.name}}[key] = _v; + _v.Resolve(tables); + return _v; + } + {{~end~}} + {{~else if x.index_list.empty? ~}} + public {{cs_define_type value_type}} this[int index] => Get(index); + public {{cs_define_type value_type}} Get(int index) + { + {{cs_define_type value_type}} _v; + if(_dataMap.TryGetValue(index, out _v)) + { + return _v; + } + ResetByteBuf(_indexMap[index]); + {{cs_deserialize '_buf' '_v' value_type}} + _dataMap[index] = _v; + _v.Resolve(tables); + if(_indexMap.Count == _dataMap.Count) + { + _buf = null; + } + return _v; + } + {{~end~}} + {{~else~}} + + private {{cs_define_type value_type}} _data; + + public {{name}} (ByteBuf _buf, string _tbName, System.Func _loader) + { + Instance = this; + ByteBuf _dataBuf = _loader(_tbName); + int n = _buf.ReadSize(); + int m = _dataBuf.ReadSize(); + if (n != 1 || m != 1) throw new SerializationException("table mode=one, but size != 1"); + {{cs_deserialize '_dataBuf' '_data' value_type}} + } + + + {{~ for field in value_type.bean.hierarchy_export_fields ~}} + {{~if field.comment != '' ~}} + /// + /// {{field.escape_comment}} + /// + {{~end~}} + public {{cs_define_type field.ctype}} {{field.convention_name}} => _data.{{field.convention_name}}; + {{~if field.gen_ref~}} + public {{cs_define_type field.ref_type}} {{field.convention_name}}_Ref => _data.{{field.convention_name}}_Ref; + {{~end~}} + {{~end~}} + + {{~end~}} + + {{~if x.is_map_table||x.is_list_table ~}} + private void ResetByteBuf(int readerInex = 0) + { + if( _buf == null) + { + if (_buf == null) + { + _buf = _dataLoader(); + } + } + _buf.ReaderIndex = readerInex; + } + {{~end~}} + + {{~if x.mode != 'ONE'~}} + private ByteBuf _buf = null; + private Dictionary tables; + {{~end~}} + public void CacheTables(Dictionary _tables) + { + {{~if x.mode == 'ONE'~}} + _data.Resolve(_tables); + {{~else~}} + tables = _tables; + {{~end~}} + } + partial void PostInit(); + } +} \ No newline at end of file diff --git a/Luban/CustomTemplate_Client_LazyLoad/config/cs_bin/tables.tpl b/Luban/CustomTemplate_Client_LazyLoad/config/cs_bin/tables.tpl new file mode 100644 index 00000000..3c5bfafd --- /dev/null +++ b/Luban/CustomTemplate_Client_LazyLoad/config/cs_bin/tables.tpl @@ -0,0 +1,40 @@ +using Bright.Serialization; + +{{ + name = x.name + namespace = x.namespace + tables = x.tables + +}} +namespace {{namespace}} +{ + +public partial class {{name}} +{ + {{~for table in tables ~}} +{{~if table.comment != '' ~}} + /// + /// {{table.escape_comment}} + /// +{{~end~}} + public {{table.full_name}} {{table.name}} {get; } + {{~end~}} + + public {{name}}(System.Func idxLoader,System.Func dataLoader) + { + var tables = new System.Collections.Generic.Dictionary(); + {{~for table in tables ~}} + {{table.name}} = new {{table.full_name}}(idxLoader("{{table.output_data_file}}"),"{{table.output_data_file}}",dataLoader); + tables.Add("{{table.full_name}}", {{table.name}}); + {{~end~}} + + PostInit(); + {{~for table in tables ~}} + {{table.name}}.CacheTables(tables); + {{~end~}} + } + + partial void PostInit(); +} + +} \ No newline at end of file diff --git a/Luban/CustomTemplate_Client_UniTask/ConfigLoader.cs b/Luban/CustomTemplate_Client_UniTask/ConfigLoader.cs index 0a52cfe1..64b3fb7f 100644 --- a/Luban/CustomTemplate_Client_UniTask/ConfigLoader.cs +++ b/Luban/CustomTemplate_Client_UniTask/ConfigLoader.cs @@ -10,12 +10,12 @@ using UnityEngine; /// /// 配置加载器 /// -public class ConfigLoader:Singleton +public class ConfigLoader : Singleton { private bool _init = false; - + private Tables _tables; - + public Tables Tables { get @@ -24,16 +24,16 @@ public class ConfigLoader:Singleton { #if !UNITY_WEBGL _init = true; - + #endif Log.Error("Config not loaded. You need Take LoadAsync at first."); } return _tables; } } - + private readonly Dictionary _configs = new Dictionary(); - + /// /// 异步加载配置。 /// @@ -62,7 +62,7 @@ public class ConfigLoader:Singleton } else { - var textAssets = await GameModule.Resource.LoadAssetAsync(location,CancellationToken.None); + var textAssets = await GameModule.Resource.LoadAssetAsync(location, CancellationToken.None); ret = textAssets.bytes; RegisterTextAssets(file, textAssets); } @@ -71,7 +71,7 @@ public class ConfigLoader:Singleton #endif return new ByteBuf(ret); } - + /// /// 注册配置资源。 /// @@ -96,6 +96,8 @@ public class ConfigLoader:Singleton public class ConfigSystem : BaseLogicSys { + public Tables Tables => ConfigLoader.Instance.Tables; + public override bool OnInit() { Log.Warning("ConfigSystem OnInit"); diff --git a/Luban/gen_code_bin_to_project.bat b/Luban/gen_code_bin_to_project.bat index c596c670..fdabda8b 100644 --- a/Luban/gen_code_bin_to_project.bat +++ b/Luban/gen_code_bin_to_project.bat @@ -6,15 +6,15 @@ set CONF_ROOT=%WORKSPACE%\Luban\Config set DATA_OUTPUT=%ROOT_PATH%..\GenerateDatas set CUSTOM_TEMP=%WORKSPACE%\Luban\CustomTemplate_Client -xcopy %CUSTOM_TEMP%\ConfigLoader.cs %WORKSPACE%\Assets\GameScripts\HotFix\GameProto\\ConfigLoader.cs /s /e /i /y +xcopy %CUSTOM_TEMP%\ConfigLoader.cs %WORKSPACE%\Assets\GameScripts\HotFix\GameProto\ConfigLoader.cs /s /e /i /y %GEN_CLIENT% -j cfg --^ -d %CONF_ROOT%\Defines\__root__.xml ^ --input_data_dir %CONF_ROOT%\Datas ^ --output_code_dir %WORKSPACE%/Assets/GameScripts/HotFix/GameProto/GameConfig ^ - --output_data_dir ..\GenerateDatas\bytes ^ + --output_data_dir %WORKSPACE%/Assets/AssetRaw/Configs/bytes/ ^ --gen_types code_cs_unity_bin,data_bin ^ - -s all + -s client echo ======== 生成配置文件结束 ======== diff --git a/Luban/gen_code_bin_to_project_lazyload.bat b/Luban/gen_code_bin_to_project_lazyload.bat new file mode 100644 index 00000000..a46d5805 --- /dev/null +++ b/Luban/gen_code_bin_to_project_lazyload.bat @@ -0,0 +1,39 @@ +cd /d %~dp0 +set WORKSPACE=.. + +set GEN_CLIENT=%WORKSPACE%\Luban\Luban.ClientServer\Luban.ClientServer.exe +set CONF_ROOT=%WORKSPACE%\Luban\Config +set DATA_OUTPUT=%ROOT_PATH%..\GenerateDatas +set CUSTOM_TEMP=%WORKSPACE%\Luban\CustomTemplate_Client_LazyLoad + +xcopy %CUSTOM_TEMP%\ConfigLoader.cs %WORKSPACE%\Assets\GameScripts\HotFix\GameProto\ConfigLoader.cs /s /e /i /y + +%GEN_CLIENT% -j cfg --^ + -d %CONF_ROOT%\Defines\__root__.xml ^ + --input_data_dir %CONF_ROOT%\Datas ^ + --output_data_dir %WORKSPACE%/Assets/AssetRaw/Configs/bytes/ ^ + --gen_types data_bin ^ + -s client + +%GEN_CLIENT% --template_search_path CustomTemplate_Client_LazyLoad -j cfg --^ + -d %CONF_ROOT%\Defines\__root__.xml ^ + --input_data_dir %CONF_ROOT%\Datas ^ + --output_code_dir %WORKSPACE%/Assets/GameScripts/HotFix/GameProto/GameConfig ^ + --output_data_dir ..\GenerateDatas\bidx ^ + --gen_types code_cs_unity_bin,data_bidx ^ + -s client + +echo ======== 生成配置文件结束 ======== +set WORKSPACE=.. + +set "prefix=Idx_" + +for %%a in (%DATA_OUTPUT%\bidx\*) do ( + ren "%%a" "Idx_%%~nxa" +) + +echo ======== 所有文件已添加前缀 ======== + +xcopy %DATA_OUTPUT%\bidx\ %WORKSPACE%\Assets\AssetRaw\Configs\bidx\ /s /e /i /y + +pause \ No newline at end of file diff --git a/Luban/gen_code_bin_to_project_unitask.bat b/Luban/gen_code_bin_to_project_unitask.bat index 7d97ccfd..712b5ff7 100644 --- a/Luban/gen_code_bin_to_project_unitask.bat +++ b/Luban/gen_code_bin_to_project_unitask.bat @@ -6,7 +6,7 @@ set CONF_ROOT=%WORKSPACE%\Luban\Config set DATA_OUTPUT=%ROOT_PATH%..\GenerateDatas set CUSTOM_TEMP=%WORKSPACE%\Luban\CustomTemplate_Client_UniTask -xcopy %CUSTOM_TEMP%\ConfigLoader.cs %WORKSPACE%\Assets\GameScripts\HotFix\GameProto\\ConfigLoader.cs /s /e /i /y +xcopy %CUSTOM_TEMP%\ConfigLoader.cs %WORKSPACE%\Assets\GameScripts\HotFix\GameProto\ConfigLoader.cs /s /e /i /y %GEN_CLIENT% --template_search_path CustomTemplate_Client_UniTask -j cfg --^ -d %CONF_ROOT%\Defines\__root__.xml ^