FreeModeItemLifeMode.cs 5.7 KB

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