FreeModeItemLifeMode.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. protected 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. if (this.m_LifeModeData.dataRequestBodyTypeEquals)
  150. {
  151. bool result;
  152. if (!this.IsCorrectMaidPersonal(from m in lifeModeAllMaidList
  153. where m.IsCrcBody
  154. select m))
  155. {
  156. result = this.IsCorrectMaidPersonal(from m in lifeModeAllMaidList
  157. where !m.IsCrcBody
  158. select m);
  159. }
  160. else
  161. {
  162. result = true;
  163. }
  164. return result;
  165. }
  166. if (this.m_LifeModeData.dataNewBodyBlock && lifeModeAllMaidList != null)
  167. {
  168. foreach (Maid maid in lifeModeAllMaidList)
  169. {
  170. if (maid.IsCrcBody)
  171. {
  172. return false;
  173. }
  174. }
  175. }
  176. return this.IsCorrectMaidPersonal(lifeModeAllMaidList);
  177. }
  178. }
  179. public override string play_file_name
  180. {
  181. get
  182. {
  183. return this.m_PlayFileName;
  184. }
  185. }
  186. public override AbstractFreeModeItem.ItemType type
  187. {
  188. get
  189. {
  190. return AbstractFreeModeItem.ItemType.LifeMode;
  191. }
  192. }
  193. private bool IsCorrectMaidPersonal(IEnumerable<Maid> maidList)
  194. {
  195. using (Dictionary<int, string>.Enumerator enumerator = this.m_LifeModeData.dataMaidPersonalUniqueNameAndActiveSlotDic.GetEnumerator())
  196. {
  197. while (enumerator.MoveNext())
  198. {
  199. KeyValuePair<int, string> personalSlotPair = enumerator.Current;
  200. if (!maidList.Any((Maid maid) => maid.status.personal.uniqueName == personalSlotPair.Value))
  201. {
  202. return false;
  203. }
  204. }
  205. }
  206. return true;
  207. }
  208. public bool IsDisplayable
  209. {
  210. get
  211. {
  212. bool flag = this.m_IsAllEnabledPersonal && this.m_LifeModeData.IsCorrectNTRBlock();
  213. if (flag && this.m_LifeModeData.dataMaidPersonalUniqueNameAndActiveSlotDic != null)
  214. {
  215. foreach (KeyValuePair<int, string> keyValuePair in this.m_LifeModeData.dataMaidPersonalUniqueNameAndActiveSlotDic)
  216. {
  217. Personal.Data data = Personal.GetData(keyValuePair.Value);
  218. if (!PersonalEventBlocker.IsEnabledLifeMode(data))
  219. {
  220. flag = false;
  221. break;
  222. }
  223. }
  224. }
  225. return flag;
  226. }
  227. }
  228. public readonly EmpireLifeModeData.Data m_LifeModeData;
  229. private readonly int m_ID;
  230. private readonly int m_LifeModeDataID;
  231. private readonly string m_Title;
  232. private readonly string m_PlayFileName;
  233. private readonly string m_Text;
  234. private readonly string[] m_ConditionTexts;
  235. public readonly bool m_IsAllEnabledPersonal;
  236. private static Dictionary<int, FreeModeItemLifeMode> m_DataDic;
  237. private const string STR_MSG = "ライフモード回想";
  238. }