YotogiStage.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. using wf;
  6. public static class YotogiStage
  7. {
  8. public static int Count
  9. {
  10. get
  11. {
  12. YotogiStage.CreateData();
  13. return YotogiStage.commonIdManager.idMap.Count;
  14. }
  15. }
  16. public static bool Contains(string name)
  17. {
  18. YotogiStage.CreateData();
  19. return YotogiStage.commonIdManager.nameMap.ContainsKey(name);
  20. }
  21. public static bool Contains(int id)
  22. {
  23. YotogiStage.CreateData();
  24. return YotogiStage.commonIdManager.idMap.ContainsKey(id);
  25. }
  26. public static int uniqueNameToId(string name)
  27. {
  28. YotogiStage.CreateData();
  29. NDebug.Assert(YotogiStage.commonIdManager.nameMap.ContainsKey(name), "夜伽ステージ\nユニーク名[" + name + "]をIDに変換できませんでした");
  30. return YotogiStage.commonIdManager.nameMap[name];
  31. }
  32. public static string IdToUniqueName(int id)
  33. {
  34. YotogiStage.CreateData();
  35. NDebug.Assert(YotogiStage.commonIdManager.idMap.ContainsKey(id), "夜伽ステージ\nID[" + id + "]をユニーク名に変換できませんでした");
  36. return YotogiStage.commonIdManager.idMap[id].Key;
  37. }
  38. public static YotogiStage.Data GetData(int id)
  39. {
  40. YotogiStage.CreateData();
  41. NDebug.Assert(YotogiStage.basicDatas.ContainsKey(id), "夜伽ステージ\nID[" + id + "]のデータは存在しません");
  42. return YotogiStage.basicDatas[id];
  43. }
  44. public static YotogiStage.Data GetData(string uniqueName)
  45. {
  46. return YotogiStage.GetData(YotogiStage.uniqueNameToId(uniqueName));
  47. }
  48. public static bool IsEnabled(string uniqueName)
  49. {
  50. YotogiStage.CreateData();
  51. return YotogiStage.commonIdManager.enabledIdList.Contains(YotogiStage.uniqueNameToId(uniqueName));
  52. }
  53. public static bool IsEnabled(int id)
  54. {
  55. YotogiStage.CreateData();
  56. return YotogiStage.commonIdManager.enabledIdList.Contains(id);
  57. }
  58. public static List<YotogiStage.Data> GetAllDatas(bool onlyEnabled)
  59. {
  60. YotogiStage.CreateData();
  61. List<YotogiStage.Data> list = new List<YotogiStage.Data>();
  62. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in YotogiStage.commonIdManager.idMap)
  63. {
  64. if (!onlyEnabled || YotogiStage.commonIdManager.enabledIdList.Contains(keyValuePair.Key))
  65. {
  66. list.Add(YotogiStage.basicDatas[keyValuePair.Key]);
  67. }
  68. }
  69. return list;
  70. }
  71. public static void CreateData()
  72. {
  73. if (YotogiStage.commonIdManager != null)
  74. {
  75. return;
  76. }
  77. YotogiStage.commonIdManager = new CsvCommonIdManager("yotogi_stage", "夜伽ステージ", CsvCommonIdManager.Type.IdAndUniqueName, null);
  78. YotogiStage.basicDatas = new Dictionary<int, YotogiStage.Data>();
  79. string[] array = new string[]
  80. {
  81. "list"
  82. };
  83. KeyValuePair<AFileBase, CsvParser>[] array2 = new KeyValuePair<AFileBase, CsvParser>[array.Length];
  84. for (int i = 0; i < array2.Length; i++)
  85. {
  86. string text = "yotogi_stage_" + array[i] + ".nei";
  87. AFileBase afileBase = GameUty.FileSystem.FileOpen(text);
  88. CsvParser csvParser = new CsvParser();
  89. bool condition = csvParser.Open(afileBase);
  90. NDebug.Assert(condition, text + "\nopen failed.");
  91. array2[i] = new KeyValuePair<AFileBase, CsvParser>(afileBase, csvParser);
  92. }
  93. HashSet<int> hashSet = new HashSet<int>(YotogiStage.commonIdManager.enabledIdList);
  94. using (AFileBase afileBase2 = GameUty.FileSystem.FileOpen("yotogi_stage_compatibility_list.nei"))
  95. {
  96. if (afileBase2 != null && afileBase2.IsValid())
  97. {
  98. using (CsvParser csvParser2 = new CsvParser())
  99. {
  100. if (csvParser2.Open(afileBase2))
  101. {
  102. for (int j = 1; j < csvParser2.max_cell_y; j++)
  103. {
  104. if (csvParser2.IsCellToExistData(0, j))
  105. {
  106. int cellAsInteger = csvParser2.GetCellAsInteger(0, j);
  107. string cellAsString = csvParser2.GetCellAsString(2, j);
  108. bool flag = !string.IsNullOrEmpty(cellAsString) && PluginData.IsEnabled(cellAsString);
  109. if (flag && !hashSet.Contains(cellAsInteger))
  110. {
  111. hashSet.Add(cellAsInteger);
  112. }
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. Dictionary<int, KeyValuePair<string, string>> idMap = new Dictionary<int, KeyValuePair<string, string>>(YotogiStage.commonIdManager.idMap);
  120. Dictionary<string, int> nameMap = new Dictionary<string, int>(YotogiStage.commonIdManager.nameMap);
  121. YotogiStage.commonIdManager = new CsvCommonIdManager(idMap, nameMap, hashSet, CsvCommonIdManager.Type.IdAndUniqueName);
  122. foreach (KeyValuePair<int, KeyValuePair<string, string>> keyValuePair in YotogiStage.commonIdManager.idMap)
  123. {
  124. YotogiStage.basicDatas.Add(keyValuePair.Key, new YotogiStage.Data(keyValuePair.Key, array2[0].Value));
  125. }
  126. foreach (KeyValuePair<AFileBase, CsvParser> keyValuePair2 in array2)
  127. {
  128. keyValuePair2.Value.Dispose();
  129. keyValuePair2.Key.Dispose();
  130. }
  131. }
  132. private const string csvTopCommonName = "yotogi_stage";
  133. private const string typeNameForErrorLog = "夜伽ステージ";
  134. public const string termRootText = "SceneYotogi/背景タイプ/";
  135. private static CsvCommonIdManager commonIdManager;
  136. private static Dictionary<int, YotogiStage.Data> basicDatas;
  137. public class Data : IComparable, IComparable<YotogiStage.Data>
  138. {
  139. public Data(int id, CsvParser basicCsv)
  140. {
  141. List<int> list = new List<int>();
  142. for (int i = 1; i < basicCsv.max_cell_y; i++)
  143. {
  144. if (basicCsv.IsCellToExistData(0, i) && basicCsv.GetCellAsInteger(0, i) == id)
  145. {
  146. this.id = id;
  147. int num = 1;
  148. string text = string.Empty;
  149. this.uniqueName = basicCsv.GetCellAsString(num++, i);
  150. this.drawName = basicCsv.GetCellAsString(num++, i);
  151. this.sortId = basicCsv.GetCellAsInteger(num++, i);
  152. this.drawClubGrade = basicCsv.GetCellAsInteger(num++, i);
  153. this.requestClubGrade = basicCsv.GetCellAsInteger(num++, i);
  154. this.requestFacilityIds = new int[0];
  155. text = basicCsv.GetCellAsString(num++, i);
  156. if (!string.IsNullOrEmpty(text))
  157. {
  158. string[] array = text.Split(new char[]
  159. {
  160. ','
  161. });
  162. this.requestFacilityIds = new int[array.Length];
  163. for (int j = 0; j < array.Length; j++)
  164. {
  165. this.requestFacilityIds[j] = int.Parse(array[j].Trim());
  166. }
  167. }
  168. this.prefabName = new string[2];
  169. this.thumbnailName = new string[2];
  170. for (int k = 0; k < this.prefabName.Length; k++)
  171. {
  172. this.prefabName[k] = basicCsv.GetCellAsString(num++, i);
  173. this.thumbnailName[k] = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".tex");
  174. }
  175. this.bgmFileName = Path.ChangeExtension(basicCsv.GetCellAsString(num++, i), ".ogg");
  176. string cellAsString = basicCsv.GetCellAsString(num++, i);
  177. string[] array2 = cellAsString.Split(new char[]
  178. {
  179. ','
  180. });
  181. NDebug.Assert(array2.Length == 6, "ステージカメラ設定が不正です\nLine : " + i.ToString());
  182. Vector3 center = new Vector3(float.Parse(array2[0]), float.Parse(array2[1]), float.Parse(array2[2]));
  183. float radius = float.Parse(array2[3]);
  184. Vector2 v = new Vector2(float.Parse(array2[4]), float.Parse(array2[5]));
  185. this.stageSelectCameraData = new YotogiStage.Data.Camera(center, v, radius);
  186. cellAsString = basicCsv.GetCellAsString(num++, i);
  187. array2 = cellAsString.Split(new char[]
  188. {
  189. ','
  190. });
  191. NDebug.Assert(array2.Length == 6, "カス子位置情報が不正です\nLine : " + i.ToString());
  192. Vector3 position = new Vector3(float.Parse(array2[0]), float.Parse(array2[1]), float.Parse(array2[2]));
  193. Vector3 rotation = new Vector3(float.Parse(array2[3]), float.Parse(array2[4]), float.Parse(array2[5]));
  194. cellAsString = basicCsv.GetCellAsString(num++, i);
  195. array2 = cellAsString.Split(new char[]
  196. {
  197. ','
  198. });
  199. NDebug.Assert(array2.Length == 2, "スキル選択時カメラデータが不正です\nLine : " + i.ToString());
  200. Vector2 cameraAngle = new Vector2(float.Parse(array2[0]), float.Parse(array2[1]));
  201. this.skillSelectcharacterData = new YotogiStage.Data.Character(position, rotation, cameraAngle);
  202. string cellAsString2 = basicCsv.GetCellAsString(num++, i);
  203. string[] array3 = cellAsString2.Split(new char[]
  204. {
  205. ','
  206. });
  207. NDebug.Assert(array3.Length == 4, "スキル選択時ライトデータが不正です\nLine : " + i.ToString());
  208. Vector3 position2 = new Vector3(float.Parse(array3[0]), float.Parse(array3[1]), float.Parse(array3[2]));
  209. float intensity = float.Parse(array3[3]);
  210. this.skillSelectLightData = new YotogiStage.Data.Light(position2, intensity);
  211. break;
  212. }
  213. }
  214. }
  215. public int CompareTo(YotogiStage.Data other)
  216. {
  217. return this.sortId.CompareTo(other.sortId);
  218. }
  219. public int CompareTo(object other)
  220. {
  221. return this.sortId.CompareTo(((YotogiStage.Data)other).sortId);
  222. }
  223. public bool isYotogiPlayable(int clubGrade, bool checkFacility)
  224. {
  225. if (clubGrade < this.requestClubGrade)
  226. {
  227. return false;
  228. }
  229. bool flag = this.requestFacilityIds.Length == 0;
  230. FacilityManager facilityMgr = GameMain.Instance.FacilityMgr;
  231. foreach (int facilityTypeID in this.requestFacilityIds)
  232. {
  233. if (checkFacility)
  234. {
  235. flag |= facilityMgr.IsExistTypeFacility(facilityTypeID);
  236. }
  237. else
  238. {
  239. flag |= facilityMgr.IsFacilityBuildFlag(facilityTypeID);
  240. }
  241. }
  242. return flag;
  243. }
  244. public string termName
  245. {
  246. get
  247. {
  248. return "SceneYotogi/背景タイプ/" + this.uniqueName;
  249. }
  250. }
  251. public readonly int id;
  252. public readonly string uniqueName;
  253. public readonly string drawName;
  254. public readonly int drawClubGrade;
  255. public readonly int sortId;
  256. public readonly int requestClubGrade;
  257. public readonly int[] requestFacilityIds;
  258. public readonly string[] prefabName;
  259. public readonly string[] thumbnailName;
  260. public readonly string bgmFileName;
  261. public readonly YotogiStage.Data.Camera stageSelectCameraData;
  262. public readonly YotogiStage.Data.Light skillSelectLightData;
  263. public readonly YotogiStage.Data.Character skillSelectcharacterData;
  264. public class Camera
  265. {
  266. public Camera(Vector3 center, Vector3 angle, float radius)
  267. {
  268. this.center = center;
  269. this.angle = angle;
  270. this.radius = radius;
  271. }
  272. public void Apply(CameraMain camera)
  273. {
  274. camera.SetFromScriptOnTarget(this.center, this.radius, this.angle);
  275. }
  276. public void Apply()
  277. {
  278. this.Apply(GameMain.Instance.MainCamera);
  279. }
  280. public readonly Vector3 center;
  281. public readonly Vector2 angle;
  282. public readonly float radius;
  283. }
  284. public class Light
  285. {
  286. public Light(Vector3 position, float intensity)
  287. {
  288. this.position = position;
  289. this.intensity = intensity;
  290. }
  291. public void Apply(LightMain light)
  292. {
  293. light.SetRotation(this.position);
  294. light.SetIntensity(this.intensity);
  295. }
  296. public void Apply()
  297. {
  298. this.Apply(GameMain.Instance.MainLight);
  299. }
  300. public readonly Vector3 position;
  301. public readonly float intensity;
  302. }
  303. public class Character
  304. {
  305. public Character(Vector3 position, Vector3 rotation, Vector2 cameraAngle)
  306. {
  307. this.position = position;
  308. this.rotation = rotation;
  309. this.cameraAngle = cameraAngle;
  310. }
  311. public void Apply(CharacterMgr charaMgr)
  312. {
  313. charaMgr.SetCharaAllPos(this.position);
  314. charaMgr.SetCharaAllRot(this.rotation);
  315. }
  316. public void Apply()
  317. {
  318. this.Apply(GameMain.Instance.CharacterMgr);
  319. }
  320. public readonly Vector3 position;
  321. public readonly Vector3 rotation;
  322. public readonly Vector2 cameraAngle;
  323. }
  324. }
  325. }