BgIconData.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. using wf;
  6. namespace SceneEditWindow
  7. {
  8. public class BgIconData
  9. {
  10. public static List<BgIconData.ItemData> itemList { get; private set; }
  11. public static BgIconData.ItemData GetItemData(int id)
  12. {
  13. BgIconData.ItemData result = default(BgIconData.ItemData);
  14. foreach (BgIconData.ItemData itemData in BgIconData.itemList)
  15. {
  16. if (itemData.id == id)
  17. {
  18. result = itemData;
  19. break;
  20. }
  21. }
  22. return result;
  23. }
  24. public static void Create()
  25. {
  26. if (BgIconData.itemList != null)
  27. {
  28. return;
  29. }
  30. HashSet<int> hashSet = new HashSet<int>();
  31. CsvCommonIdManager.ReadEnabledIdList(CsvCommonIdManager.FileSystemType.Normal, true, "edit_bg_enabled_list", ref hashSet);
  32. HashSet<int> hashSet2 = new HashSet<int>();
  33. BgIconData.itemList = new List<BgIconData.ItemData>();
  34. using (AFileBase afileBase = GameUty.FileSystem.FileOpen("edit_bg.nei"))
  35. {
  36. using (CsvParser csvParser = new CsvParser())
  37. {
  38. bool condition = csvParser.Open(afileBase);
  39. NDebug.Assert(condition, "edit_bg.nei\nopen failed.");
  40. for (int i = 1; i < csvParser.max_cell_y; i++)
  41. {
  42. if (csvParser.IsCellToExistData(0, i))
  43. {
  44. int num = 0;
  45. BgIconData.ItemData item = default(BgIconData.ItemData);
  46. item.id = csvParser.GetCellAsInteger(num++, i);
  47. if (hashSet.Contains(item.id))
  48. {
  49. if (!hashSet2.Contains(item.id))
  50. {
  51. hashSet2.Add(item.id);
  52. item.iconTexName = Path.ChangeExtension(csvParser.GetCellAsString(num++, i).ToString(), "tex");
  53. item.bgName = csvParser.GetCellAsString(num++, i);
  54. item.yotogiStageData = null;
  55. string cellAsString = csvParser.GetCellAsString(num++, i);
  56. if (!string.IsNullOrEmpty(cellAsString))
  57. {
  58. try
  59. {
  60. item.yotogiStageData = YotogiStage.GetData(cellAsString);
  61. }
  62. catch (Exception)
  63. {
  64. item.yotogiStageData = null;
  65. goto IL_1D0;
  66. }
  67. }
  68. item.isRefNoon = (csvParser.GetCellAsString(num++, i) == "昼");
  69. item.isLegacyBG = (csvParser.GetCellAsString(num++, i) == "〇");
  70. item.position = Parse.Vector3(csvParser.GetCellAsString(num++, i));
  71. item.rotation_y = float.Parse(csvParser.GetCellAsString(num++, i));
  72. BgIconData.itemList.Add(item);
  73. }
  74. }
  75. }
  76. IL_1D0:;
  77. }
  78. }
  79. }
  80. BgIconData.itemList.Sort((BgIconData.ItemData a, BgIconData.ItemData b) => a.id - b.id);
  81. }
  82. public struct ItemData
  83. {
  84. public bool enabled
  85. {
  86. get
  87. {
  88. return this.yotogiStageData == null || (YotogiStage.IsEnabled(this.yotogiStageData.id) && this.yotogiStageData.isYotogiPlayable(GameMain.Instance.CharacterMgr.status.clubGrade, false));
  89. }
  90. }
  91. public bool Exec()
  92. {
  93. if (GameMain.Instance == null || GameMain.Instance.BgMgr == null)
  94. {
  95. return false;
  96. }
  97. BgMgr bgMgr = GameMain.Instance.BgMgr;
  98. if (string.IsNullOrEmpty(this.bgName) && this.yotogiStageData != null)
  99. {
  100. int num = (!this.isRefNoon) ? 1 : 0;
  101. GameMain.Instance.BgMgr.ChangeBg(this.yotogiStageData.prefabName[num]);
  102. }
  103. else
  104. {
  105. bgMgr.ChangeBg(this.bgName);
  106. }
  107. bgMgr.SetPos(this.position);
  108. bgMgr.SetRot(new Vector3(0f, this.rotation_y, 0f));
  109. return true;
  110. }
  111. public int id;
  112. public bool isLegacyBG;
  113. public YotogiStage.Data yotogiStageData;
  114. public bool isRefNoon;
  115. public string iconTexName;
  116. public string bgName;
  117. public Vector3 position;
  118. public float rotation_y;
  119. }
  120. }
  121. }