using Bright.Serialization; using GameConfig; using TEngine; using TEngine.Core; /// /// 配置加载器。 /// public class ConfigLoader:Singleton { private bool _init = false; private Tables _tables = null!; public ConfigLoader() { this.Load(); } public Tables Tables { get { if (!_init) { _init = true; Load(); } return _tables; } } /// /// 加载配置。 /// public void Load() { var tablesCtor = typeof(Tables).GetConstructors()[0]; var loaderReturnType = tablesCtor.GetParameters()[0].ParameterType.GetGenericArguments()[1]; System.Delegate loader = new System.Func(LoadByteBuf); _tables = (Tables)tablesCtor.Invoke(new object[] { loader }); } /// /// 加载二进制配置。 /// /// FileName /// ByteBuf private ByteBuf LoadByteBuf(string file) { byte[]ret = File.ReadAllBytes($"../../../Config/GameConfig/{file}.bytes"); return new ByteBuf(ret); } }