NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/DataTable/RedPoint/RedPointConfig.cs

72 lines
2.0 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-10-19 15:00:19 +08:00
namespace cfg.RedPoint
2023-08-22 19:08:45 +08:00
{
2023-10-19 15:00:19 +08:00
public sealed partial class RedPointConfig
2023-08-22 19:08:45 +08:00
{
2023-10-19 15:00:19 +08:00
private readonly Dictionary<int, RedPoint.DataRedPoint> _dataMap;
private readonly List<RedPoint.DataRedPoint> _dataList;
2023-08-22 19:08:45 +08:00
2023-10-19 15:00:19 +08:00
public RedPointConfig(JSONNode _json)
2023-08-22 19:08:45 +08:00
{
2023-10-19 15:00:19 +08:00
_dataMap = new Dictionary<int, RedPoint.DataRedPoint>();
_dataList = new List<RedPoint.DataRedPoint>();
2023-08-22 19:08:45 +08:00
foreach(JSONNode _row in _json.Children)
{
2023-10-19 15:00:19 +08:00
var _v = RedPoint.DataRedPoint.DeserializeDataRedPoint(_row);
2023-08-22 19:08:45 +08:00
_dataList.Add(_v);
2023-10-19 15:00:19 +08:00
_dataMap.Add(_v.Id, _v);
2023-08-22 19:08:45 +08:00
}
PostInit();
}
2023-10-19 15:00:19 +08:00
public Dictionary<int, RedPoint.DataRedPoint> DataMap => _dataMap;
public List<RedPoint.DataRedPoint> DataList => _dataList;
2023-08-22 19:08:45 +08:00
2023-10-19 15:00:19 +08:00
public RedPoint.DataRedPoint GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;
public RedPoint.DataRedPoint Get(int key) {
if (_dataMap.TryGetValue(key, out var v)) {
return v;
} else {
UnityEngine.Debug.LogError($"table RedPointConfig key not found: {key}");
return null;
}
}
public RedPoint.DataRedPoint 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();
}
}