NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/GenCode/Luban/DataTable/SystemCfg.cs

72 lines
2.0 KiB
C#
Raw Normal View History

2023-12-21 20:00:58 +08:00
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using Bright.Serialization;
using System.Collections.Generic;
2025-03-31 14:04:38 +08:00
using SimpleJSON;
2023-12-21 20:00:58 +08:00
2023-12-21 20:00:58 +08:00
namespace cfg
{
public sealed partial class SystemCfg
2023-12-21 20:00:58 +08:00
{
private readonly Dictionary<ESystemType, DataSystemCfg> _dataMap;
private readonly List<DataSystemCfg> _dataList;
2023-12-21 20:00:58 +08:00
public SystemCfg(JSONNode _json)
2023-12-21 20:00:58 +08:00
{
_dataMap = new Dictionary<ESystemType, DataSystemCfg>();
_dataList = new List<DataSystemCfg>();
2023-12-21 20:00:58 +08:00
foreach(JSONNode _row in _json.Children)
2023-12-21 20:00:58 +08:00
{
var _v = DataSystemCfg.DeserializeDataSystemCfg(_row);
2023-12-21 20:00:58 +08:00
_dataList.Add(_v);
_dataMap.Add(_v.Id, _v);
}
PostInit();
2023-12-21 20:00:58 +08:00
}
public Dictionary<ESystemType, DataSystemCfg> DataMap => _dataMap;
public List<DataSystemCfg> DataList => _dataList;
2023-12-21 20:00:58 +08:00
public DataSystemCfg GetOrDefault(ESystemType key) => _dataMap.TryGetValue(key, out var v) ? v : null;
public DataSystemCfg Get(ESystemType key) {
if (_dataMap.TryGetValue(key, out var v)) {
return v;
} else {
UnityEngine.Debug.LogError($"table SystemCfg key not found: {key}");
return null;
}
}
2023-12-21 20:00:58 +08:00
public DataSystemCfg this[ESystemType key] => _dataMap[key];
public void Resolve(Dictionary<string, object> _tables)
2023-12-21 20:00:58 +08:00
{
foreach(var v in _dataList)
2023-12-21 20:00:58 +08:00
{
v.Resolve(_tables);
2023-12-21 20:00:58 +08:00
}
PostResolve();
2023-12-21 20:00:58 +08:00
}
public void TranslateText(System.Func<string, string, string> translator)
{
foreach(var v in _dataList)
{
v.TranslateText(translator);
}
}
partial void PostInit();
partial void PostResolve();
2023-12-21 20:00:58 +08:00
}
}