YotogiStage.cs 12 KB

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