FreeModeItemLifeMode.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. }
  32. public static List<FreeModeItemLifeMode> CreateItemList(bool displayableOnly = true)
  33. {
  34. FreeModeItemLifeMode.CreateCsvData();
  35. if (displayableOnly)
  36. {
  37. return new List<FreeModeItemLifeMode>(from data in FreeModeItemLifeMode.m_DataDic.Values
  38. where data.IsDisplayable
  39. select data);
  40. }
  41. return new List<FreeModeItemLifeMode>(FreeModeItemLifeMode.m_DataDic.Values);
  42. }
  43. private static void CreateCsvData()
  44. {
  45. if (FreeModeItemLifeMode.m_DataDic != null)
  46. {
  47. return;
  48. }
  49. FreeModeItemLifeMode.m_DataDic = new Dictionary<int, FreeModeItemLifeMode>();
  50. HashSet<int> enabledIdList = AbstractFreeModeItem.GetEnabledIdList();
  51. if (enabledIdList == null || enabledIdList.Count <= 0)
  52. {
  53. return;
  54. }
  55. string text = "recollection_life_mode.nei";
  56. NDebug.Assert(GameUty.FileSystem.IsExistentFile(text), text + "\nopen failed.");
  57. using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text))
  58. {
  59. using (CsvParser csvParser = new CsvParser())
  60. {
  61. bool condition = csvParser.Open(afileBase);
  62. NDebug.Assert(condition, text + "\nopen failed.");
  63. for (int i = 1; i < csvParser.max_cell_y; i++)
  64. {
  65. if (csvParser.IsCellToExistData(0, i))
  66. {
  67. int cellAsInteger = csvParser.GetCellAsInteger(0, i);
  68. if (enabledIdList.Contains(cellAsInteger))
  69. {
  70. FreeModeItemLifeMode freeModeItemLifeMode = new FreeModeItemLifeMode(csvParser, i);
  71. if (freeModeItemLifeMode.m_IsAllEnabledPersonal)
  72. {
  73. FreeModeItemLifeMode.m_DataDic.Add(cellAsInteger, freeModeItemLifeMode);
  74. }
  75. }
  76. }
  77. }
  78. }
  79. }
  80. }
  81. public override string title
  82. {
  83. get
  84. {
  85. return this.m_Title;
  86. }
  87. }
  88. public override string titleTerm
  89. {
  90. get
  91. {
  92. return "SceneFreeModeSelect/タイトル/" + this.m_Title;
  93. }
  94. }
  95. public override int item_id
  96. {
  97. get
  98. {
  99. return this.m_ID;
  100. }
  101. }
  102. public override string text
  103. {
  104. get
  105. {
  106. return this.m_Text;
  107. }
  108. }
  109. public override string textTerm
  110. {
  111. get
  112. {
  113. return "SceneFreeModeSelect/説明/" + this.m_Text;
  114. }
  115. }
  116. public override string[] condition_texts
  117. {
  118. get
  119. {
  120. return this.m_ConditionTexts;
  121. }
  122. }
  123. public override string[] condition_text_terms
  124. {
  125. get
  126. {
  127. string[] array = new string[this.m_ConditionTexts.Length];
  128. for (int i = 0; i < array.Length; i++)
  129. {
  130. array[i] = "SceneFreeModeSelect/条件文/" + this.m_ConditionTexts[i];
  131. }
  132. return array;
  133. }
  134. }
  135. public override bool is_enabled
  136. {
  137. get
  138. {
  139. if (GameMain.Instance.LifeModeMgr.GetScenarioExecuteCount(this.m_LifeModeData.ID) <= 0)
  140. {
  141. return false;
  142. }
  143. List<Maid> lifeModeAllMaidList = GameMain.Instance.LifeModeMgr.lifeModeAllMaidList;
  144. using (Dictionary<int, string>.Enumerator enumerator = this.m_LifeModeData.dataMaidPersonalUniqueNameAndActiveSlotDic.GetEnumerator())
  145. {
  146. while (enumerator.MoveNext())
  147. {
  148. KeyValuePair<int, string> personalSlotPair = enumerator.Current;
  149. if (!lifeModeAllMaidList.Any((Maid maid) => maid.status.personal.uniqueName == personalSlotPair.Value))
  150. {
  151. return false;
  152. }
  153. }
  154. }
  155. return true;
  156. }
  157. }
  158. public override string play_file_name
  159. {
  160. get
  161. {
  162. return this.m_PlayFileName;
  163. }
  164. }
  165. public override AbstractFreeModeItem.ItemType type
  166. {
  167. get
  168. {
  169. return AbstractFreeModeItem.ItemType.LifeMode;
  170. }
  171. }
  172. public bool IsDisplayable
  173. {
  174. get
  175. {
  176. return this.m_IsAllEnabledPersonal && this.m_LifeModeData.IsCorrectNTRBlock();
  177. }
  178. }
  179. public readonly EmpireLifeModeData.Data m_LifeModeData;
  180. private readonly int m_ID;
  181. private readonly int m_LifeModeDataID;
  182. private readonly string m_Title;
  183. private readonly string m_PlayFileName;
  184. private readonly string m_Text;
  185. private readonly string[] m_ConditionTexts;
  186. public readonly bool m_IsAllEnabledPersonal;
  187. private static Dictionary<int, FreeModeItemLifeMode> m_DataDic;
  188. private const string STR_MSG = "ライフモード回想";
  189. }