FreeModeItemLifeMode.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. public class FreeModeItemLifeMode : AbstractFreeModeItem
  5. {
  6. private FreeModeItemLifeMode(CsvParser csv, int y)
  7. {
  8. int num = 0;
  9. this.m_ID = csv.GetCellAsInteger(num++, y);
  10. this.m_LifeModeDataID = csv.GetCellAsInteger(num++, y);
  11. this.m_Title = csv.GetCellAsString(num++, y);
  12. this.m_PlayFileName = csv.GetCellAsString(num++, y);
  13. this.m_Text = csv.GetCellAsString(num++, y);
  14. List<string> list = new List<string>();
  15. while (num < csv.max_cell_x && csv.IsCellToExistData(num, y))
  16. {
  17. list.Add(csv.GetCellAsString(num++, y));
  18. }
  19. this.m_ConditionTexts = list.ToArray();
  20. NDebug.Assert(EmpireLifeModeData.Contains(this.m_LifeModeDataID), "ライフモード回想\n項目「ライフモードID」の値が不正です。\nこのIDに対応するライフモードの表データが存在しません。\n値:" + this.m_LifeModeDataID.ToString());
  21. this.m_LifeModeData = EmpireLifeModeData.GetData(this.m_LifeModeDataID);
  22. this.m_IsAllEnabledPersonal = true;
  23. foreach (KeyValuePair<int, string> keyValuePair in this.m_LifeModeData.dataMaidPersonalUniqueNameAndActiveSlotDic)
  24. {
  25. if (!EmpireLifeModeAPI.GetEnabledPersonalListOfRecollection().Contains(keyValuePair.Value))
  26. {
  27. this.m_IsAllEnabledPersonal = false;
  28. break;
  29. }
  30. }
  31. if (this.m_IsAllEnabledPersonal && !this.m_LifeModeData.IsCorrectPersonalGP002())
  32. {
  33. this.m_IsAllEnabledPersonal = false;
  34. }
  35. }
  36. public static List<FreeModeItemLifeMode> CreateItemList(bool displayableOnly = true)
  37. {
  38. FreeModeItemLifeMode.CreateCsvData();
  39. if (displayableOnly)
  40. {
  41. return new List<FreeModeItemLifeMode>(from data in FreeModeItemLifeMode.m_DataDic.Values
  42. where data.IsDisplayable
  43. select data);
  44. }
  45. return new List<FreeModeItemLifeMode>(FreeModeItemLifeMode.m_DataDic.Values);
  46. }
  47. private static void CreateCsvData()
  48. {
  49. if (FreeModeItemLifeMode.m_DataDic != null)
  50. {
  51. return;
  52. }
  53. FreeModeItemLifeMode.m_DataDic = new Dictionary<int, FreeModeItemLifeMode>();
  54. HashSet<int> enabledIdList = AbstractFreeModeItem.GetEnabledIdList();
  55. if (enabledIdList == null || enabledIdList.Count <= 0)
  56. {
  57. return;
  58. }
  59. string text = "recollection_life_mode.nei";
  60. NDebug.Assert(GameUty.FileSystem.IsExistentFile(text), text + "\nopen failed.");
  61. using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text))
  62. {
  63. using (CsvParser csvParser = new CsvParser())
  64. {
  65. bool condition = csvParser.Open(afileBase);
  66. NDebug.Assert(condition, text + "\nopen failed.");
  67. for (int i = 1; i < csvParser.max_cell_y; i++)
  68. {
  69. if (csvParser.IsCellToExistData(0, i))
  70. {
  71. int cellAsInteger = csvParser.GetCellAsInteger(0, i);
  72. if (enabledIdList.Contains(cellAsInteger))
  73. {
  74. FreeModeItemLifeMode freeModeItemLifeMode = new FreeModeItemLifeMode(csvParser, i);
  75. if (freeModeItemLifeMode.m_IsAllEnabledPersonal)
  76. {
  77. FreeModeItemLifeMode.m_DataDic.Add(cellAsInteger, freeModeItemLifeMode);
  78. }
  79. }
  80. }
  81. }
  82. }
  83. }
  84. }
  85. public override string title
  86. {
  87. get
  88. {
  89. return this.m_Title;
  90. }
  91. }
  92. public override string titleTerm
  93. {
  94. get
  95. {
  96. return "SceneFreeModeSelect/タイトル/" + this.m_Title;
  97. }
  98. }
  99. public override int item_id
  100. {
  101. get
  102. {
  103. return this.m_ID;
  104. }
  105. }
  106. public override string text
  107. {
  108. get
  109. {
  110. return this.m_Text;
  111. }
  112. }
  113. public override string textTerm
  114. {
  115. get
  116. {
  117. return "SceneFreeModeSelect/説明/" + this.m_Text;
  118. }
  119. }
  120. public override string[] condition_texts
  121. {
  122. get
  123. {
  124. return this.m_ConditionTexts;
  125. }
  126. }
  127. public override string[] condition_text_terms
  128. {
  129. get
  130. {
  131. string[] array = new string[this.m_ConditionTexts.Length];
  132. for (int i = 0; i < array.Length; i++)
  133. {
  134. array[i] = "SceneFreeModeSelect/条件文/" + this.m_ConditionTexts[i];
  135. }
  136. return array;
  137. }
  138. }
  139. public override bool is_enabled
  140. {
  141. get
  142. {
  143. if (GameMain.Instance.LifeModeMgr.GetScenarioExecuteCount(this.m_LifeModeData.ID) <= 0)
  144. {
  145. return false;
  146. }
  147. List<Maid> lifeModeAllMaidList = GameMain.Instance.LifeModeMgr.lifeModeAllMaidList;
  148. using (Dictionary<int, string>.Enumerator enumerator = this.m_LifeModeData.dataMaidPersonalUniqueNameAndActiveSlotDic.GetEnumerator())
  149. {
  150. while (enumerator.MoveNext())
  151. {
  152. KeyValuePair<int, string> personalSlotPair = enumerator.Current;
  153. if (!lifeModeAllMaidList.Any((Maid maid) => maid.status.personal.uniqueName == personalSlotPair.Value))
  154. {
  155. return false;
  156. }
  157. }
  158. }
  159. return true;
  160. }
  161. }
  162. public override string play_file_name
  163. {
  164. get
  165. {
  166. return this.m_PlayFileName;
  167. }
  168. }
  169. public override AbstractFreeModeItem.ItemType type
  170. {
  171. get
  172. {
  173. return AbstractFreeModeItem.ItemType.LifeMode;
  174. }
  175. }
  176. public bool IsDisplayable
  177. {
  178. get
  179. {
  180. return this.m_IsAllEnabledPersonal && this.m_LifeModeData.IsCorrectNTRBlock();
  181. }
  182. }
  183. public readonly EmpireLifeModeData.Data m_LifeModeData;
  184. private readonly int m_ID;
  185. private readonly int m_LifeModeDataID;
  186. private readonly string m_Title;
  187. private readonly string m_PlayFileName;
  188. private readonly string m_Text;
  189. private readonly string[] m_ConditionTexts;
  190. public readonly bool m_IsAllEnabledPersonal;
  191. private static Dictionary<int, FreeModeItemLifeMode> m_DataDic;
  192. private const string STR_MSG = "ライフモード回想";
  193. }