item.TbItem.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //------------------------------------------------------------------------------
  2. // <auto-generated>
  3. // This code was generated by a tool.
  4. // Changes to this file may cause incorrect behavior and will be lost if
  5. // the code is regenerated.
  6. // </auto-generated>
  7. //------------------------------------------------------------------------------
  8. using Luban;
  9. using SimpleJSON;
  10. namespace cfg.item
  11. {
  12. public partial class TbItem
  13. {
  14. private readonly System.Collections.Generic.Dictionary<int, Item> _dataMap;
  15. private readonly System.Collections.Generic.List<Item> _dataList;
  16. public TbItem(JSONNode _buf)
  17. {
  18. _dataMap = new System.Collections.Generic.Dictionary<int, Item>();
  19. _dataList = new System.Collections.Generic.List<Item>();
  20. foreach(JSONNode _ele in _buf.Children)
  21. {
  22. Item _v;
  23. { if(!_ele.IsObject) { throw new SerializationException(); } _v = Item.DeserializeItem(_ele); }
  24. _dataList.Add(_v);
  25. _dataMap.Add(_v.Id, _v);
  26. }
  27. }
  28. public System.Collections.Generic.Dictionary<int, Item> DataMap => _dataMap;
  29. public System.Collections.Generic.List<Item> DataList => _dataList;
  30. public Item GetOrDefault(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;
  31. public Item Get(int key) => _dataMap[key];
  32. public Item this[int key] => _dataMap[key];
  33. public void ResolveRef(Tables tables)
  34. {
  35. foreach(var _v in _dataList)
  36. {
  37. _v.ResolveRef(tables);
  38. }
  39. }
  40. }
  41. }