ItemCfgArray.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using System.Threading.Tasks;
  4. using cfg;
  5. using cfg.GfgCfg;
  6. using ET;
  7. namespace GFGGame
  8. {
  9. public class ItemCfgArray : SingletonBaseET<ItemCfgArray>
  10. {
  11. public bool CheckCfgExist(int itemId)
  12. {
  13. var itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(itemId);
  14. return itemCfg != null;
  15. }
  16. // 静态字典,全局共享
  17. public Dictionary<int, List<int>> SyntheticSuitDic = new Dictionary<int, List<int>>();
  18. // 初始化方法(应该在加载配置时调用)
  19. public void InitSyntheticSuitDic()
  20. {
  21. Instance.SyntheticSuitDic.Clear();
  22. foreach (var itemCfg in CommonDataManager.Tables.TblItemCfg.DataList)
  23. {
  24. foreach (var itemParam in itemCfg.SyntheticMateriars)
  25. {
  26. SyntheticSuitDic.TryGetValue(itemParam.ItemId, out var list);
  27. list ??= new List<int>();
  28. if (list.Any(a => a == itemCfg.Id))
  29. {
  30. continue;
  31. }
  32. list.Add(itemCfg.Id);
  33. SyntheticSuitDic[itemParam.ItemId] = list;
  34. }
  35. }
  36. }
  37. // /// <summary>
  38. // /// 临时用 服装异步加载
  39. // /// </summary>
  40. // /// <param name="itemType"></param>
  41. // /// <param name="subType"></param>
  42. // /// <returns></returns>
  43. // public async Task GetCfgsByitemTypeAndsubTypeAsync(int itemType, int subType)
  44. // {
  45. //
  46. //
  47. // var colNames = new string[] { nameof(itemType), nameof(subType) };
  48. // var colValues = new string[] { itemType.ToString(), subType.ToString() };
  49. // await DressUpConfigUtil.GetCfgsAsync<ItemCfg>("ItemCfgArray", colNames, colValues, _cfgsGroupDic1,
  50. // HandleCfg);
  51. // }
  52. }
  53. }