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

72 lines
1.9 KiB
C#
Raw Normal View History

2023-08-22 19:08:45 +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;
using SimpleJSON;
2023-11-01 15:03:24 +08:00
namespace cfg
2023-08-22 19:08:45 +08:00
{
2023-11-01 15:03:24 +08:00
public sealed partial class ConditionConfig
2023-08-22 19:08:45 +08:00
{
2023-11-01 15:03:24 +08:00
private readonly Dictionary<int, DataCondition> _dataMap;
private readonly List<DataCondition> _dataList;
2023-08-22 19:08:45 +08:00
2023-11-01 15:03:24 +08:00
public ConditionConfig(JSONNode _json)
2023-08-22 19:08:45 +08:00
{
2023-11-01 15:03:24 +08:00
_dataMap = new Dictionary<int, DataCondition>();
_dataList = new List<DataCondition>();
2023-08-22 19:08:45 +08:00
foreach(JSONNode _row in _json.Children)
{
2023-11-01 15:03:24 +08:00
var _v = DataCondition.DeserializeDataCondition(_row);
2023-08-22 19:08:45 +08:00
_dataList.Add(_v);
_dataMap.Add(_v.Id, _v);
}
PostInit();
}
2023-11-01 15:03:24 +08:00
public Dictionary<int, DataCondition> DataMap => _dataMap;
public List<DataCondition> DataList => _dataList;
2023-08-22 19:08:45 +08:00
2023-11-01 15:03:24 +08:00
public DataCondition GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;
public DataCondition Get(int key) {
2023-10-19 15:00:19 +08:00
if (_dataMap.TryGetValue(key, out var v)) {
return v;
} else {
2023-11-01 15:03:24 +08:00
UnityEngine.Debug.LogError($"table ConditionConfig key not found: {key}");
2023-10-19 15:00:19 +08:00
return null;
}
}
2023-11-01 15:03:24 +08:00
public DataCondition this[int key] => _dataMap[key];
2023-08-22 19:08:45 +08:00
public void Resolve(Dictionary<string, object> _tables)
{
foreach(var v in _dataList)
{
v.Resolve(_tables);
}
PostResolve();
}
public void TranslateText(System.Func<string, string, string> translator)
{
foreach(var v in _dataList)
{
v.TranslateText(translator);
}
}
partial void PostInit();
partial void PostResolve();
}
}