From ea38004ba293256c415b853f28893f4c05b63d8c Mon Sep 17 00:00:00 2001
From: ALEXTANG <574809918@qq.com>
Date: Fri, 20 Oct 2023 16:24:00 +0800
Subject: [PATCH] =?UTF-8?q?luban-next=E6=94=AF=E6=8C=81=E6=87=92=E5=8A=A0?=
=?UTF-8?q?=E8=BD=BD=20=E6=84=9F=E8=B0=A2=E5=8D=8A=E4=BB=99=E5=84=BF?=
=?UTF-8?q?=E6=8F=90=E4=BE=9B=E6=94=AF=E6=8C=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
luban-next支持懒加载 感谢半仙儿提供支持
---
.../CustomTemplate_Client/ConfigSystem.cs | 48 --
.../ConfigSystem.cs | 61 ---
.../config/cs_bin/_.tpl | 87 ----
.../config/cs_bin/table.tpl | 413 ------------------
.../config/cs_bin/tables.tpl | 40 --
.../ConfigSystem.cs | 95 ----
.../config/cs_bin/bean.tpl | 115 -----
.../config/cs_bin/table.tpl | 173 --------
.../config/cs_bin/tables.tpl | 53 ---
.../config/cs_bin/bean.tpl | 115 -----
.../config/cs_bin/table.tpl | 173 --------
.../config/cs_bin/tables.tpl | 46 --
.../cs-bin/tables.sbn | 55 +++
.../GameConfig/gen_code_bin_to_project.bat | 3 +
.../gen_code_bin_to_project_lazyload.bat | 18 +
15 files changed, 76 insertions(+), 1419 deletions(-)
delete mode 100644 Configs/CustomTemplate/CustomTemplate_Client/ConfigSystem.cs
delete mode 100644 Configs/CustomTemplate/CustomTemplate_Client_LazyLoad/ConfigSystem.cs
delete mode 100644 Configs/CustomTemplate/CustomTemplate_Client_LazyLoad/config/cs_bin/_.tpl
delete mode 100644 Configs/CustomTemplate/CustomTemplate_Client_LazyLoad/config/cs_bin/table.tpl
delete mode 100644 Configs/CustomTemplate/CustomTemplate_Client_LazyLoad/config/cs_bin/tables.tpl
delete mode 100644 Configs/CustomTemplate/CustomTemplate_Client_UniTask/ConfigSystem.cs
delete mode 100644 Configs/CustomTemplate/CustomTemplate_Client_UniTask/config/cs_bin/bean.tpl
delete mode 100644 Configs/CustomTemplate/CustomTemplate_Client_UniTask/config/cs_bin/table.tpl
delete mode 100644 Configs/CustomTemplate/CustomTemplate_Client_UniTask/config/cs_bin/tables.tpl
delete mode 100644 Configs/CustomTemplate/CustomTemplate_Server_Task/config/cs_bin/bean.tpl
delete mode 100644 Configs/CustomTemplate/CustomTemplate_Server_Task/config/cs_bin/table.tpl
delete mode 100644 Configs/CustomTemplate/CustomTemplate_Server_Task/config/cs_bin/tables.tpl
create mode 100644 Configs/GameConfig/CustomTemplate/CustomTemplate_Client_LazyLoad/cs-bin/tables.sbn
create mode 100644 Configs/GameConfig/gen_code_bin_to_project_lazyload.bat
diff --git a/Configs/CustomTemplate/CustomTemplate_Client/ConfigSystem.cs b/Configs/CustomTemplate/CustomTemplate_Client/ConfigSystem.cs
deleted file mode 100644
index 29327c55..00000000
--- a/Configs/CustomTemplate/CustomTemplate_Client/ConfigSystem.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using GameBase;
-using GameConfig;
-using Luban;
-using TEngine;
-using UnityEngine;
-
-///
-/// 配置加载器。
-///
-public class ConfigSystem : Singleton
-{
- private bool _init = false;
-
- private Tables _tables;
-
- public Tables Tables
- {
- get
- {
- if (!_init)
- {
- Load();
- }
- return _tables;
- }
- }
-
- ///
- /// 加载配置。
- ///
- public void Load()
- {
- _tables = new Tables(LoadByteBuf);
- _init = true;
- }
-
- ///
- /// 加载二进制配置。
- ///
- /// FileName
- /// ByteBuf
- private ByteBuf LoadByteBuf(string file)
- {
- var textAssets = GameModule.Resource.LoadAsset(file);
- byte[] ret = textAssets.bytes;
- return new ByteBuf(ret);
- }
-}
\ No newline at end of file
diff --git a/Configs/CustomTemplate/CustomTemplate_Client_LazyLoad/ConfigSystem.cs b/Configs/CustomTemplate/CustomTemplate_Client_LazyLoad/ConfigSystem.cs
deleted file mode 100644
index b68d0fab..00000000
--- a/Configs/CustomTemplate/CustomTemplate_Client_LazyLoad/ConfigSystem.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using Bright.Serialization;
-using GameBase;
-using GameConfig;
-using TEngine;
-using UnityEngine;
-
-///
-/// 配置加载器。
-///
-public class ConfigSystem : 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);
- }
-}
\ No newline at end of file
diff --git a/Configs/CustomTemplate/CustomTemplate_Client_LazyLoad/config/cs_bin/_.tpl b/Configs/CustomTemplate/CustomTemplate_Client_LazyLoad/config/cs_bin/_.tpl
deleted file mode 100644
index 43ab323c..00000000
--- a/Configs/CustomTemplate/CustomTemplate_Client_LazyLoad/config/cs_bin/_.tpl
+++ /dev/null
@@ -1,87 +0,0 @@
-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/Configs/CustomTemplate/CustomTemplate_Client_LazyLoad/config/cs_bin/table.tpl b/Configs/CustomTemplate/CustomTemplate_Client_LazyLoad/config/cs_bin/table.tpl
deleted file mode 100644
index ff3f2bee..00000000
--- a/Configs/CustomTemplate/CustomTemplate_Client_LazyLoad/config/cs_bin/table.tpl
+++ /dev/null
@@ -1,413 +0,0 @@
-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/Configs/CustomTemplate/CustomTemplate_Client_LazyLoad/config/cs_bin/tables.tpl b/Configs/CustomTemplate/CustomTemplate_Client_LazyLoad/config/cs_bin/tables.tpl
deleted file mode 100644
index 3c5bfafd..00000000
--- a/Configs/CustomTemplate/CustomTemplate_Client_LazyLoad/config/cs_bin/tables.tpl
+++ /dev/null
@@ -1,40 +0,0 @@
-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/Configs/CustomTemplate/CustomTemplate_Client_UniTask/ConfigSystem.cs b/Configs/CustomTemplate/CustomTemplate_Client_UniTask/ConfigSystem.cs
deleted file mode 100644
index 5ef21b1b..00000000
--- a/Configs/CustomTemplate/CustomTemplate_Client_UniTask/ConfigSystem.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-using System.Collections.Generic;
-using System.Threading;
-using Bright.Serialization;
-using Cysharp.Threading.Tasks;
-using GameBase;
-using GameConfig;
-using TEngine;
-using UnityEngine;
-
-///
-/// 配置加载器
-///
-public class ConfigSystem : Singleton
-{
- private bool _init = false;
-
- private Tables _tables;
-
- public Tables Tables
- {
- get
- {
- if (!_init)
- {
-#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();
-
- ///
- /// 异步加载配置。
- ///
- public async UniTask LoadAsync()
- {
- _tables = new Tables();
- await _tables.LoadAsync(LoadByteBufAsync);
- _init = true;
- }
-
- ///
- /// 异步加载二进制配置。
- ///
- /// FileName
- /// ByteBuf
- private async UniTask LoadByteBufAsync(string file)
- {
-#if false
- GameTickWatcher gameTickWatcher = new GameTickWatcher();
-#endif
- byte[] ret;
- var location = file;
- if (_configs.TryGetValue(location, out var config))
- {
- ret = config.bytes;
- }
- else
- {
- var textAssets = await GameModule.Resource.LoadAssetAsync(location, CancellationToken.None);
- ret = textAssets.bytes;
- RegisterTextAssets(file, textAssets);
- }
-#if false
- Log.Warning($"LoadByteBuf {file} used time {gameTickWatcher.ElapseTime()}");
-#endif
- return new ByteBuf(ret);
- }
-
- ///
- /// 注册配置资源。
- ///
- /// 资源Key。
- /// 资源实例。
- /// 注册成功。
- private bool RegisterTextAssets(string key, TextAsset value)
- {
- if (string.IsNullOrEmpty(key))
- {
- return false;
- }
-
- if (value == null)
- {
- return false;
- }
- _configs[key] = value;
- return true;
- }
-}
\ No newline at end of file
diff --git a/Configs/CustomTemplate/CustomTemplate_Client_UniTask/config/cs_bin/bean.tpl b/Configs/CustomTemplate/CustomTemplate_Client_UniTask/config/cs_bin/bean.tpl
deleted file mode 100644
index 7ce5006e..00000000
--- a/Configs/CustomTemplate/CustomTemplate_Client_UniTask/config/cs_bin/bean.tpl
+++ /dev/null
@@ -1,115 +0,0 @@
-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
-}}
-
-{{cs_start_name_space_grace 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 {{x.cs_method_modifier}} void Resolve(Dictionary _tables)
- {
- {{~if parent_def_type~}}
- base.Resolve(_tables);
- {{~end~}}
- {{~ for field in export_fields ~}}
- {{~if field.gen_ref~}}
- {{cs_ref_validator_resolve field}}
- {{~else if field.has_recursive_ref~}}
- {{cs_recursive_resolve field '_tables'}}
- {{~end~}}
- {{~end~}}
- PostResolve();
- }
-
- public {{x.cs_method_modifier}} void TranslateText(System.Func translator)
- {
- {{~if parent_def_type~}}
- base.TranslateText(translator);
- {{~end~}}
- {{~ for field in export_fields ~}}
- {{~if field.gen_text_key~}}
- {{cs_translate_text field 'translator'}}
- {{~else if field.has_recursive_text~}}
- {{cs_recursive_translate_text field 'translator'}}
- {{~end~}}
- {{~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();
- partial void PostResolve();
-}
-
-{{cs_end_name_space_grace x.namespace_with_top_module}}
\ No newline at end of file
diff --git a/Configs/CustomTemplate/CustomTemplate_Client_UniTask/config/cs_bin/table.tpl b/Configs/CustomTemplate/CustomTemplate_Client_UniTask/config/cs_bin/table.tpl
deleted file mode 100644
index 516c1764..00000000
--- a/Configs/CustomTemplate/CustomTemplate_Client_UniTask/config/cs_bin/table.tpl
+++ /dev/null
@@ -1,173 +0,0 @@
-using Bright.Serialization;
-using System.Collections.Generic;
-
-
-{{cs_start_name_space_grace 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}}
-{
- {{~if x.is_map_table ~}}
- private readonly Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> _dataMap;
- private readonly List<{{cs_define_type value_type}}> _dataList;
-
- public {{name}}(ByteBuf _buf)
- {
- _dataMap = new Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}>();
- _dataList = new List<{{cs_define_type value_type}}>();
-
- for(int n = _buf.ReadSize() ; n > 0 ; --n)
- {
- {{cs_define_type value_type}} _v;
- {{cs_deserialize '_buf' '_v' value_type}}
- _dataList.Add(_v);
- _dataMap.Add(_v.{{x.index_field.convention_name}}, _v);
- }
- PostInit();
- }
-
- public Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> DataMap => _dataMap;
- public List<{{cs_define_type value_type}}> DataList => _dataList;
-
-{{~if value_type.is_dynamic~}}
- public T GetOrDefaultAs({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} => _dataMap.TryGetValue(key, out var v) ? (T)v : null;
- public T GetAs({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} => (T)_dataMap[key];
-{{~end~}}
- public {{cs_define_type value_type}} GetOrDefault({{cs_define_type key_type}} key) => _dataMap.TryGetValue(key, out var v) ? v : null;
- public {{cs_define_type value_type}} Get({{cs_define_type key_type}} key) => _dataMap[key];
- public {{cs_define_type value_type}} this[{{cs_define_type key_type}} key] => _dataMap[key];
-
- public void Resolve(Dictionary _tables)
- {
- foreach(var v in _dataList)
- {
- v.Resolve(_tables);
- }
- PostResolve();
- }
-
- public void TranslateText(System.Func translator)
- {
- foreach(var v in _dataList)
- {
- v.TranslateText(translator);
- }
- }
- {{~else if x.is_list_table ~}}
- private readonly List<{{cs_define_type value_type}}> _dataList;
-
- {{~if x.is_union_index~}}
- private {{cs_table_union_map_type_name x}} _dataMapUnion;
- {{~else if !x.index_list.empty?~}}
- {{~for idx in x.index_list~}}
- private Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}> _dataMap_{{idx.index_field.name}};
- {{~end~}}
- {{~end~}}
-
- public {{name}}(ByteBuf _buf)
- {
- _dataList = new List<{{cs_define_type value_type}}>();
-
- for(int n = _buf.ReadSize() ; n > 0 ; --n)
- {
- {{cs_define_type value_type}} _v;
- {{cs_deserialize '_buf' '_v' value_type}}
- _dataList.Add(_v);
- }
- {{~if x.is_union_index~}}
- _dataMapUnion = new {{cs_table_union_map_type_name x}}();
- foreach(var _v in _dataList)
- {
- _dataMapUnion.Add(({{cs_table_key_list x "_v"}}), _v);
- }
- {{~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}}>();
- {{~end~}}
- foreach(var _v in _dataList)
- {
- {{~for idx in x.index_list~}}
- _dataMap_{{idx.index_field.name}}.Add(_v.{{idx.index_field.convention_name}}, _v);
- {{~end~}}
- }
- {{~end~}}
- PostInit();
- }
-
-
- public List<{{cs_define_type value_type}}> DataList => _dataList;
-
- {{~if x.is_union_index~}}
- public {{cs_define_type value_type}} Get({{cs_table_get_param_def_list x}}) => _dataMapUnion.TryGetValue(({{cs_table_get_param_name_list x}}), out {{cs_define_type value_type}} __v) ? __v : null;
- {{~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) => _dataMap_{{idx.index_field.name}}.TryGetValue(key, out {{cs_define_type value_type}} __v) ? __v : null;
- {{~end~}}
- {{~end~}}
-
- public void Resolve(Dictionary _tables)
- {
- foreach(var v in _dataList)
- {
- v.Resolve(_tables);
- }
- PostResolve();
- }
-
- public void TranslateText(System.Func translator)
- {
- foreach(var v in _dataList)
- {
- v.TranslateText(translator);
- }
- }
- {{~else~}}
-
- private readonly {{cs_define_type value_type}} _data;
-
- public {{name}}(ByteBuf _buf)
- {
- int n = _buf.ReadSize();
- if (n != 1) throw new SerializationException("table mode=one, but size != 1");
- {{cs_deserialize '_buf' '_data' value_type}}
- PostInit();
- }
-
-
- {{~ 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}};
- {{~end~}}
-
- public void Resolve(Dictionary _tables)
- {
- _data.Resolve(_tables);
- PostResolve();
- }
-
- public void TranslateText(System.Func translator)
- {
- _data.TranslateText(translator);
- }
-
- {{~end~}}
-
- partial void PostInit();
- partial void PostResolve();
-}
-
-{{cs_end_name_space_grace x.namespace_with_top_module}}
\ No newline at end of file
diff --git a/Configs/CustomTemplate/CustomTemplate_Client_UniTask/config/cs_bin/tables.tpl b/Configs/CustomTemplate/CustomTemplate_Client_UniTask/config/cs_bin/tables.tpl
deleted file mode 100644
index 58875994..00000000
--- a/Configs/CustomTemplate/CustomTemplate_Client_UniTask/config/cs_bin/tables.tpl
+++ /dev/null
@@ -1,53 +0,0 @@
-using Bright.Serialization;
-using Cysharp.Threading.Tasks;
-using System.Collections.Generic;
-
-{{
- name = x.name
- namespace = x.namespace
- tables = x.tables
-}}
-namespace {{namespace}}
-{
-
-public sealed class {{name}}
-{
- {{~for table in tables ~}}
-{{~if table.comment != '' ~}}
- ///
- /// {{table.escape_comment}}
- ///
-{{~end~}}
- public {{table.full_name}} {{table.name}} {get; private set; }
- {{~end~}}
-
- public {{name}}() { }
-
- public async UniTask LoadAsync(System.Func> loader)
- {
- var tables = new System.Collections.Generic.Dictionary();
- List list = new List();
- {{~for table in tables ~}}
- list.Add(UniTask.Create(async () =>
- {
- {{table.name}} = new {{table.full_name}}(await loader("{{table.output_data_file}}"));
- tables.Add("{{table.full_name}}", {{table.name}});
- }));
- {{~end~}}
-
- await UniTask.WhenAll(list);
-
- {{~for table in tables ~}}
- {{table.name}}.Resolve(tables);
- {{~end~}}
- }
-
- public void TranslateText(System.Func translator)
- {
- {{~for table in tables ~}}
- {{table.name}}.TranslateText(translator);
- {{~end~}}
- }
-}
-
-}
\ No newline at end of file
diff --git a/Configs/CustomTemplate/CustomTemplate_Server_Task/config/cs_bin/bean.tpl b/Configs/CustomTemplate/CustomTemplate_Server_Task/config/cs_bin/bean.tpl
deleted file mode 100644
index 7ce5006e..00000000
--- a/Configs/CustomTemplate/CustomTemplate_Server_Task/config/cs_bin/bean.tpl
+++ /dev/null
@@ -1,115 +0,0 @@
-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
-}}
-
-{{cs_start_name_space_grace 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 {{x.cs_method_modifier}} void Resolve(Dictionary _tables)
- {
- {{~if parent_def_type~}}
- base.Resolve(_tables);
- {{~end~}}
- {{~ for field in export_fields ~}}
- {{~if field.gen_ref~}}
- {{cs_ref_validator_resolve field}}
- {{~else if field.has_recursive_ref~}}
- {{cs_recursive_resolve field '_tables'}}
- {{~end~}}
- {{~end~}}
- PostResolve();
- }
-
- public {{x.cs_method_modifier}} void TranslateText(System.Func translator)
- {
- {{~if parent_def_type~}}
- base.TranslateText(translator);
- {{~end~}}
- {{~ for field in export_fields ~}}
- {{~if field.gen_text_key~}}
- {{cs_translate_text field 'translator'}}
- {{~else if field.has_recursive_text~}}
- {{cs_recursive_translate_text field 'translator'}}
- {{~end~}}
- {{~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();
- partial void PostResolve();
-}
-
-{{cs_end_name_space_grace x.namespace_with_top_module}}
\ No newline at end of file
diff --git a/Configs/CustomTemplate/CustomTemplate_Server_Task/config/cs_bin/table.tpl b/Configs/CustomTemplate/CustomTemplate_Server_Task/config/cs_bin/table.tpl
deleted file mode 100644
index 516c1764..00000000
--- a/Configs/CustomTemplate/CustomTemplate_Server_Task/config/cs_bin/table.tpl
+++ /dev/null
@@ -1,173 +0,0 @@
-using Bright.Serialization;
-using System.Collections.Generic;
-
-
-{{cs_start_name_space_grace 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}}
-{
- {{~if x.is_map_table ~}}
- private readonly Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> _dataMap;
- private readonly List<{{cs_define_type value_type}}> _dataList;
-
- public {{name}}(ByteBuf _buf)
- {
- _dataMap = new Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}>();
- _dataList = new List<{{cs_define_type value_type}}>();
-
- for(int n = _buf.ReadSize() ; n > 0 ; --n)
- {
- {{cs_define_type value_type}} _v;
- {{cs_deserialize '_buf' '_v' value_type}}
- _dataList.Add(_v);
- _dataMap.Add(_v.{{x.index_field.convention_name}}, _v);
- }
- PostInit();
- }
-
- public Dictionary<{{cs_define_type key_type}}, {{cs_define_type value_type}}> DataMap => _dataMap;
- public List<{{cs_define_type value_type}}> DataList => _dataList;
-
-{{~if value_type.is_dynamic~}}
- public T GetOrDefaultAs({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} => _dataMap.TryGetValue(key, out var v) ? (T)v : null;
- public T GetAs({{cs_define_type key_type}} key) where T : {{cs_define_type value_type}} => (T)_dataMap[key];
-{{~end~}}
- public {{cs_define_type value_type}} GetOrDefault({{cs_define_type key_type}} key) => _dataMap.TryGetValue(key, out var v) ? v : null;
- public {{cs_define_type value_type}} Get({{cs_define_type key_type}} key) => _dataMap[key];
- public {{cs_define_type value_type}} this[{{cs_define_type key_type}} key] => _dataMap[key];
-
- public void Resolve(Dictionary _tables)
- {
- foreach(var v in _dataList)
- {
- v.Resolve(_tables);
- }
- PostResolve();
- }
-
- public void TranslateText(System.Func translator)
- {
- foreach(var v in _dataList)
- {
- v.TranslateText(translator);
- }
- }
- {{~else if x.is_list_table ~}}
- private readonly List<{{cs_define_type value_type}}> _dataList;
-
- {{~if x.is_union_index~}}
- private {{cs_table_union_map_type_name x}} _dataMapUnion;
- {{~else if !x.index_list.empty?~}}
- {{~for idx in x.index_list~}}
- private Dictionary<{{cs_define_type idx.type}}, {{cs_define_type value_type}}> _dataMap_{{idx.index_field.name}};
- {{~end~}}
- {{~end~}}
-
- public {{name}}(ByteBuf _buf)
- {
- _dataList = new List<{{cs_define_type value_type}}>();
-
- for(int n = _buf.ReadSize() ; n > 0 ; --n)
- {
- {{cs_define_type value_type}} _v;
- {{cs_deserialize '_buf' '_v' value_type}}
- _dataList.Add(_v);
- }
- {{~if x.is_union_index~}}
- _dataMapUnion = new {{cs_table_union_map_type_name x}}();
- foreach(var _v in _dataList)
- {
- _dataMapUnion.Add(({{cs_table_key_list x "_v"}}), _v);
- }
- {{~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}}>();
- {{~end~}}
- foreach(var _v in _dataList)
- {
- {{~for idx in x.index_list~}}
- _dataMap_{{idx.index_field.name}}.Add(_v.{{idx.index_field.convention_name}}, _v);
- {{~end~}}
- }
- {{~end~}}
- PostInit();
- }
-
-
- public List<{{cs_define_type value_type}}> DataList => _dataList;
-
- {{~if x.is_union_index~}}
- public {{cs_define_type value_type}} Get({{cs_table_get_param_def_list x}}) => _dataMapUnion.TryGetValue(({{cs_table_get_param_name_list x}}), out {{cs_define_type value_type}} __v) ? __v : null;
- {{~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) => _dataMap_{{idx.index_field.name}}.TryGetValue(key, out {{cs_define_type value_type}} __v) ? __v : null;
- {{~end~}}
- {{~end~}}
-
- public void Resolve(Dictionary _tables)
- {
- foreach(var v in _dataList)
- {
- v.Resolve(_tables);
- }
- PostResolve();
- }
-
- public void TranslateText(System.Func translator)
- {
- foreach(var v in _dataList)
- {
- v.TranslateText(translator);
- }
- }
- {{~else~}}
-
- private readonly {{cs_define_type value_type}} _data;
-
- public {{name}}(ByteBuf _buf)
- {
- int n = _buf.ReadSize();
- if (n != 1) throw new SerializationException("table mode=one, but size != 1");
- {{cs_deserialize '_buf' '_data' value_type}}
- PostInit();
- }
-
-
- {{~ 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}};
- {{~end~}}
-
- public void Resolve(Dictionary _tables)
- {
- _data.Resolve(_tables);
- PostResolve();
- }
-
- public void TranslateText(System.Func translator)
- {
- _data.TranslateText(translator);
- }
-
- {{~end~}}
-
- partial void PostInit();
- partial void PostResolve();
-}
-
-{{cs_end_name_space_grace x.namespace_with_top_module}}
\ No newline at end of file
diff --git a/Configs/CustomTemplate/CustomTemplate_Server_Task/config/cs_bin/tables.tpl b/Configs/CustomTemplate/CustomTemplate_Server_Task/config/cs_bin/tables.tpl
deleted file mode 100644
index 4b638b1a..00000000
--- a/Configs/CustomTemplate/CustomTemplate_Server_Task/config/cs_bin/tables.tpl
+++ /dev/null
@@ -1,46 +0,0 @@
-using Bright.Serialization;
-using System.Threading.Tasks;
-
-{{
- name = x.name
- namespace = x.namespace
- tables = x.tables
-}}
-namespace {{namespace}}
-{
-
-public sealed class {{name}}
-{
- {{~for table in tables ~}}
-{{~if table.comment != '' ~}}
- ///
- /// {{table.escape_comment}}
- ///
-{{~end~}}
- public {{table.full_name}} {{table.name}} {get; private set; }
- {{~end~}}
-
- public {{name}}() { }
-
- public async Task LoadAsync(System.Func> loader)
- {
- var tables = new System.Collections.Generic.Dictionary();
- {{~for table in tables ~}}
- {{table.name}} = new {{table.full_name}}(await loader("{{table.output_data_file}}"));
- tables.Add("{{table.full_name}}", {{table.name}});
- {{~end~}}
-
- {{~for table in tables ~}}
- {{table.name}}.Resolve(tables);
- {{~end~}}
- }
-
- public void TranslateText(System.Func translator)
- {
- {{~for table in tables ~}}
- {{table.name}}.TranslateText(translator);
- {{~end~}}
- }
-}
-
-}
\ No newline at end of file
diff --git a/Configs/GameConfig/CustomTemplate/CustomTemplate_Client_LazyLoad/cs-bin/tables.sbn b/Configs/GameConfig/CustomTemplate/CustomTemplate_Client_LazyLoad/cs-bin/tables.sbn
new file mode 100644
index 00000000..8a3718dd
--- /dev/null
+++ b/Configs/GameConfig/CustomTemplate/CustomTemplate_Client_LazyLoad/cs-bin/tables.sbn
@@ -0,0 +1,55 @@
+using Luban;
+
+{{namespace_with_grace_begin __namespace}}
+public partial class {{__name}}
+{
+ #region The Tables
+
+ {{~for table in __tables ~}}
+{{~if table.comment != '' ~}}
+ ///
+ /// {{escape_comment table.comment}}
+ ///
+{{~end~}}
+ private {{table.full_name}} m_{{table.name}};
+ public {{table.full_name}} {{format_property_name __code_style table.name}}
+ {
+ get
+ {
+ if (m_{{table.name}} == null)
+ {
+ m_{{table.name}} = new {{table.full_name}}(defaultLoader("{{table.output_data_file}}"));
+ m_{{table.name}}.ResolveRef(this);
+ }
+ return m_{{table.name}};
+ }
+ set
+ {
+ m_{{table.name}} = value;
+ m_{{table.name}}.ResolveRef(this);
+ }
+ }
+ {{~end~}}
+
+ #endregion
+
+ System.Func defaultLoader;
+
+ public {{__name}}(System.Func loader)
+ {
+ SetDefaultLoader(loader);
+ Init();
+ }
+
+ public void SetDefaultLoader(System.Func loader)
+ {
+ defaultLoader = null;
+ defaultLoader = loader;
+ }
+
+ //public partial void Init();
+
+ public void Init(){}
+}
+
+{{namespace_with_grace_end __namespace}}
\ No newline at end of file
diff --git a/Configs/GameConfig/gen_code_bin_to_project.bat b/Configs/GameConfig/gen_code_bin_to_project.bat
index 9d97b29e..ea012320 100644
--- a/Configs/GameConfig/gen_code_bin_to_project.bat
+++ b/Configs/GameConfig/gen_code_bin_to_project.bat
@@ -3,6 +3,9 @@ set LUBAN_DLL=%WORKSPACE%\Tools\Luban\Luban.dll
set CONF_ROOT=.
set DATA_OUTPATH=%WORKSPACE%/UnityProject/Assets/AssetRaw/Configs/bytes/
set CODE_OUTPATH=%WORKSPACE%/UnityProject/Assets/GameScripts/HotFix/GameProto/GameConfig/
+
+xcopy /s /e /i /y "%CONF_ROOT%/CustomTemplate/ConfigSystem.cs" "%WORKSPACE%/UnityProject/Assets/GameScripts/HotFix/GameProto/ConfigSystem.cs"
+
dotnet %LUBAN_DLL% ^
-t client ^
-c cs-bin ^
diff --git a/Configs/GameConfig/gen_code_bin_to_project_lazyload.bat b/Configs/GameConfig/gen_code_bin_to_project_lazyload.bat
new file mode 100644
index 00000000..5556575d
--- /dev/null
+++ b/Configs/GameConfig/gen_code_bin_to_project_lazyload.bat
@@ -0,0 +1,18 @@
+set WORKSPACE=../..
+set LUBAN_DLL=%WORKSPACE%\Tools\Luban\Luban.dll
+set CONF_ROOT=.
+set DATA_OUTPATH=%WORKSPACE%/UnityProject/Assets/AssetRaw/Configs/bytes/
+set CODE_OUTPATH=%WORKSPACE%/UnityProject/Assets/GameScripts/HotFix/GameProto/GameConfig/
+
+xcopy /s /e /i /y "%CONF_ROOT%/CustomTemplate/ConfigSystem.cs" "%WORKSPACE%/UnityProject/Assets/GameScripts/HotFix/GameProto/ConfigSystem.cs"
+
+dotnet %LUBAN_DLL% ^
+ -t client ^
+ -c cs-bin ^
+ -d bin^
+ --conf %CONF_ROOT%\luban.conf ^
+ --customTemplateDir %CONF_ROOT%\CustomTemplate\CustomTemplate_Client_LazyLoad ^
+ -x outputCodeDir=%CODE_OUTPATH% ^
+ -x outputDataDir=%DATA_OUTPATH%
+pause
+