diff --git a/Assets/Scripts/Configs/Editor/CfgEditorUtil.cs b/Assets/Scripts/Configs/Editor/CfgEditorUtil.cs index f8c33bf5a..e7f116f82 100644 --- a/Assets/Scripts/Configs/Editor/CfgEditorUtil.cs +++ b/Assets/Scripts/Configs/Editor/CfgEditorUtil.cs @@ -19,14 +19,14 @@ namespace NBF [MenuItem("构建/配置表/导表")] public static void BuildExcel() { - ExcelToJsonWindow.GenConfig(false); + // ExcelToJsonWindow.GenConfig(false); AssetDatabase.Refresh(); } [MenuItem("构建/配置表/导多语言")] public static void BuildLanguage() { - ExcelToJsonWindow.GenLanguage(); + // ExcelToJsonWindow.GenLanguage(); AssetDatabase.Refresh(); } diff --git a/Assets/Scripts/Editor/Builder/Tasks/BuildExcelTask.cs b/Assets/Scripts/Editor/Builder/Tasks/BuildExcelTask.cs index 05599a8c0..45a15eeac 100644 --- a/Assets/Scripts/Editor/Builder/Tasks/BuildExcelTask.cs +++ b/Assets/Scripts/Editor/Builder/Tasks/BuildExcelTask.cs @@ -8,7 +8,7 @@ namespace NBF { public override void Run(BuildContext context) { - ExcelToJsonWindow.GenConfig(false); + // ExcelToJsonWindow.GenConfig(false); } } } \ No newline at end of file diff --git a/Assets/Scripts/Editor/Excel/ExcelToJsonWindow.cs b/Assets/Scripts/Editor/Excel/ExcelToJsonWindow.cs index f85b03fe9..e4c3c8715 100644 --- a/Assets/Scripts/Editor/Excel/ExcelToJsonWindow.cs +++ b/Assets/Scripts/Editor/Excel/ExcelToJsonWindow.cs @@ -1,487 +1,487 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using ExcelDataReader; -using NBC; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using UnityEditor; -using UnityEngine; -using Debug = UnityEngine.Debug; - -namespace NBF -{ - public static class ExcelToJsonWindow - { - #region 生成配置表 - - public static void GenConfig(bool showMessageBox = true) - { - CfgEditorUtil.GenConfigScripts(); - GenConfig(Application.dataPath + "/../Config", showMessageBox); - } - - - public static void GenConfig(string path, bool showMessageBox = false) - { - List list = new List(); - - GetFiles(path, fileList: ref list); - - AllJsonData.Clear(); - Stopwatch s = Stopwatch.StartNew(); - - ReadExcel(list.ToArray()); - - BuildAsset(); - - s.Stop(); - if (showMessageBox) - { - EditorUtility.DisplayDialog("成功", $"导表完成,耗时{(s.ElapsedMilliseconds / 1000f):.00}秒", "知道了"); - EditorUtility.ClearProgressBar(); - } - else - { - Debug.Log($"导表完成,耗时{(s.ElapsedMilliseconds / 1000f):.00}秒"); - } - - AssetDatabase.Refresh(); - } - - - private static void BuildAsset() - { - var json = JsonConvert.SerializeObject(AllJsonData, Formatting.Indented, new JsonSerializerSettings - { - ReferenceLoopHandling = ReferenceLoopHandling.Ignore - }); - var jsonObj = JObject.Parse(json); - - Dictionary tokens = new Dictionary(StringComparer.OrdinalIgnoreCase); - - foreach (var item in jsonObj) - { - try - { - var name = item.Key; - var value = item.Value; - if (value != null) - { - tokens[name] = value; - } - } - catch (Exception e) - { - Log.Error($"读表异常,请检查,name={item.Key} ex={e}"); - } - } - - var relativePath = ConfigAssets.SavePath; - - var asset = EditorUtils.GetOrCreateAsset(relativePath); - - var types = Reflection.GetAllNonAbstractDerivedTypes(); - foreach (var type in types) - { - var tableNameAttribute = type.GetCustomAttribute(); - if (tableNameAttribute == null) continue; - if (!tokens.TryGetValue(tableNameAttribute.Name, out var token)) - { - Log.Warning($"{tableNameAttribute.Name} 解析失败,tableName不一致"); - continue; - } - - if (token is not JArray jArray) return; - asset.Parse(jArray.ToArray(), type); - } - - EditorUtility.SetDirty(asset); - AssetDatabase.SaveAssets(); - AssetDatabase.Refresh(); - } - - #endregion - - #region 生成多语言 - - public static void GenLanguage() - { - var path = Application.dataPath + "/../Config/language"; - - List list = new List(); - - GetFiles(path, fileList: ref list); - - AllJsonData.Clear(); - Stopwatch s = Stopwatch.StartNew(); - - ReadExcel(list.ToArray()); - - var savePath = Path.Combine(Application.dataPath, "Resources/config/language.json"); - - BuildJson(savePath); - - s.Stop(); - - Debug.Log($"导多语言完成,耗时{(s.ElapsedMilliseconds / 1000f):.00}秒"); - - AssetDatabase.Refresh(); - } - - private static void BuildJson(string savaPath) - { - var json = JsonConvert.SerializeObject(AllJsonData, Formatting.Indented, new JsonSerializerSettings - { - ReferenceLoopHandling = ReferenceLoopHandling.Ignore - }); - SaveJson(savaPath, json); - - AssetDatabase.SaveAssets(); - AssetDatabase.Refresh(); - } - - #endregion - - #region 文件读写 - - private static void GetFiles(string path, ref List fileList) - { - var files = Directory.GetFiles(path); - if (files.Length > 0) - { - foreach (var file in files) - { - var fileName = Path.GetFileName(file); - - if ((fileName.EndsWith(".xls", true, CultureInfo.CurrentCulture) || - fileName.EndsWith(".xlsx", true, CultureInfo.CurrentCulture)) && !fileName.StartsWith(".") && - !fileName.StartsWith("~")) - { - fileList.Add(file.Replace('\\', '/')); - } - } - } - } - - private static void SaveJson(string jsonPath, string json) - { - try - { - if (File.Exists(jsonPath)) - { - File.Delete(jsonPath); - } - - File.WriteAllBytes(jsonPath, Encoding.UTF8.GetBytes(json)); - } - catch (Exception e) - { - // Console.WriteLine(e); - // throw; - } - } - - #endregion - - #region Excel读取 - - private static readonly Dictionary AllJsonData = new Dictionary(); - private static bool _buildIng = false; - private static int _buildTotal = 0; - - private static int _buildDoneCount = 0; - - private static void ReadExcel(IReadOnlyCollection paths) - { - _buildTotal = paths.Count; - _buildDoneCount = 0; - _buildIng = true; - - foreach (var t in paths) - { - ReadSingleExcel(t); - } - - _buildIng = false; - } - - private static void ReadSingleExcelFunc(string xlsxPath, bool isThrow = false) - { - try - { - using FileStream stream = File.Open(xlsxPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); - IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream); - DataSet result = excelReader.AsDataSet(); - // 读取第一张工资表 - DataTableCollection tc = result.Tables; - - if (tc.Count >= 1) - { - foreach (DataTable table in tc) - { - if (!table.TableName.StartsWith("!") && !table.TableName.StartsWith("Sheet")) - { - ReadSingleSheet(table, isThrow); - } - } - } - else - { - Debug.LogError("表名为空,请检查表"); - } - } - catch (Exception e) - { - Log.Error(e); - } - } - - - public static void ReadSingleExcel(string xlsxPath, bool isThrow = false) - { - Stopwatch s = Stopwatch.StartNew(); - string xlsxName = Path.GetFileName(xlsxPath); - - if (!File.Exists(xlsxPath)) - { - Debug.LogError("不存在该Excel!"); - return; - } - - try - { - ReadSingleExcelFunc(xlsxPath, isThrow); - - Debug.Log(xlsxName + ".xlsx" + "转换Json成功!"); - - s.Stop(); - Debug.Log($"导表{xlsxName},花费时间={s.ElapsedMilliseconds}毫秒"); - _buildDoneCount++; - } - catch (Exception e) - { - Debug.LogError(e); - } - } - - /// - /// 读取一个工作表的数据 - /// - /// 读取的工作表数据 - /// 是否抛出异常 - private static void ReadSingleSheet(DataTable dataTable, bool isThrow = false) - { - int rows = dataTable.Rows.Count; - int columns = dataTable.Columns.Count; - if (rows < 1 || columns < 1) - { - return; - } - - // 工作表的行数据 - DataRowCollection collect = dataTable.Rows; - // xlsx对应的数据字段,规定是第二行 - string[] jsonFields = new string[columns]; - string[] jsonFieldsType = new string[columns]; - // 要保存成Json的obj - List objsToSave = new List(); - for (int i = 0; i < columns; i++) - { - //字段 - jsonFields[i] = collect[1][i].ToString(); - //字段类型 - jsonFieldsType[i] = collect[2][i].ToString(); - } - - // _lastTableName = dataTable.TableName; - // 从第三行开始 - for (int i = 3; i < rows; i++) - { - Dictionary jObject = new Dictionary(); - - // _lastX = i; - for (int j = 0; j < columns; j++) - { - var objectValue = collect[i][j].ToString(); - // _lastY = j; - var lastValue = $"{collect[1][j]}---{objectValue}"; - try - { - if (isThrow) - { - Debug.Log($"{i}/{j}/{objectValue}"); - } - - Type type = GetTypeByString(jsonFieldsType[j]); - // 获取字段 - string field = jsonFields[j]; - //过滤掉字段为空的值 - if (!string.IsNullOrEmpty(field)) - { - object value = null; - if (!string.IsNullOrEmpty(objectValue)) - { - //需要先判断下是否为数组 - if (type != typeof(Array)) - { - //需要判断一下是否为bool值 bool 直接返回int 0 或者 1 - if (type == typeof(bool)) - { - value = int.Parse(objectValue); - } - else if (type == typeof(Vector2)) - { - value = objectValue.ToVector2(); - } - else if (type == typeof(Vector3)) - { - value = objectValue.ToVector3(); - } - else - { - value = Convert.ChangeType(objectValue, type); - } - } - else - { - //这里在做二维数组的处理 - //一般到这都是Int数组,当然还可以更细致的处理不同类型的数组 - string[] strs = objectValue.Split(','); - string arrayType = jsonFieldsType[j]; - - object[] ints = new object[strs.Length]; - - for (int k = 0; k < strs.Length; k++) - { - switch (arrayType) - { - case "[int]": - { - int.TryParse(strs[k], out var v); - ints[k] = v; - break; - } - case "[float]": - { - float.TryParse(strs[k], out var v); - ints[k] = v; - break; - } - case "[string]": - ints[k] = strs[k]; - break; - default: - ints[k] = strs[k]; - break; - } - } - - value = ints; - } - } - else - { - // Log.I($"{dataTable.TableName} 字段{field}有空值存在 第{j + 1}列数据 请检查表格!!!"); - //如果值为空会出现导表失败 这里需要做一下处理 - value = GetDataType(type); - } - - jObject[field] = value; - } - } - catch (Exception) - { - Debug.LogError($"解析表错误,table={dataTable.TableName} y={i} x={j} value={lastValue}"); - } - } - - objsToSave.Add(jObject); - } - - AllJsonData[dataTable.TableName] = objsToSave; - } - - - /// - /// 判断一下数据类型 - /// - /// - /// - public static object GetDataType(Type type) - { - object value = null; - if (type == typeof(int) || type == typeof(float)) - { - value = 0; - } - else if (type == typeof(string)) - { - value = ""; - } - else if (type == typeof(bool)) - { - //如果boo值类型为空 默认显示 - value = 0; - } - else if (type == typeof(Array)) - { - value = new List().ToArray(); - } - else - { - value = ""; - } - - return value; - } - - /// - /// 获取字段类型 - /// - /// - /// - public static Type GetTypeByString(string type) - { - switch (type.ToLower()) - { - case "bool": - return typeof(bool); - case "array": - return typeof(Array); - case "double": - return typeof(double); - case "float": - return typeof(float); - case "int": - return typeof(int); - case "long": - return typeof(long); - case "object": - return typeof(object); - case "string": - return typeof(string); - case "[float]": - return typeof(Array); - case "[int]": - return typeof(Array); - case "[string]": - return typeof(Array); - case "v2": - return typeof(Vector2); - case "v3": - return typeof(Vector3); - default: - return typeof(string); - } - } - - #endregion - } -} \ No newline at end of file +// using System; +// using System.Collections.Generic; +// using System.Data; +// using System.Diagnostics; +// using System.Globalization; +// using System.IO; +// using System.Linq; +// using System.Reflection; +// using System.Text; +// using ExcelDataReader; +// using NBC; +// using Newtonsoft.Json; +// using Newtonsoft.Json.Linq; +// using UnityEditor; +// using UnityEngine; +// using Debug = UnityEngine.Debug; +// +// namespace NBF +// { +// public static class ExcelToJsonWindow +// { +// #region 生成配置表 +// +// public static void GenConfig(bool showMessageBox = true) +// { +// CfgEditorUtil.GenConfigScripts(); +// GenConfig(Application.dataPath + "/../Config", showMessageBox); +// } +// +// +// public static void GenConfig(string path, bool showMessageBox = false) +// { +// List list = new List(); +// +// GetFiles(path, fileList: ref list); +// +// AllJsonData.Clear(); +// Stopwatch s = Stopwatch.StartNew(); +// +// ReadExcel(list.ToArray()); +// +// BuildAsset(); +// +// s.Stop(); +// if (showMessageBox) +// { +// EditorUtility.DisplayDialog("成功", $"导表完成,耗时{(s.ElapsedMilliseconds / 1000f):.00}秒", "知道了"); +// EditorUtility.ClearProgressBar(); +// } +// else +// { +// Debug.Log($"导表完成,耗时{(s.ElapsedMilliseconds / 1000f):.00}秒"); +// } +// +// AssetDatabase.Refresh(); +// } +// +// +// private static void BuildAsset() +// { +// var json = JsonConvert.SerializeObject(AllJsonData, Formatting.Indented, new JsonSerializerSettings +// { +// ReferenceLoopHandling = ReferenceLoopHandling.Ignore +// }); +// var jsonObj = JObject.Parse(json); +// +// Dictionary tokens = new Dictionary(StringComparer.OrdinalIgnoreCase); +// +// foreach (var item in jsonObj) +// { +// try +// { +// var name = item.Key; +// var value = item.Value; +// if (value != null) +// { +// tokens[name] = value; +// } +// } +// catch (Exception e) +// { +// Log.Error($"读表异常,请检查,name={item.Key} ex={e}"); +// } +// } +// +// var relativePath = ConfigAssets.SavePath; +// +// var asset = EditorUtils.GetOrCreateAsset(relativePath); +// +// var types = Reflection.GetAllNonAbstractDerivedTypes(); +// foreach (var type in types) +// { +// var tableNameAttribute = type.GetCustomAttribute(); +// if (tableNameAttribute == null) continue; +// if (!tokens.TryGetValue(tableNameAttribute.Name, out var token)) +// { +// Log.Warning($"{tableNameAttribute.Name} 解析失败,tableName不一致"); +// continue; +// } +// +// if (token is not JArray jArray) return; +// asset.Parse(jArray.ToArray(), type); +// } +// +// EditorUtility.SetDirty(asset); +// AssetDatabase.SaveAssets(); +// AssetDatabase.Refresh(); +// } +// +// #endregion +// +// #region 生成多语言 +// +// public static void GenLanguage() +// { +// var path = Application.dataPath + "/../Config/language"; +// +// List list = new List(); +// +// GetFiles(path, fileList: ref list); +// +// AllJsonData.Clear(); +// Stopwatch s = Stopwatch.StartNew(); +// +// ReadExcel(list.ToArray()); +// +// var savePath = Path.Combine(Application.dataPath, "Resources/config/language.json"); +// +// BuildJson(savePath); +// +// s.Stop(); +// +// Debug.Log($"导多语言完成,耗时{(s.ElapsedMilliseconds / 1000f):.00}秒"); +// +// AssetDatabase.Refresh(); +// } +// +// private static void BuildJson(string savaPath) +// { +// var json = JsonConvert.SerializeObject(AllJsonData, Formatting.Indented, new JsonSerializerSettings +// { +// ReferenceLoopHandling = ReferenceLoopHandling.Ignore +// }); +// SaveJson(savaPath, json); +// +// AssetDatabase.SaveAssets(); +// AssetDatabase.Refresh(); +// } +// +// #endregion +// +// #region 文件读写 +// +// private static void GetFiles(string path, ref List fileList) +// { +// var files = Directory.GetFiles(path); +// if (files.Length > 0) +// { +// foreach (var file in files) +// { +// var fileName = Path.GetFileName(file); +// +// if ((fileName.EndsWith(".xls", true, CultureInfo.CurrentCulture) || +// fileName.EndsWith(".xlsx", true, CultureInfo.CurrentCulture)) && !fileName.StartsWith(".") && +// !fileName.StartsWith("~")) +// { +// fileList.Add(file.Replace('\\', '/')); +// } +// } +// } +// } +// +// private static void SaveJson(string jsonPath, string json) +// { +// try +// { +// if (File.Exists(jsonPath)) +// { +// File.Delete(jsonPath); +// } +// +// File.WriteAllBytes(jsonPath, Encoding.UTF8.GetBytes(json)); +// } +// catch (Exception e) +// { +// // Console.WriteLine(e); +// // throw; +// } +// } +// +// #endregion +// +// #region Excel读取 +// +// private static readonly Dictionary AllJsonData = new Dictionary(); +// private static bool _buildIng = false; +// private static int _buildTotal = 0; +// +// private static int _buildDoneCount = 0; +// +// private static void ReadExcel(IReadOnlyCollection paths) +// { +// _buildTotal = paths.Count; +// _buildDoneCount = 0; +// _buildIng = true; +// +// foreach (var t in paths) +// { +// ReadSingleExcel(t); +// } +// +// _buildIng = false; +// } +// +// private static void ReadSingleExcelFunc(string xlsxPath, bool isThrow = false) +// { +// try +// { +// using FileStream stream = File.Open(xlsxPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); +// IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream); +// DataSet result = excelReader.AsDataSet(); +// // 读取第一张工资表 +// DataTableCollection tc = result.Tables; +// +// if (tc.Count >= 1) +// { +// foreach (DataTable table in tc) +// { +// if (!table.TableName.StartsWith("!") && !table.TableName.StartsWith("Sheet")) +// { +// ReadSingleSheet(table, isThrow); +// } +// } +// } +// else +// { +// Debug.LogError("表名为空,请检查表"); +// } +// } +// catch (Exception e) +// { +// Log.Error(e); +// } +// } +// +// +// public static void ReadSingleExcel(string xlsxPath, bool isThrow = false) +// { +// Stopwatch s = Stopwatch.StartNew(); +// string xlsxName = Path.GetFileName(xlsxPath); +// +// if (!File.Exists(xlsxPath)) +// { +// Debug.LogError("不存在该Excel!"); +// return; +// } +// +// try +// { +// ReadSingleExcelFunc(xlsxPath, isThrow); +// +// Debug.Log(xlsxName + ".xlsx" + "转换Json成功!"); +// +// s.Stop(); +// Debug.Log($"导表{xlsxName},花费时间={s.ElapsedMilliseconds}毫秒"); +// _buildDoneCount++; +// } +// catch (Exception e) +// { +// Debug.LogError(e); +// } +// } +// +// /// +// /// 读取一个工作表的数据 +// /// +// /// 读取的工作表数据 +// /// 是否抛出异常 +// private static void ReadSingleSheet(DataTable dataTable, bool isThrow = false) +// { +// int rows = dataTable.Rows.Count; +// int columns = dataTable.Columns.Count; +// if (rows < 1 || columns < 1) +// { +// return; +// } +// +// // 工作表的行数据 +// DataRowCollection collect = dataTable.Rows; +// // xlsx对应的数据字段,规定是第二行 +// string[] jsonFields = new string[columns]; +// string[] jsonFieldsType = new string[columns]; +// // 要保存成Json的obj +// List objsToSave = new List(); +// for (int i = 0; i < columns; i++) +// { +// //字段 +// jsonFields[i] = collect[1][i].ToString(); +// //字段类型 +// jsonFieldsType[i] = collect[2][i].ToString(); +// } +// +// // _lastTableName = dataTable.TableName; +// // 从第三行开始 +// for (int i = 3; i < rows; i++) +// { +// Dictionary jObject = new Dictionary(); +// +// // _lastX = i; +// for (int j = 0; j < columns; j++) +// { +// var objectValue = collect[i][j].ToString(); +// // _lastY = j; +// var lastValue = $"{collect[1][j]}---{objectValue}"; +// try +// { +// if (isThrow) +// { +// Debug.Log($"{i}/{j}/{objectValue}"); +// } +// +// Type type = GetTypeByString(jsonFieldsType[j]); +// // 获取字段 +// string field = jsonFields[j]; +// //过滤掉字段为空的值 +// if (!string.IsNullOrEmpty(field)) +// { +// object value = null; +// if (!string.IsNullOrEmpty(objectValue)) +// { +// //需要先判断下是否为数组 +// if (type != typeof(Array)) +// { +// //需要判断一下是否为bool值 bool 直接返回int 0 或者 1 +// if (type == typeof(bool)) +// { +// value = int.Parse(objectValue); +// } +// else if (type == typeof(Vector2)) +// { +// value = objectValue.ToVector2(); +// } +// else if (type == typeof(Vector3)) +// { +// value = objectValue.ToVector3(); +// } +// else +// { +// value = Convert.ChangeType(objectValue, type); +// } +// } +// else +// { +// //这里在做二维数组的处理 +// //一般到这都是Int数组,当然还可以更细致的处理不同类型的数组 +// string[] strs = objectValue.Split(','); +// string arrayType = jsonFieldsType[j]; +// +// object[] ints = new object[strs.Length]; +// +// for (int k = 0; k < strs.Length; k++) +// { +// switch (arrayType) +// { +// case "[int]": +// { +// int.TryParse(strs[k], out var v); +// ints[k] = v; +// break; +// } +// case "[float]": +// { +// float.TryParse(strs[k], out var v); +// ints[k] = v; +// break; +// } +// case "[string]": +// ints[k] = strs[k]; +// break; +// default: +// ints[k] = strs[k]; +// break; +// } +// } +// +// value = ints; +// } +// } +// else +// { +// // Log.I($"{dataTable.TableName} 字段{field}有空值存在 第{j + 1}列数据 请检查表格!!!"); +// //如果值为空会出现导表失败 这里需要做一下处理 +// value = GetDataType(type); +// } +// +// jObject[field] = value; +// } +// } +// catch (Exception) +// { +// Debug.LogError($"解析表错误,table={dataTable.TableName} y={i} x={j} value={lastValue}"); +// } +// } +// +// objsToSave.Add(jObject); +// } +// +// AllJsonData[dataTable.TableName] = objsToSave; +// } +// +// +// /// +// /// 判断一下数据类型 +// /// +// /// +// /// +// public static object GetDataType(Type type) +// { +// object value = null; +// if (type == typeof(int) || type == typeof(float)) +// { +// value = 0; +// } +// else if (type == typeof(string)) +// { +// value = ""; +// } +// else if (type == typeof(bool)) +// { +// //如果boo值类型为空 默认显示 +// value = 0; +// } +// else if (type == typeof(Array)) +// { +// value = new List().ToArray(); +// } +// else +// { +// value = ""; +// } +// +// return value; +// } +// +// /// +// /// 获取字段类型 +// /// +// /// +// /// +// public static Type GetTypeByString(string type) +// { +// switch (type.ToLower()) +// { +// case "bool": +// return typeof(bool); +// case "array": +// return typeof(Array); +// case "double": +// return typeof(double); +// case "float": +// return typeof(float); +// case "int": +// return typeof(int); +// case "long": +// return typeof(long); +// case "object": +// return typeof(object); +// case "string": +// return typeof(string); +// case "[float]": +// return typeof(Array); +// case "[int]": +// return typeof(Array); +// case "[string]": +// return typeof(Array); +// case "v2": +// return typeof(Vector2); +// case "v3": +// return typeof(Vector3); +// default: +// return typeof(string); +// } +// } +// +// #endregion +// } +// } \ No newline at end of file diff --git a/Assets/Scripts/Fishing2/Helper/ProtoHelper.cs b/Assets/Scripts/Fishing2/Helper/ProtoHelper.cs index bece7b9ee..0922b3380 100644 --- a/Assets/Scripts/Fishing2/Helper/ProtoHelper.cs +++ b/Assets/Scripts/Fishing2/Helper/ProtoHelper.cs @@ -12,7 +12,7 @@ namespace NBF.Fishing2 MapUnitInfo mapUnit = new MapUnitInfo(); mapUnit.Id = self.RoleId; mapUnit.RoleInfo = self.ToSimpleInfo(); - mapUnit.Gears = self.Gears; + // mapUnit.Gears = self.Gears; return mapUnit; } diff --git a/Assets/Scripts/Fishing2/Unit/MapUnit.cs b/Assets/Scripts/Fishing2/Unit/MapUnit.cs index 97cb347f9..6262a44a1 100644 --- a/Assets/Scripts/Fishing2/Unit/MapUnit.cs +++ b/Assets/Scripts/Fishing2/Unit/MapUnit.cs @@ -66,15 +66,15 @@ namespace NBF.Fishing2 } } - public UnitConfig Config() - { - return UnitConfig.Get(ConfigId); - } - - public UnitType UnitType() - { - return Config().Type; - } + // public UnitConfig Config() + // { + // return UnitConfig.Get(ConfigId); + // } + // + // public UnitType UnitType() + // { + // return Config().Type; + // } #region View diff --git a/Assets/Scripts/Game.cs b/Assets/Scripts/Game.cs index c6d8a7b5a..c613847e3 100644 --- a/Assets/Scripts/Game.cs +++ b/Assets/Scripts/Game.cs @@ -19,13 +19,13 @@ namespace NBF /// /// 摄像机配置 /// - public static CameraScriptObject CameraConfig { get; private set; } + // public static CameraScriptObject CameraConfig { get; private set; } public static long SelfId; private void Awake() { Instance = this; - CameraConfig = Resources.Load(nameof(CameraConfig)); + // CameraConfig = Resources.Load(nameof(CameraConfig)); } diff --git a/Assets/Scripts/Generate/NetworkProtocol/CommonProtoData.cs b/Assets/Scripts/Generate/NetworkProtocol/CommonProtoData.cs index 4d3c9abf0..d0ec126b8 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/CommonProtoData.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/CommonProtoData.cs @@ -82,12 +82,12 @@ namespace NBC BaseInfo = default; RoleId = default; Items.Clear(); + ItemBinds.Clear(); Fishs.Clear(); Activities.Clear(); Currency.Clear(); Slots.Clear(); Skills.Clear(); - Gears.Clear(); MapId = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); @@ -100,17 +100,17 @@ namespace NBC [ProtoMember(3)] public List Items = new List(); [ProtoMember(4)] - public List Fishs = new List(); + public List ItemBinds = new List(); [ProtoMember(5)] - public List Activities = new List(); + public List Fishs = new List(); [ProtoMember(6)] - public List Currency = new List(); + public List Activities = new List(); [ProtoMember(7)] - public List Slots = new List(); + public List Currency = new List(); [ProtoMember(8)] - public List Skills = new List(); + public List Slots = new List(); [ProtoMember(9)] - public List Gears = new List(); + public List Skills = new List(); [ProtoMember(10)] public int MapId { get; set; } } @@ -199,6 +199,29 @@ namespace NBC public int Count { get; set; } } /// + /// 玩家当前使用钓组信息 + /// + [ProtoContract] + public partial class ItemBindInfo : AMessage, IProto + { + public static ItemBindInfo Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Item = default; + BindItems.Clear(); +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoMember(1)] + public long Item { get; set; } + [ProtoMember(2)] + public List BindItems = new List(); + } + /// /// 物品信息 /// [ProtoContract] diff --git a/Assets/Scripts/Generate/NetworkProtocol/GameMessage.cs b/Assets/Scripts/Generate/NetworkProtocol/GameMessage.cs index b63f5ca3c..d1129c55b 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/GameMessage.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/GameMessage.cs @@ -9,4 +9,304 @@ using NBC.Serialize; namespace NBC { + /// + /// /////////// ******** 物品信息 *******///////////// + /// + /// + /// 请求背包列表 + /// + [ProtoContract] + public partial class C2Game_GetItemsRequest : AMessage, ICustomRouteRequest, IProto + { + public static C2Game_GetItemsRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoIgnore] + public Game2C_GetItemsResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2Game_GetItemsRequest; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.GameRoute; + } + /// + /// 请求背包列表响应 + /// + [ProtoContract] + public partial class Game2C_GetItemsResponse : AMessage, ICustomRouteResponse, IProto + { + public static Game2C_GetItemsResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + Items.Clear(); + Rigs.Clear(); +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Game2C_GetItemsResponse; } + [ProtoMember(1)] + public List Items = new List(); + [ProtoMember(2)] + public List Rigs = new List(); + [ProtoMember(3)] + public uint ErrorCode { get; set; } + } + /// + /// 请求使用物品 + /// + [ProtoContract] + public partial class C2Game_UseItemRequest : AMessage, ICustomRouteRequest, IProto + { + public static C2Game_UseItemRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoIgnore] + public Game2C_UseItemResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2Game_UseItemRequest; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.GameRoute; + } + /// + /// 请求使用物品响应 + /// + [ProtoContract] + public partial class Game2C_UseItemResponse : AMessage, ICustomRouteResponse, IProto + { + public static Game2C_UseItemResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Game2C_UseItemResponse; } + [ProtoMember(1)] + public uint ErrorCode { get; set; } + } + /// + /// 物品变化 + /// + [ProtoContract] + public partial class Game2C_ItemChange : AMessage, ICustomRouteMessage, IProto + { + public static Game2C_ItemChange Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Type = default; + Items.Clear(); + Removes.Clear(); +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Game2C_ItemChange; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.GameRoute; + [ProtoMember(1)] + public int Type { get; set; } + [ProtoMember(2)] + public List Items = new List(); + [ProtoMember(3)] + public List Removes = new List(); + } + /// + /// /////////// ******** 鱼护 *******///////////// + /// + /// + /// 请求鱼护列表 + /// + [ProtoContract] + public partial class C2Game_GetFishsRequest : AMessage, ICustomRouteRequest, IProto + { + public static C2Game_GetFishsRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoIgnore] + public Game2C_GetFishsResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2Game_GetFishsRequest; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.GameRoute; + } + /// + /// 请求鱼护列表响应 + /// + [ProtoContract] + public partial class Game2C_GetFishsResponse : AMessage, ICustomRouteResponse, IProto + { + public static Game2C_GetFishsResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + Fishs.Clear(); +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Game2C_GetFishsResponse; } + [ProtoMember(1)] + public List Fishs = new List(); + [ProtoMember(2)] + public uint ErrorCode { get; set; } + } + /// + /// 鱼护变化 + /// + [ProtoContract] + public partial class Game2C_FishChange : AMessage, ICustomRouteMessage, IProto + { + public static Game2C_FishChange Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Type = default; + Fishs.Clear(); + Removes.Clear(); +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Game2C_FishChange; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.GameRoute; + [ProtoMember(1)] + public int Type { get; set; } + [ProtoMember(2)] + public List Fishs = new List(); + [ProtoMember(3)] + public List Removes = new List(); + } + /// + /// 请求出售 + /// + [ProtoContract] + public partial class C2Game_SellFishRequest : AMessage, ICustomRouteRequest, IProto + { + public static C2Game_SellFishRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Ids.Clear(); +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoIgnore] + public Game2C_SellFishResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2Game_SellFishRequest; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.GameRoute; + [ProtoMember(1)] + public List Ids = new List(); + } + /// + /// 请求出售响应 + /// + [ProtoContract] + public partial class Game2C_SellFishResponse : AMessage, ICustomRouteResponse, IProto + { + public static Game2C_SellFishResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + Awards.Clear(); +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Game2C_SellFishResponse; } + [ProtoMember(1)] + public List Awards = new List(); + [ProtoMember(2)] + public uint ErrorCode { get; set; } + } + /// + /// /////////// ******** 商店 *******///////////// + /// + /// + /// 请求购买 + /// + [ProtoContract] + public partial class C2Game_BuyRequest : AMessage, ICustomRouteRequest, IProto + { + public static C2Game_BuyRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + [ProtoIgnore] + public Game2C_GetFishsResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2Game_BuyRequest; } + [ProtoIgnore] + public int RouteType => Fantasy.RouteType.GameRoute; + } + /// + /// 请求购买响应 + /// + [ProtoContract] + public partial class Game2C_BuyResponse : AMessage, ICustomRouteResponse, IProto + { + public static Game2C_BuyResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + Awards.Clear(); +#if FANTASY_NET || FANTASY_UNITY + GetScene().MessagePoolComponent.Return(this); +#endif + } + public uint OpCode() { return OuterOpcode.Game2C_BuyResponse; } + [ProtoMember(1)] + public List Awards = new List(); + [ProtoMember(2)] + public uint ErrorCode { get; set; } + } } diff --git a/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs b/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs index 16493aacf..5d4482248 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs @@ -2,61 +2,73 @@ namespace Fantasy { public static partial class OuterOpcode { - public const uint C2Map_CreateRoomRequest = 2281711377; - public const uint Map2C_CreateRoomResponse = 2415929105; + public const uint C2Game_GetItemsRequest = 2281711377; + public const uint Game2C_GetItemsResponse = 2415929105; + public const uint C2Game_UseItemRequest = 2281711378; + public const uint Game2C_UseItemResponse = 2415929106; + public const uint Game2C_ItemChange = 2147493649; + public const uint C2Game_GetFishsRequest = 2281711379; + public const uint Game2C_GetFishsResponse = 2415929107; + public const uint Game2C_FishChange = 2147493650; + public const uint C2Game_SellFishRequest = 2281711380; + public const uint Game2C_SellFishResponse = 2415929108; + public const uint C2Game_BuyRequest = 2281711381; + public const uint Game2C_BuyResponse = 2415929109; + public const uint C2Map_CreateRoomRequest = 2281711382; + public const uint Map2C_CreateRoomResponse = 2415929110; public const uint C2G_ExitRoomRequest = 268445457; public const uint G2C_ExitRoomResponse = 402663185; public const uint C2G_EnterMapRequest = 268445458; public const uint G2C_EnterMapResponse = 402663186; - public const uint Map2C_ChangeMap = 2147493649; + public const uint Map2C_ChangeMap = 2147493651; public const uint C2A_LoginRequest = 268445459; public const uint A2C_LoginResponse = 402663187; public const uint C2G_LoginRequest = 268445460; public const uint G2C_LoginResponse = 402663188; public const uint G2C_RepeatLogin = 134227729; - public const uint C2Game_GetRoleInfoRequest = 2281711378; - public const uint Game2C_GetRoleInfoResponse = 2415929106; - public const uint Map2C_RoleEnterRoomNotify = 2147493650; - public const uint Map2C_RoleExitRoomNotify = 2147493651; - public const uint C2Map_RolePropertyChange = 2147493652; - public const uint Map2C_RoleStateNotify = 2147493653; - public const uint Map2C_RoleGearChangeNotify = 2147493654; - public const uint Map2C_RolePropertyChangeNotify = 2147493655; - public const uint C2Map_Move = 2147493656; - public const uint C2Map_Look = 2147493657; - public const uint Map2C_MoveNotify = 2147493658; - public const uint Map2C_LookeNotify = 2147493659; - public const uint C2S_GetConversationsRequest = 2281711379; - public const uint S2C_GetConversationsResponse = 2415929107; - public const uint C2S_SendMailRequest = 2281711380; - public const uint S2C_SendMailResponse = 2415929108; - public const uint C2S_DeleteMailRequest = 2281711381; - public const uint S2C_DeleteMailResponse = 2415929109; - public const uint S2C_HaveMail = 2147493660; - public const uint S2C_MailState = 2147493661; - public const uint C2S_CreateChannelRequest = 2281711382; - public const uint S2C_CreateChannelResponse = 2415929110; - public const uint C2S_JoinChannelRequest = 2281711383; - public const uint S2C_JoinChannelResponse = 2415929111; - public const uint C2S_SendMessageRequest = 2281711384; - public const uint S2C_SendMessageResponse = 2415929112; - public const uint S2C_Message = 2147493662; - public const uint C2S_CreateClubRequest = 2281711385; - public const uint S2C_CreateClubResponse = 2415929113; - public const uint C2S_GetClubInfoRequest = 2281711386; - public const uint S2C_GetClubInfoResponse = 2415929114; - public const uint C2S_GetMemberListRequest = 2281711387; - public const uint S2C_GetMemberListResponse = 2415929115; - public const uint C2S_GetClubListRequest = 2281711388; - public const uint S2C_GetClubListResponse = 2415929116; - public const uint C2S_JoinClubRequest = 2281711389; - public const uint S2C_JoinClubResponse = 2415929117; - public const uint C2S_LeaveClubRequest = 2281711390; - public const uint S2C_LeaveClubResponse = 2415929118; - public const uint C2S_DissolveClubRequest = 2281711391; - public const uint S2C_DissolveClubResponse = 2415929119; - public const uint C2S_DisposeJoinRequest = 2281711392; - public const uint S2C_DisposeJoinResponse = 2415929120; - public const uint S2C_ClubChange = 2147493663; + public const uint C2Game_GetRoleInfoRequest = 2281711383; + public const uint Game2C_GetRoleInfoResponse = 2415929111; + public const uint Map2C_RoleEnterRoomNotify = 2147493652; + public const uint Map2C_RoleExitRoomNotify = 2147493653; + public const uint C2Map_RolePropertyChange = 2147493654; + public const uint Map2C_RoleStateNotify = 2147493655; + public const uint Map2C_RoleGearChangeNotify = 2147493656; + public const uint Map2C_RolePropertyChangeNotify = 2147493657; + public const uint C2Map_Move = 2147493658; + public const uint C2Map_Look = 2147493659; + public const uint Map2C_MoveNotify = 2147493660; + public const uint Map2C_LookeNotify = 2147493661; + public const uint C2S_GetConversationsRequest = 2281711384; + public const uint S2C_GetConversationsResponse = 2415929112; + public const uint C2S_SendMailRequest = 2281711385; + public const uint S2C_SendMailResponse = 2415929113; + public const uint C2S_DeleteMailRequest = 2281711386; + public const uint S2C_DeleteMailResponse = 2415929114; + public const uint S2C_HaveMail = 2147493662; + public const uint S2C_MailState = 2147493663; + public const uint C2S_CreateChannelRequest = 2281711387; + public const uint S2C_CreateChannelResponse = 2415929115; + public const uint C2S_JoinChannelRequest = 2281711388; + public const uint S2C_JoinChannelResponse = 2415929116; + public const uint C2S_SendMessageRequest = 2281711389; + public const uint S2C_SendMessageResponse = 2415929117; + public const uint S2C_Message = 2147493664; + public const uint C2S_CreateClubRequest = 2281711390; + public const uint S2C_CreateClubResponse = 2415929118; + public const uint C2S_GetClubInfoRequest = 2281711391; + public const uint S2C_GetClubInfoResponse = 2415929119; + public const uint C2S_GetMemberListRequest = 2281711392; + public const uint S2C_GetMemberListResponse = 2415929120; + public const uint C2S_GetClubListRequest = 2281711393; + public const uint S2C_GetClubListResponse = 2415929121; + public const uint C2S_JoinClubRequest = 2281711394; + public const uint S2C_JoinClubResponse = 2415929122; + public const uint C2S_LeaveClubRequest = 2281711395; + public const uint S2C_LeaveClubResponse = 2415929123; + public const uint C2S_DissolveClubRequest = 2281711396; + public const uint S2C_DissolveClubResponse = 2415929124; + public const uint C2S_DisposeJoinRequest = 2281711397; + public const uint S2C_DisposeJoinResponse = 2415929125; + public const uint S2C_ClubChange = 2147493665; } } diff --git a/Assets/Scripts/Generate/NetworkProtocol/RoomMessage.cs b/Assets/Scripts/Generate/NetworkProtocol/RoomMessage.cs index 4370832e4..56c73cf38 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/RoomMessage.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/RoomMessage.cs @@ -225,6 +225,7 @@ namespace NBC Rotation = default; Direction = default; IsStop = default; + IsRun = default; Timestamp = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); @@ -244,6 +245,8 @@ namespace NBC [ProtoMember(5)] public bool IsStop { get; set; } [ProtoMember(6)] + public bool IsRun { get; set; } + [ProtoMember(7)] public long Timestamp { get; set; } } /// diff --git a/Assets/Scripts/Generate/Test.meta b/Assets/Scripts/Generate/Test.meta new file mode 100644 index 000000000..756c07270 --- /dev/null +++ b/Assets/Scripts/Generate/Test.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 797250a29ac28db458a11e40145a9e6c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Generate/Test/BaitConfig.cs b/Assets/Scripts/Generate/Test/BaitConfig.cs new file mode 100644 index 000000000..e5c681acb --- /dev/null +++ b/Assets/Scripts/Generate/Test/BaitConfig.cs @@ -0,0 +1,110 @@ +using System; +using ProtoBuf; +using Fantasy; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using System.Collections.Concurrent; +#if FANTASY_NET +using Fantasy.ConfigTable; +using Fantasy.Serialize; +#else +using NBC; +using NBC.Serialize; +#endif +// ReSharper disable CollectionNeverUpdated.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member +#pragma warning disable CS0169 +#pragma warning disable CS8618 +#pragma warning disable CS8625 +#pragma warning disable CS8603 + +namespace Fantasy +{ + [ProtoContract] + public sealed partial class BaitConfigData : ASerialize, IConfigTable, IProto + { + [ProtoMember(1)] + public List List { get; set; } = new List(); +#if FANTASY_NET + [ProtoIgnore] + private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); +#else + [ProtoIgnore] + private readonly Dictionary _configs = new Dictionary(); +#endif + private static BaitConfigData _instance = null; + + public static BaitConfigData Instance + { + get { return _instance ??= ConfigTableHelper.Load(); } + private set => _instance = value; + } + + public BaitConfig Get(uint id, bool check = true) + { + if (_configs.ContainsKey(id)) + { + return _configs[id]; + } + + if (check) + { + throw new Exception($"BaitConfig not find {id} Id"); + } + + return null; + } + public bool TryGet(uint id, out BaitConfig config) + { + config = null; + + if (!_configs.ContainsKey(id)) + { + return false; + } + + config = _configs[id]; + return true; + } + public override void AfterDeserialization() + { + foreach (var config in List) + { +#if FANTASY_NET + _configs.TryAdd(config.Id, config); +#else + _configs.Add(config.Id, config); +#endif + config.AfterDeserialization(); + } + + EndInit(); + } + + public override void Dispose() + { + Instance = null; + } + } + + [ProtoContract] + public sealed partial class BaitConfig : ASerialize, IProto + { + [ProtoMember(1)] + public uint Id { get; set; } // Id + [ProtoMember(2)] + public string Model { get; set; } // 模型 + [ProtoMember(3)] + public uint EfficacyBase { get; set; } // 吸引力 + [ProtoMember(4)] + public uint Length { get; set; } // 长度(毫米) + [ProtoMember(5)] + public uint Weight { get; set; } // 重量(克) + [ProtoMember(6)] + public uint[] Arr { get; set; } = Array.Empty(); // 重量(克) + [ProtoMember(7)] + public string[] ArrStr { get; set; } = Array.Empty(); // 重量(克) + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/BaitConfig.cs.meta b/Assets/Scripts/Generate/Test/BaitConfig.cs.meta new file mode 100644 index 000000000..30315b183 --- /dev/null +++ b/Assets/Scripts/Generate/Test/BaitConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 6362bd09bd57c6647b87ac7abcde3a6c \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/BobberConfig.cs b/Assets/Scripts/Generate/Test/BobberConfig.cs new file mode 100644 index 000000000..4db4bb1a8 --- /dev/null +++ b/Assets/Scripts/Generate/Test/BobberConfig.cs @@ -0,0 +1,108 @@ +using System; +using ProtoBuf; +using Fantasy; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using System.Collections.Concurrent; +#if FANTASY_NET +using Fantasy.ConfigTable; +using Fantasy.Serialize; +#else +using NBC; +using NBC.Serialize; +#endif +// ReSharper disable CollectionNeverUpdated.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member +#pragma warning disable CS0169 +#pragma warning disable CS8618 +#pragma warning disable CS8625 +#pragma warning disable CS8603 + +namespace Fantasy +{ + [ProtoContract] + public sealed partial class BobberConfigData : ASerialize, IConfigTable, IProto + { + [ProtoMember(1)] + public List List { get; set; } = new List(); +#if FANTASY_NET + [ProtoIgnore] + private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); +#else + [ProtoIgnore] + private readonly Dictionary _configs = new Dictionary(); +#endif + private static BobberConfigData _instance = null; + + public static BobberConfigData Instance + { + get { return _instance ??= ConfigTableHelper.Load(); } + private set => _instance = value; + } + + public BobberConfig Get(uint id, bool check = true) + { + if (_configs.ContainsKey(id)) + { + return _configs[id]; + } + + if (check) + { + throw new Exception($"BobberConfig not find {id} Id"); + } + + return null; + } + public bool TryGet(uint id, out BobberConfig config) + { + config = null; + + if (!_configs.ContainsKey(id)) + { + return false; + } + + config = _configs[id]; + return true; + } + public override void AfterDeserialization() + { + foreach (var config in List) + { +#if FANTASY_NET + _configs.TryAdd(config.Id, config); +#else + _configs.Add(config.Id, config); +#endif + config.AfterDeserialization(); + } + + EndInit(); + } + + public override void Dispose() + { + Instance = null; + } + } + + [ProtoContract] + public sealed partial class BobberConfig : ASerialize, IProto + { + [ProtoMember(1)] + public uint Id { get; set; } // Id + [ProtoMember(2)] + public string Model { get; set; } // 模型 + [ProtoMember(3)] + public uint Type { get; set; } // 类型 + [ProtoMember(4)] + public uint Weight { get; set; } // 重量(克) + [ProtoMember(5)] + public uint Displacement { get; set; } // 位移 + [ProtoMember(6)] + public uint NightLight { get; set; } // 是否夜光 + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/BobberConfig.cs.meta b/Assets/Scripts/Generate/Test/BobberConfig.cs.meta new file mode 100644 index 000000000..f6d7b246f --- /dev/null +++ b/Assets/Scripts/Generate/Test/BobberConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 4c4ce5c38c2619a4f95a1bd26089cca7 \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/FeederConfig.cs b/Assets/Scripts/Generate/Test/FeederConfig.cs new file mode 100644 index 000000000..897498881 --- /dev/null +++ b/Assets/Scripts/Generate/Test/FeederConfig.cs @@ -0,0 +1,106 @@ +using System; +using ProtoBuf; +using Fantasy; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using System.Collections.Concurrent; +#if FANTASY_NET +using Fantasy.ConfigTable; +using Fantasy.Serialize; +#else +using NBC; +using NBC.Serialize; +#endif +// ReSharper disable CollectionNeverUpdated.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member +#pragma warning disable CS0169 +#pragma warning disable CS8618 +#pragma warning disable CS8625 +#pragma warning disable CS8603 + +namespace Fantasy +{ + [ProtoContract] + public sealed partial class FeederConfigData : ASerialize, IConfigTable, IProto + { + [ProtoMember(1)] + public List List { get; set; } = new List(); +#if FANTASY_NET + [ProtoIgnore] + private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); +#else + [ProtoIgnore] + private readonly Dictionary _configs = new Dictionary(); +#endif + private static FeederConfigData _instance = null; + + public static FeederConfigData Instance + { + get { return _instance ??= ConfigTableHelper.Load(); } + private set => _instance = value; + } + + public FeederConfig Get(uint id, bool check = true) + { + if (_configs.ContainsKey(id)) + { + return _configs[id]; + } + + if (check) + { + throw new Exception($"FeederConfig not find {id} Id"); + } + + return null; + } + public bool TryGet(uint id, out FeederConfig config) + { + config = null; + + if (!_configs.ContainsKey(id)) + { + return false; + } + + config = _configs[id]; + return true; + } + public override void AfterDeserialization() + { + foreach (var config in List) + { +#if FANTASY_NET + _configs.TryAdd(config.Id, config); +#else + _configs.Add(config.Id, config); +#endif + config.AfterDeserialization(); + } + + EndInit(); + } + + public override void Dispose() + { + Instance = null; + } + } + + [ProtoContract] + public sealed partial class FeederConfig : ASerialize, IProto + { + [ProtoMember(1)] + public uint Id { get; set; } // Id + [ProtoMember(2)] + public string Model { get; set; } // 模型 + [ProtoMember(3)] + public uint Type { get; set; } // 类型 + [ProtoMember(4)] + public uint Capacity { get; set; } // 能力 + [ProtoMember(5)] + public uint Weight { get; set; } // 重量(克) + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/FeederConfig.cs.meta b/Assets/Scripts/Generate/Test/FeederConfig.cs.meta new file mode 100644 index 000000000..90b228a26 --- /dev/null +++ b/Assets/Scripts/Generate/Test/FeederConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: da3d806c80cc74148a23c2af19ecbe4d \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/FishConfig.cs b/Assets/Scripts/Generate/Test/FishConfig.cs new file mode 100644 index 000000000..a213df6d1 --- /dev/null +++ b/Assets/Scripts/Generate/Test/FishConfig.cs @@ -0,0 +1,110 @@ +using System; +using ProtoBuf; +using Fantasy; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using System.Collections.Concurrent; +#if FANTASY_NET +using Fantasy.ConfigTable; +using Fantasy.Serialize; +#else +using NBC; +using NBC.Serialize; +#endif +// ReSharper disable CollectionNeverUpdated.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member +#pragma warning disable CS0169 +#pragma warning disable CS8618 +#pragma warning disable CS8625 +#pragma warning disable CS8603 + +namespace Fantasy +{ + [ProtoContract] + public sealed partial class FishConfigData : ASerialize, IConfigTable, IProto + { + [ProtoMember(1)] + public List List { get; set; } = new List(); +#if FANTASY_NET + [ProtoIgnore] + private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); +#else + [ProtoIgnore] + private readonly Dictionary _configs = new Dictionary(); +#endif + private static FishConfigData _instance = null; + + public static FishConfigData Instance + { + get { return _instance ??= ConfigTableHelper.Load(); } + private set => _instance = value; + } + + public FishConfig Get(uint id, bool check = true) + { + if (_configs.ContainsKey(id)) + { + return _configs[id]; + } + + if (check) + { + throw new Exception($"FishConfig not find {id} Id"); + } + + return null; + } + public bool TryGet(uint id, out FishConfig config) + { + config = null; + + if (!_configs.ContainsKey(id)) + { + return false; + } + + config = _configs[id]; + return true; + } + public override void AfterDeserialization() + { + foreach (var config in List) + { +#if FANTASY_NET + _configs.TryAdd(config.Id, config); +#else + _configs.Add(config.Id, config); +#endif + config.AfterDeserialization(); + } + + EndInit(); + } + + public override void Dispose() + { + Instance = null; + } + } + + [ProtoContract] + public sealed partial class FishConfig : ASerialize, IProto + { + [ProtoMember(1)] + public uint Id { get; set; } // Id + [ProtoMember(2)] + public string[] Model { get; set; } = Array.Empty(); // 模型 + [ProtoMember(3)] + public uint Type { get; set; } // 类型 + [ProtoMember(4)] + public uint SpeciesName { get; set; } // 鱼类型Id + [ProtoMember(5)] + public uint MinWeight { get; set; } // 最小重量(克) + [ProtoMember(6)] + public uint MaxWeight { get; set; } // 最大重量(克) + [ProtoMember(7)] + public uint Accept { get; set; } // 接受饵 + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/FishConfig.cs.meta b/Assets/Scripts/Generate/Test/FishConfig.cs.meta new file mode 100644 index 000000000..fc444043a --- /dev/null +++ b/Assets/Scripts/Generate/Test/FishConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 38a9a1b4cfa8ab24c8bb141ae7cba986 \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/HookConfig.cs b/Assets/Scripts/Generate/Test/HookConfig.cs new file mode 100644 index 000000000..7e27914be --- /dev/null +++ b/Assets/Scripts/Generate/Test/HookConfig.cs @@ -0,0 +1,108 @@ +using System; +using ProtoBuf; +using Fantasy; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using System.Collections.Concurrent; +#if FANTASY_NET +using Fantasy.ConfigTable; +using Fantasy.Serialize; +#else +using NBC; +using NBC.Serialize; +#endif +// ReSharper disable CollectionNeverUpdated.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member +#pragma warning disable CS0169 +#pragma warning disable CS8618 +#pragma warning disable CS8625 +#pragma warning disable CS8603 + +namespace Fantasy +{ + [ProtoContract] + public sealed partial class HookConfigData : ASerialize, IConfigTable, IProto + { + [ProtoMember(1)] + public List List { get; set; } = new List(); +#if FANTASY_NET + [ProtoIgnore] + private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); +#else + [ProtoIgnore] + private readonly Dictionary _configs = new Dictionary(); +#endif + private static HookConfigData _instance = null; + + public static HookConfigData Instance + { + get { return _instance ??= ConfigTableHelper.Load(); } + private set => _instance = value; + } + + public HookConfig Get(uint id, bool check = true) + { + if (_configs.ContainsKey(id)) + { + return _configs[id]; + } + + if (check) + { + throw new Exception($"HookConfig not find {id} Id"); + } + + return null; + } + public bool TryGet(uint id, out HookConfig config) + { + config = null; + + if (!_configs.ContainsKey(id)) + { + return false; + } + + config = _configs[id]; + return true; + } + public override void AfterDeserialization() + { + foreach (var config in List) + { +#if FANTASY_NET + _configs.TryAdd(config.Id, config); +#else + _configs.Add(config.Id, config); +#endif + config.AfterDeserialization(); + } + + EndInit(); + } + + public override void Dispose() + { + Instance = null; + } + } + + [ProtoContract] + public sealed partial class HookConfig : ASerialize, IProto + { + [ProtoMember(1)] + public uint Id { get; set; } // Id + [ProtoMember(2)] + public string Model { get; set; } // 模型 + [ProtoMember(3)] + public uint Type { get; set; } // 类型 + [ProtoMember(4)] + public uint Zadzior { get; set; } // 长钉 + [ProtoMember(5)] + public uint Length { get; set; } // 长度(毫米) + [ProtoMember(6)] + public uint Weight { get; set; } // 重量(克) + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/HookConfig.cs.meta b/Assets/Scripts/Generate/Test/HookConfig.cs.meta new file mode 100644 index 000000000..69396363d --- /dev/null +++ b/Assets/Scripts/Generate/Test/HookConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 5a6178b7c5ee4ca45b28631c50966e28 \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/LineConfig.cs b/Assets/Scripts/Generate/Test/LineConfig.cs new file mode 100644 index 000000000..600506467 --- /dev/null +++ b/Assets/Scripts/Generate/Test/LineConfig.cs @@ -0,0 +1,108 @@ +using System; +using ProtoBuf; +using Fantasy; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using System.Collections.Concurrent; +#if FANTASY_NET +using Fantasy.ConfigTable; +using Fantasy.Serialize; +#else +using NBC; +using NBC.Serialize; +#endif +// ReSharper disable CollectionNeverUpdated.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member +#pragma warning disable CS0169 +#pragma warning disable CS8618 +#pragma warning disable CS8625 +#pragma warning disable CS8603 + +namespace Fantasy +{ + [ProtoContract] + public sealed partial class LineConfigData : ASerialize, IConfigTable, IProto + { + [ProtoMember(1)] + public List List { get; set; } = new List(); +#if FANTASY_NET + [ProtoIgnore] + private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); +#else + [ProtoIgnore] + private readonly Dictionary _configs = new Dictionary(); +#endif + private static LineConfigData _instance = null; + + public static LineConfigData Instance + { + get { return _instance ??= ConfigTableHelper.Load(); } + private set => _instance = value; + } + + public LineConfig Get(uint id, bool check = true) + { + if (_configs.ContainsKey(id)) + { + return _configs[id]; + } + + if (check) + { + throw new Exception($"LineConfig not find {id} Id"); + } + + return null; + } + public bool TryGet(uint id, out LineConfig config) + { + config = null; + + if (!_configs.ContainsKey(id)) + { + return false; + } + + config = _configs[id]; + return true; + } + public override void AfterDeserialization() + { + foreach (var config in List) + { +#if FANTASY_NET + _configs.TryAdd(config.Id, config); +#else + _configs.Add(config.Id, config); +#endif + config.AfterDeserialization(); + } + + EndInit(); + } + + public override void Dispose() + { + Instance = null; + } + } + + [ProtoContract] + public sealed partial class LineConfig : ASerialize, IProto + { + [ProtoMember(1)] + public uint Id { get; set; } // Id + [ProtoMember(2)] + public string Model { get; set; } // 模型 + [ProtoMember(3)] + public uint Type { get; set; } // 类型 + [ProtoMember(4)] + public uint Length { get; set; } // 长度(毫米) + [ProtoMember(5)] + public uint Strength { get; set; } // 强度 + [ProtoMember(6)] + public uint Size { get; set; } // 尺寸 + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/LineConfig.cs.meta b/Assets/Scripts/Generate/Test/LineConfig.cs.meta new file mode 100644 index 000000000..020df054b --- /dev/null +++ b/Assets/Scripts/Generate/Test/LineConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: dd32cd6701963b84988ab6c9168f0568 \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/LureConfig.cs b/Assets/Scripts/Generate/Test/LureConfig.cs new file mode 100644 index 000000000..72fa04639 --- /dev/null +++ b/Assets/Scripts/Generate/Test/LureConfig.cs @@ -0,0 +1,108 @@ +using System; +using ProtoBuf; +using Fantasy; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using System.Collections.Concurrent; +#if FANTASY_NET +using Fantasy.ConfigTable; +using Fantasy.Serialize; +#else +using NBC; +using NBC.Serialize; +#endif +// ReSharper disable CollectionNeverUpdated.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member +#pragma warning disable CS0169 +#pragma warning disable CS8618 +#pragma warning disable CS8625 +#pragma warning disable CS8603 + +namespace Fantasy +{ + [ProtoContract] + public sealed partial class LureConfigData : ASerialize, IConfigTable, IProto + { + [ProtoMember(1)] + public List List { get; set; } = new List(); +#if FANTASY_NET + [ProtoIgnore] + private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); +#else + [ProtoIgnore] + private readonly Dictionary _configs = new Dictionary(); +#endif + private static LureConfigData _instance = null; + + public static LureConfigData Instance + { + get { return _instance ??= ConfigTableHelper.Load(); } + private set => _instance = value; + } + + public LureConfig Get(uint id, bool check = true) + { + if (_configs.ContainsKey(id)) + { + return _configs[id]; + } + + if (check) + { + throw new Exception($"LureConfig not find {id} Id"); + } + + return null; + } + public bool TryGet(uint id, out LureConfig config) + { + config = null; + + if (!_configs.ContainsKey(id)) + { + return false; + } + + config = _configs[id]; + return true; + } + public override void AfterDeserialization() + { + foreach (var config in List) + { +#if FANTASY_NET + _configs.TryAdd(config.Id, config); +#else + _configs.Add(config.Id, config); +#endif + config.AfterDeserialization(); + } + + EndInit(); + } + + public override void Dispose() + { + Instance = null; + } + } + + [ProtoContract] + public sealed partial class LureConfig : ASerialize, IProto + { + [ProtoMember(1)] + public uint Id { get; set; } // Id + [ProtoMember(2)] + public string Model { get; set; } // 模型 + [ProtoMember(3)] + public uint[] Hook { get; set; } = Array.Empty(); // 勾 + [ProtoMember(4)] + public uint EfficacyBase { get; set; } // 吸引力 + [ProtoMember(5)] + public uint Length { get; set; } // 长度(毫米) + [ProtoMember(6)] + public uint Weight { get; set; } // 重量(克) + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/LureConfig.cs.meta b/Assets/Scripts/Generate/Test/LureConfig.cs.meta new file mode 100644 index 000000000..e4cbc6b53 --- /dev/null +++ b/Assets/Scripts/Generate/Test/LureConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: a3789e74296554d43b1ea6274f978384 \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/ReelConfig.cs b/Assets/Scripts/Generate/Test/ReelConfig.cs new file mode 100644 index 000000000..80b15118b --- /dev/null +++ b/Assets/Scripts/Generate/Test/ReelConfig.cs @@ -0,0 +1,108 @@ +using System; +using ProtoBuf; +using Fantasy; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using System.Collections.Concurrent; +#if FANTASY_NET +using Fantasy.ConfigTable; +using Fantasy.Serialize; +#else +using NBC; +using NBC.Serialize; +#endif +// ReSharper disable CollectionNeverUpdated.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member +#pragma warning disable CS0169 +#pragma warning disable CS8618 +#pragma warning disable CS8625 +#pragma warning disable CS8603 + +namespace Fantasy +{ + [ProtoContract] + public sealed partial class ReelConfigData : ASerialize, IConfigTable, IProto + { + [ProtoMember(1)] + public List List { get; set; } = new List(); +#if FANTASY_NET + [ProtoIgnore] + private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); +#else + [ProtoIgnore] + private readonly Dictionary _configs = new Dictionary(); +#endif + private static ReelConfigData _instance = null; + + public static ReelConfigData Instance + { + get { return _instance ??= ConfigTableHelper.Load(); } + private set => _instance = value; + } + + public ReelConfig Get(uint id, bool check = true) + { + if (_configs.ContainsKey(id)) + { + return _configs[id]; + } + + if (check) + { + throw new Exception($"ReelConfig not find {id} Id"); + } + + return null; + } + public bool TryGet(uint id, out ReelConfig config) + { + config = null; + + if (!_configs.ContainsKey(id)) + { + return false; + } + + config = _configs[id]; + return true; + } + public override void AfterDeserialization() + { + foreach (var config in List) + { +#if FANTASY_NET + _configs.TryAdd(config.Id, config); +#else + _configs.Add(config.Id, config); +#endif + config.AfterDeserialization(); + } + + EndInit(); + } + + public override void Dispose() + { + Instance = null; + } + } + + [ProtoContract] + public sealed partial class ReelConfig : ASerialize, IProto + { + [ProtoMember(1)] + public uint Id { get; set; } // Id + [ProtoMember(2)] + public string Model { get; set; } // 模型 + [ProtoMember(3)] + public uint Type { get; set; } // 类型 + [ProtoMember(4)] + public float[] GearRatio { get; set; } = Array.Empty(); // 组件比 + [ProtoMember(5)] + public uint Size { get; set; } // 尺寸 + [ProtoMember(6)] + public uint Strength { get; set; } // 强度 + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/ReelConfig.cs.meta b/Assets/Scripts/Generate/Test/ReelConfig.cs.meta new file mode 100644 index 000000000..6748cdd63 --- /dev/null +++ b/Assets/Scripts/Generate/Test/ReelConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 937f0fc7328e76f4a8f3137d0cf2bf3c \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/RingConfig.cs b/Assets/Scripts/Generate/Test/RingConfig.cs new file mode 100644 index 000000000..373d6c844 --- /dev/null +++ b/Assets/Scripts/Generate/Test/RingConfig.cs @@ -0,0 +1,100 @@ +using System; +using ProtoBuf; +using Fantasy; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using System.Collections.Concurrent; +#if FANTASY_NET +using Fantasy.ConfigTable; +using Fantasy.Serialize; +#else +using NBC; +using NBC.Serialize; +#endif +// ReSharper disable CollectionNeverUpdated.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member +#pragma warning disable CS0169 +#pragma warning disable CS8618 +#pragma warning disable CS8625 +#pragma warning disable CS8603 + +namespace Fantasy +{ + [ProtoContract] + public sealed partial class RingConfigData : ASerialize, IConfigTable, IProto + { + [ProtoMember(1)] + public List List { get; set; } = new List(); +#if FANTASY_NET + [ProtoIgnore] + private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); +#else + [ProtoIgnore] + private readonly Dictionary _configs = new Dictionary(); +#endif + private static RingConfigData _instance = null; + + public static RingConfigData Instance + { + get { return _instance ??= ConfigTableHelper.Load(); } + private set => _instance = value; + } + + public RingConfig Get(uint id, bool check = true) + { + if (_configs.ContainsKey(id)) + { + return _configs[id]; + } + + if (check) + { + throw new Exception($"RingConfig not find {id} Id"); + } + + return null; + } + public bool TryGet(uint id, out RingConfig config) + { + config = null; + + if (!_configs.ContainsKey(id)) + { + return false; + } + + config = _configs[id]; + return true; + } + public override void AfterDeserialization() + { + foreach (var config in List) + { +#if FANTASY_NET + _configs.TryAdd(config.Id, config); +#else + _configs.Add(config.Id, config); +#endif + config.AfterDeserialization(); + } + + EndInit(); + } + + public override void Dispose() + { + Instance = null; + } + } + + [ProtoContract] + public sealed partial class RingConfig : ASerialize, IProto + { + [ProtoMember(1)] + public uint Id { get; set; } // Id + [ProtoMember(2)] + public string Model { get; set; } // 模型 + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/RingConfig.cs.meta b/Assets/Scripts/Generate/Test/RingConfig.cs.meta new file mode 100644 index 000000000..b1ae506c2 --- /dev/null +++ b/Assets/Scripts/Generate/Test/RingConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 011d34ec27d1f7740b439af74c883be5 \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/RodConfig.cs b/Assets/Scripts/Generate/Test/RodConfig.cs new file mode 100644 index 000000000..2d49a275b --- /dev/null +++ b/Assets/Scripts/Generate/Test/RodConfig.cs @@ -0,0 +1,114 @@ +using System; +using ProtoBuf; +using Fantasy; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using System.Collections.Concurrent; +#if FANTASY_NET +using Fantasy.ConfigTable; +using Fantasy.Serialize; +#else +using NBC; +using NBC.Serialize; +#endif +// ReSharper disable CollectionNeverUpdated.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member +#pragma warning disable CS0169 +#pragma warning disable CS8618 +#pragma warning disable CS8625 +#pragma warning disable CS8603 + +namespace Fantasy +{ + [ProtoContract] + public sealed partial class RodConfigData : ASerialize, IConfigTable, IProto + { + [ProtoMember(1)] + public List List { get; set; } = new List(); +#if FANTASY_NET + [ProtoIgnore] + private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); +#else + [ProtoIgnore] + private readonly Dictionary _configs = new Dictionary(); +#endif + private static RodConfigData _instance = null; + + public static RodConfigData Instance + { + get { return _instance ??= ConfigTableHelper.Load(); } + private set => _instance = value; + } + + public RodConfig Get(uint id, bool check = true) + { + if (_configs.ContainsKey(id)) + { + return _configs[id]; + } + + if (check) + { + throw new Exception($"RodConfig not find {id} Id"); + } + + return null; + } + public bool TryGet(uint id, out RodConfig config) + { + config = null; + + if (!_configs.ContainsKey(id)) + { + return false; + } + + config = _configs[id]; + return true; + } + public override void AfterDeserialization() + { + foreach (var config in List) + { +#if FANTASY_NET + _configs.TryAdd(config.Id, config); +#else + _configs.Add(config.Id, config); +#endif + config.AfterDeserialization(); + } + + EndInit(); + } + + public override void Dispose() + { + Instance = null; + } + } + + [ProtoContract] + public sealed partial class RodConfig : ASerialize, IProto + { + [ProtoMember(1)] + public uint Id { get; set; } // Id + [ProtoMember(2)] + public string Model { get; set; } // 模型 + [ProtoMember(3)] + public uint Type { get; set; } // 类型 + [ProtoMember(4)] + public uint Ring { get; set; } // 导线圈 + [ProtoMember(5)] + public uint Length { get; set; } // 长度(毫米) + [ProtoMember(6)] + public uint Weight { get; set; } // 重量(克) + [ProtoMember(7)] + public uint Strength { get; set; } // 强度 + [ProtoMember(8)] + public uint MaxRange { get; set; } // 最大范围 + [ProtoMember(9)] + public uint ConstructionType { get; set; } // 结构类型 + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/RodConfig.cs.meta b/Assets/Scripts/Generate/Test/RodConfig.cs.meta new file mode 100644 index 000000000..2c6f5ca12 --- /dev/null +++ b/Assets/Scripts/Generate/Test/RodConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 50e00e7722e5f804b9151354058842cc \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/Unit2Config.cs b/Assets/Scripts/Generate/Test/Unit2Config.cs new file mode 100644 index 000000000..8f2671705 --- /dev/null +++ b/Assets/Scripts/Generate/Test/Unit2Config.cs @@ -0,0 +1,102 @@ +using System; +using ProtoBuf; +using Fantasy; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using System.Collections.Concurrent; +#if FANTASY_NET +using Fantasy.ConfigTable; +using Fantasy.Serialize; +#else +using NBC; +using NBC.Serialize; +#endif +// ReSharper disable CollectionNeverUpdated.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member +#pragma warning disable CS0169 +#pragma warning disable CS8618 +#pragma warning disable CS8625 +#pragma warning disable CS8603 + +namespace Fantasy +{ + [ProtoContract] + public sealed partial class Unit2ConfigData : ASerialize, IConfigTable, IProto + { + [ProtoMember(1)] + public List List { get; set; } = new List(); +#if FANTASY_NET + [ProtoIgnore] + private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); +#else + [ProtoIgnore] + private readonly Dictionary _configs = new Dictionary(); +#endif + private static Unit2ConfigData _instance = null; + + public static Unit2ConfigData Instance + { + get { return _instance ??= ConfigTableHelper.Load(); } + private set => _instance = value; + } + + public Unit2Config Get(uint id, bool check = true) + { + if (_configs.ContainsKey(id)) + { + return _configs[id]; + } + + if (check) + { + throw new Exception($"Unit2Config not find {id} Id"); + } + + return null; + } + public bool TryGet(uint id, out Unit2Config config) + { + config = null; + + if (!_configs.ContainsKey(id)) + { + return false; + } + + config = _configs[id]; + return true; + } + public override void AfterDeserialization() + { + foreach (var config in List) + { +#if FANTASY_NET + _configs.TryAdd(config.Id, config); +#else + _configs.Add(config.Id, config); +#endif + config.AfterDeserialization(); + } + + EndInit(); + } + + public override void Dispose() + { + Instance = null; + } + } + + [ProtoContract] + public sealed partial class Unit2Config : ASerialize, IProto + { + [ProtoMember(1)] + public uint Id { get; set; } // Id + [ProtoMember(2)] + public string Name { get; set; } // 名称 + [ProtoMember(3)] + public string Model { get; set; } // 数据库类型 + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/Unit2Config.cs.meta b/Assets/Scripts/Generate/Test/Unit2Config.cs.meta new file mode 100644 index 000000000..e2e3be243 --- /dev/null +++ b/Assets/Scripts/Generate/Test/Unit2Config.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 0750f0970e8c3aa49bd98757da8cbe39 \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/UnitConfig.cs b/Assets/Scripts/Generate/Test/UnitConfig.cs new file mode 100644 index 000000000..b051d8fe9 --- /dev/null +++ b/Assets/Scripts/Generate/Test/UnitConfig.cs @@ -0,0 +1,102 @@ +using System; +using ProtoBuf; +using Fantasy; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using System.Collections.Concurrent; +#if FANTASY_NET +using Fantasy.ConfigTable; +using Fantasy.Serialize; +#else +using NBC; +using NBC.Serialize; +#endif +// ReSharper disable CollectionNeverUpdated.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member +#pragma warning disable CS0169 +#pragma warning disable CS8618 +#pragma warning disable CS8625 +#pragma warning disable CS8603 + +namespace Fantasy +{ + [ProtoContract] + public sealed partial class UnitConfigData : ASerialize, IConfigTable, IProto + { + [ProtoMember(1)] + public List List { get; set; } = new List(); +#if FANTASY_NET + [ProtoIgnore] + private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); +#else + [ProtoIgnore] + private readonly Dictionary _configs = new Dictionary(); +#endif + private static UnitConfigData _instance = null; + + public static UnitConfigData Instance + { + get { return _instance ??= ConfigTableHelper.Load(); } + private set => _instance = value; + } + + public UnitConfig Get(uint id, bool check = true) + { + if (_configs.ContainsKey(id)) + { + return _configs[id]; + } + + if (check) + { + throw new Exception($"UnitConfig not find {id} Id"); + } + + return null; + } + public bool TryGet(uint id, out UnitConfig config) + { + config = null; + + if (!_configs.ContainsKey(id)) + { + return false; + } + + config = _configs[id]; + return true; + } + public override void AfterDeserialization() + { + foreach (var config in List) + { +#if FANTASY_NET + _configs.TryAdd(config.Id, config); +#else + _configs.Add(config.Id, config); +#endif + config.AfterDeserialization(); + } + + EndInit(); + } + + public override void Dispose() + { + Instance = null; + } + } + + [ProtoContract] + public sealed partial class UnitConfig : ASerialize, IProto + { + [ProtoMember(1)] + public uint Id { get; set; } // Id + [ProtoMember(2)] + public string Name { get; set; } // 名称 + [ProtoMember(3)] + public string Model { get; set; } // 数据库类型 + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/UnitConfig.cs.meta b/Assets/Scripts/Generate/Test/UnitConfig.cs.meta new file mode 100644 index 000000000..7bf08ead5 --- /dev/null +++ b/Assets/Scripts/Generate/Test/UnitConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: c4fcd00be96ef734682179e668d43ff5 \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/WeightConfig.cs b/Assets/Scripts/Generate/Test/WeightConfig.cs new file mode 100644 index 000000000..ea8a29cdc --- /dev/null +++ b/Assets/Scripts/Generate/Test/WeightConfig.cs @@ -0,0 +1,104 @@ +using System; +using ProtoBuf; +using Fantasy; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using System.Collections.Concurrent; +#if FANTASY_NET +using Fantasy.ConfigTable; +using Fantasy.Serialize; +#else +using NBC; +using NBC.Serialize; +#endif +// ReSharper disable CollectionNeverUpdated.Global +// ReSharper disable UnusedAutoPropertyAccessor.Global +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member +#pragma warning disable CS0169 +#pragma warning disable CS8618 +#pragma warning disable CS8625 +#pragma warning disable CS8603 + +namespace Fantasy +{ + [ProtoContract] + public sealed partial class WeightConfigData : ASerialize, IConfigTable, IProto + { + [ProtoMember(1)] + public List List { get; set; } = new List(); +#if FANTASY_NET + [ProtoIgnore] + private readonly ConcurrentDictionary _configs = new ConcurrentDictionary(); +#else + [ProtoIgnore] + private readonly Dictionary _configs = new Dictionary(); +#endif + private static WeightConfigData _instance = null; + + public static WeightConfigData Instance + { + get { return _instance ??= ConfigTableHelper.Load(); } + private set => _instance = value; + } + + public WeightConfig Get(uint id, bool check = true) + { + if (_configs.ContainsKey(id)) + { + return _configs[id]; + } + + if (check) + { + throw new Exception($"WeightConfig not find {id} Id"); + } + + return null; + } + public bool TryGet(uint id, out WeightConfig config) + { + config = null; + + if (!_configs.ContainsKey(id)) + { + return false; + } + + config = _configs[id]; + return true; + } + public override void AfterDeserialization() + { + foreach (var config in List) + { +#if FANTASY_NET + _configs.TryAdd(config.Id, config); +#else + _configs.Add(config.Id, config); +#endif + config.AfterDeserialization(); + } + + EndInit(); + } + + public override void Dispose() + { + Instance = null; + } + } + + [ProtoContract] + public sealed partial class WeightConfig : ASerialize, IProto + { + [ProtoMember(1)] + public uint Id { get; set; } // Id + [ProtoMember(2)] + public string Model { get; set; } // 模型 + [ProtoMember(3)] + public uint Type { get; set; } // 类型 + [ProtoMember(4)] + public uint Weight { get; set; } // 重量(克) + } +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/WeightConfig.cs.meta b/Assets/Scripts/Generate/Test/WeightConfig.cs.meta new file mode 100644 index 000000000..7702578f4 --- /dev/null +++ b/Assets/Scripts/Generate/Test/WeightConfig.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 190543eb94e16a24ba18b202c8f66cd3 \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/configs.json b/Assets/Scripts/Generate/Test/configs.json new file mode 100644 index 000000000..0865fd5c2 --- /dev/null +++ b/Assets/Scripts/Generate/Test/configs.json @@ -0,0 +1,323 @@ +{ + "Unit2Config": [ + { + "Id": 1, + "Name": "Unit01", + "Model": "Unit01" + } + ], + "WeightConfig": [ + { + "Id": 800001, + "Model": "Weights/Weight2_5g", + "Type": 0, + "Weight": 3 + } + ], + "UnitConfig": [ + { + "Id": 1, + "Name": "Unit01", + "Model": "Unit01" + } + ], + "RingConfig": [ + { + "Id": 1100001, + "Model": "rod_rings/rumoi/rumoi_oxiline_spin" + }, + { + "Id": 1100002, + "Model": "rod_rings/smt/smt_pure_ceramic_bolo" + } + ], + "LureConfig": [ + { + "Id": 600001, + "Model": "lures/express_fishing/crankbaits_1/775/crankbaits_775", + "Hook": [ + 700102 + ], + "EfficacyBase": 50, + "Length": 0, + "Weight": 250 + }, + { + "Id": 600002, + "Model": "lures/express_fishing/poppers_1/poppers_590/poppers_590", + "Hook": [ + 700102 + ], + "EfficacyBase": 50, + "Length": 0, + "Weight": 120 + }, + { + "Id": 600003, + "Model": "lures/express_fishing/softplastic/ef_supergrab_6/softplastic_g_1622", + "Hook": [ + 0 + ], + "EfficacyBase": 50, + "Length": 0, + "Weight": 120 + }, + { + "Id": 600004, + "Model": "lures/express_fishing/softplastic/ef_superminnow_6/softplastic_m_1634", + "Hook": [ + 0 + ], + "EfficacyBase": 50, + "Length": 0, + "Weight": 120 + } + ], + "ReelConfig": [ + { + "Id": 200001, + "Model": "reels/syberia/spin_5002/spin_5002", + "Type": 0, + "GearRatio": [ + "7" + ], + "Size": 250, + "Strength": 40 + }, + { + "Id": 200002, + "Model": "reels/syberia/spin_5036/spin_5036", + "Type": 0, + "GearRatio": [ + "5" + ], + "Size": 120, + "Strength": 40 + } + ], + "LineConfig": [ + { + "Id": 400001, + "Model": "Lines/UFE Mono/UFE monoClear", + "Type": 0, + "Length": 7, + "Strength": 40, + "Size": 1 + }, + { + "Id": 400002, + "Model": "rods/syberia/bolo_10021/bolo_10021_LB400", + "Type": 0, + "Length": 5, + "Strength": 40, + "Size": 1 + } + ], + "HookConfig": [ + { + "Id": 700001, + "Model": "hooks/alliance/c_hook_20789_20794/c_hook_20789", + "Type": 1, + "Zadzior": 1, + "Length": 0, + "Weight": 1 + }, + { + "Id": 700002, + "Model": "hooks/berserk_hooks/triple_20569_20577/triple_20569", + "Type": 1, + "Zadzior": 1, + "Length": 0, + "Weight": 1 + } + ], + "RodConfig": [ + { + "Id": 100001, + "Model": "rods/syberia/tele_10037/tele_10037_t13", + "Type": 1, + "Ring": 0, + "Length": 7, + "Weight": 250, + "Strength": 40, + "MaxRange": 67, + "ConstructionType": 0 + }, + { + "Id": 100002, + "Model": "rods/syberia/bolo_10021/bolo_10021_LB400", + "Type": 0, + "Ring": 1100002, + "Length": 5, + "Weight": 120, + "Strength": 40, + "MaxRange": 30, + "ConstructionType": 0 + }, + { + "Id": 100003, + "Model": "rods/syberia/spin_10034/spin_10034_S60H", + "Type": 0, + "Ring": 1100001, + "Length": 5, + "Weight": 120, + "Strength": 40, + "MaxRange": 30, + "ConstructionType": 0 + } + ], + "FishConfig": [ + { + "Id": 2200001, + "Model": [ + "Burbot_B" + ], + "Type": 0, + "SpeciesName": 10, + "MinWeight": 1, + "MaxWeight": 34, + "Accept": 2100001 + }, + { + "Id": 2200002, + "Model": [ + "CarpCommon_B" + ], + "Type": 0, + "SpeciesName": 11, + "MinWeight": 1, + "MaxWeight": 34, + "Accept": 2100001 + }, + { + "Id": 2200003, + "Model": [ + "CarpGrass_B" + ], + "Type": 0, + "SpeciesName": 14, + "MinWeight": 1, + "MaxWeight": 34, + "Accept": 2100001 + }, + { + "Id": 2200004, + "Model": [ + "CarpCrucian_B" + ], + "Type": 0, + "SpeciesName": 16, + "MinWeight": 1, + "MaxWeight": 34, + "Accept": 2100001 + } + ], + "BobberConfig": [ + { + "Id": 300001, + "Model": "bobbers/expressfishing/bob_25003/bob_25003", + "Type": 2, + "Weight": 1, + "Displacement": 40, + "NightLight": 0 + }, + { + "Id": 300002, + "Model": "bobbers/expressfishing/bob_25162_25163/bob_25162", + "Type": 0, + "Weight": 1, + "Displacement": 40, + "NightLight": 0 + }, + { + "Id": 300003, + "Model": "bobbers/expressfishing/bob_25166_25167/bob_25166", + "Type": 0, + "Weight": 1, + "Displacement": 40, + "NightLight": 0 + }, + { + "Id": 300004, + "Model": "bobbers/expressfishing/bob_25001/bob_25001", + "Type": 0, + "Weight": 1, + "Displacement": 40, + "NightLight": 0 + } + ], + "FeederConfig": [ + { + "Id": 900001, + "Model": "Feeders/Feeder 1/FeedTrash 1", + "Type": 0, + "Capacity": 100, + "Weight": 5 + } + ], + "BaitConfig": [ + { + "Id": 500001, + "Model": "baits/worm_01/worm_01", + "EfficacyBase": 15, + "Length": 0, + "Weight": 250, + "Arr": [ + 250, + 1, + 2, + 3 + ], + "ArrStr": [ + "d", + "a", + "bb", + "e|12" + ] + }, + { + "Id": 500002, + "Model": "baits/fly/fly", + "EfficacyBase": 15, + "Length": 0, + "Weight": 120, + "Arr": [ + 120, + 4, + 3 + ], + "ArrStr": [ + "120", + "4", + "3" + ] + }, + { + "Id": 500003, + "Model": "baits/black_leech/black_leech", + "EfficacyBase": 15, + "Length": 0, + "Weight": 120, + "Arr": [ + 120 + ], + "ArrStr": [ + "kkk" + ] + }, + { + "Id": 500004, + "Model": "baits/bread/bread", + "EfficacyBase": 15, + "Length": 0, + "Weight": 120, + "Arr": [ + 120 + ], + "ArrStr": [ + "11|33", + "44|2" + ] + } + ] +} \ No newline at end of file diff --git a/Assets/Scripts/Generate/Test/configs.json.meta b/Assets/Scripts/Generate/Test/configs.json.meta new file mode 100644 index 000000000..6c2030bad --- /dev/null +++ b/Assets/Scripts/Generate/Test/configs.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: c8b5cb8d32d7bc9438c04720cd8e7bf4 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Init.cs b/Assets/Scripts/Init.cs index 3189a0937..80bec7549 100644 --- a/Assets/Scripts/Init.cs +++ b/Assets/Scripts/Init.cs @@ -111,7 +111,7 @@ namespace NBF private void LoadData() { - ConfigAssets.Init(); + // ConfigAssets.Init(); } private async FTask OpenUI() diff --git a/Assets/Scripts/NBC/Runtime/Core/Config.meta b/Assets/Scripts/NBC/Runtime/Core/Config.meta new file mode 100644 index 000000000..42243075f --- /dev/null +++ b/Assets/Scripts/NBC/Runtime/Core/Config.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5ccc2499679c40909ac59a0a325c78c4 +timeCreated: 1759160041 \ No newline at end of file diff --git a/Assets/Scripts/NBC/Runtime/Core/Config/ConfigTableHelper.cs b/Assets/Scripts/NBC/Runtime/Core/Config/ConfigTableHelper.cs new file mode 100644 index 000000000..79b499aa3 --- /dev/null +++ b/Assets/Scripts/NBC/Runtime/Core/Config/ConfigTableHelper.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.IO; +using NBC.Serialize; + +namespace NBC +{ + /// + /// 配置表帮助类 + /// + public static class ConfigTableHelper + { + private static string _configTableBinaryDirectory; + private static readonly object Lock = new object(); + // 配置表数据缓存字典 + private static readonly Dictionary ConfigDic = new (); + /// + /// 初始化ConfigTableHelper + /// + /// + public static void Initialize(string configTableBinaryDirectory) + { + _configTableBinaryDirectory = configTableBinaryDirectory; + } + /// + /// 加载配置表数据 + /// + /// 配置表类型 + /// 配置表数据 + public static T Load() where T : ASerialize + { + lock (Lock) + { + try + { + var dataConfig = typeof(T).Name; + + if (ConfigDic.TryGetValue(dataConfig, out var aProto)) + { + return (T)aProto; + } + + var configFile = GetConfigPath(dataConfig); + var bytes = File.ReadAllBytes(configFile); + // Log.Debug($"dataConfig:{dataConfig} {bytes.Length}"); + var data = SerializerManager.GetSerializer(FantasySerializerType.ProtoBuf).Deserialize(bytes); + ConfigDic[dataConfig] = data; + return data; + } + catch (Exception ex) + { + throw new Exception($"ConfigTableManage:{typeof(T).Name} 数据表加载之后反序列化时出错:{ex}"); + } + } + } + + /// + /// 获取配置表文件路径 + /// + /// 配置表名称 + /// 配置表文件路径 + private static string GetConfigPath(string name) + { + var configFile = Path.Combine(_configTableBinaryDirectory, $"{name}.bytes"); + + if (File.Exists(configFile)) + { + return configFile; + } + + throw new FileNotFoundException($"{name}.byte not found: {configFile}"); + } + + /// + /// 重新加载配置表数据 + /// + public static void ReLoadConfigTable() + { + lock (Lock) + { + foreach (var (_, aProto) in ConfigDic) + { + ((IDisposable) aProto).Dispose(); + } + + ConfigDic.Clear(); + } + } + } +} diff --git a/Assets/Scripts/NBC/Runtime/Core/Config/ConfigTableHelper.cs.meta b/Assets/Scripts/NBC/Runtime/Core/Config/ConfigTableHelper.cs.meta new file mode 100644 index 000000000..5e76c5c1d --- /dev/null +++ b/Assets/Scripts/NBC/Runtime/Core/Config/ConfigTableHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: de53a788ec4e446eb6c07c50c65afcc2 +timeCreated: 1759160093 \ No newline at end of file diff --git a/Assets/Scripts/NBC/Runtime/Core/Config/IConfigTable.cs b/Assets/Scripts/NBC/Runtime/Core/Config/IConfigTable.cs new file mode 100644 index 000000000..a2160d2fe --- /dev/null +++ b/Assets/Scripts/NBC/Runtime/Core/Config/IConfigTable.cs @@ -0,0 +1,7 @@ +namespace NBC +{ + /// + /// 表示是一个配置文件 + /// + public interface IConfigTable { } +} \ No newline at end of file diff --git a/Assets/Scripts/NBC/Runtime/Core/Config/IConfigTable.cs.meta b/Assets/Scripts/NBC/Runtime/Core/Config/IConfigTable.cs.meta new file mode 100644 index 000000000..78551c11b --- /dev/null +++ b/Assets/Scripts/NBC/Runtime/Core/Config/IConfigTable.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: df4eb038440a4a498e27ccaf23a1cd9b +timeCreated: 1759160060 \ No newline at end of file