拓展自定义鲁班加载配置,支持懒加载 默认使用懒加载,未使用的配置不会载入内存

拓展自定义鲁班加载配置,支持懒加载 默认使用懒加载,未使用的配置不会载入内存
This commit is contained in:
ALEXTANG
2023-08-17 23:07:07 +08:00
parent bf73ce333b
commit e071c20214
17 changed files with 1123 additions and 216 deletions

View File

@@ -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<string, ByteBuf> loader)
public Tables(System.Func<string, ByteBuf> idxLoader,System.Func<string, ByteBuf> dataLoader)
{
var tables = new System.Collections.Generic.Dictionary<string, object>();
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<string, string, string> 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();
}
}