FreeModeItemEveryday.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. using System;
  2. using System.Collections.Generic;
  3. using MaidStatus;
  4. using PlayerStatus;
  5. public class FreeModeItemEveryday : AbstractFreeModeItem
  6. {
  7. private FreeModeItemEveryday(FreeModeItemEveryday.ScnearioType type, int item_id)
  8. {
  9. this.scnerioType = type;
  10. this.item_id_ = item_id;
  11. this.everyday_event_data_ = FreeModeItemEveryday.DataDic[type].everyday_event_data_dic_[this.item_id_];
  12. this.is_enabled_ = FreeModeItemEveryday.IsEnabledFlag(type, this.everyday_event_data_.check_flag_name);
  13. }
  14. public static List<FreeModeItemEveryday> CreateItemEverydayList(FreeModeItemEveryday.ScnearioType type, MaidStatus.Status maidStatus = null)
  15. {
  16. FreeModeItemEveryday.CreateCsvData(type);
  17. List<FreeModeItemEveryday> list = new List<FreeModeItemEveryday>();
  18. foreach (KeyValuePair<int, FreeModeItemEveryday.EverydayEventData> keyValuePair in FreeModeItemEveryday.DataDic[type].everyday_event_data_dic_)
  19. {
  20. if (maidStatus != null && !DailyMgr.IsLegacy)
  21. {
  22. if (maidStatus.subCharaData != null)
  23. {
  24. if (keyValuePair.Value.subHerionID != maidStatus.subCharaData.id)
  25. {
  26. continue;
  27. }
  28. }
  29. else if (!keyValuePair.Value.personalIdList.Contains(maidStatus.personal.id))
  30. {
  31. continue;
  32. }
  33. }
  34. if (keyValuePair.Value.gameMode != AbstractFreeModeItem.GameMode.CM3D2 || DailyMgr.IsLegacy)
  35. {
  36. if (keyValuePair.Value.gameMode != AbstractFreeModeItem.GameMode.COM3D || !DailyMgr.IsLegacy)
  37. {
  38. if (!GameMain.Instance.CharacterMgr.status.lockNTRPlay || !keyValuePair.Value.netorare)
  39. {
  40. if (type == FreeModeItemEveryday.ScnearioType.Story)
  41. {
  42. string check_flag_name = keyValuePair.Value.check_flag_name;
  43. if (!FreeModeItemEveryday.IsEnabledFlag(FreeModeItemEveryday.ScnearioType.Story, check_flag_name))
  44. {
  45. continue;
  46. }
  47. }
  48. list.Add(new FreeModeItemEveryday(type, keyValuePair.Key));
  49. }
  50. }
  51. }
  52. }
  53. return list;
  54. }
  55. public static void CheckAllMaidEveryDayFlag()
  56. {
  57. FreeModeItemEveryday.CheckAllMaidEveryDayFlag(FreeModeItemEveryday.ScnearioType.Story);
  58. FreeModeItemEveryday.CheckAllMaidEveryDayFlag(FreeModeItemEveryday.ScnearioType.Nitijyou);
  59. }
  60. public static void CheckAllMaidEveryDayFlag(FreeModeItemEveryday.ScnearioType type)
  61. {
  62. FreeModeItemEveryday.CreateCsvData(type);
  63. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  64. PlayerStatus.Status status = characterMgr.status;
  65. List<string> list = new List<string>();
  66. foreach (string text in FreeModeItemEveryday.DataDic[type].flag_name_set_)
  67. {
  68. if (status.GetFlag(FreeModeItemEveryday.DataDic[type].FixingFlagText + text) == 0)
  69. {
  70. list.Add(text);
  71. }
  72. }
  73. for (int i = 0; i < characterMgr.GetStockMaidCount(); i++)
  74. {
  75. Maid stockMaid = characterMgr.GetStockMaid(i);
  76. if (!(stockMaid == null))
  77. {
  78. MaidStatus.Status status2 = stockMaid.status;
  79. for (int j = 0; j < list.Count; j++)
  80. {
  81. if (status2.GetFlag(list[j]) != 0)
  82. {
  83. characterMgr.status.SetFlag(FreeModeItemEveryday.DataDic[type].FixingFlagText + list[j], 1);
  84. }
  85. }
  86. }
  87. }
  88. }
  89. public static void CheckEveryDayFlag(string flag_name, FreeModeItemEveryday.ScnearioType type)
  90. {
  91. FreeModeItemEveryday.CreateCsvData(type);
  92. if (FreeModeItemEveryday.DataDic[type].flag_name_set_.Contains(flag_name) && !FreeModeItemEveryday.IsEnabledFlag(type, flag_name))
  93. {
  94. GameMain.Instance.CharacterMgr.status.SetFlag(FreeModeItemEveryday.DataDic[type].FixingFlagText + flag_name, 1);
  95. }
  96. }
  97. public static bool IsEnabledFlag(FreeModeItemEveryday.ScnearioType type, string flag_name)
  98. {
  99. string flagName = FreeModeItemEveryday.DataDic[type].FixingFlagText + flag_name;
  100. return GameMain.Instance.CharacterMgr.status.GetFlag(flagName) != 0;
  101. }
  102. public override int item_id
  103. {
  104. get
  105. {
  106. return this.item_id_;
  107. }
  108. }
  109. public override string title
  110. {
  111. get
  112. {
  113. return this.everyday_event_data_.name;
  114. }
  115. }
  116. public override string titleTerm
  117. {
  118. get
  119. {
  120. return "SceneFreeModeSelect/タイトル/" + this.everyday_event_data_.name;
  121. }
  122. }
  123. public override string text
  124. {
  125. get
  126. {
  127. return this.everyday_event_data_.info_text;
  128. }
  129. }
  130. public override string textTerm
  131. {
  132. get
  133. {
  134. return "SceneFreeModeSelect/説明/" + this.everyday_event_data_.name;
  135. }
  136. }
  137. public override string[] condition_texts
  138. {
  139. get
  140. {
  141. return this.everyday_event_data_.condition_texts;
  142. }
  143. }
  144. public override string[] condition_text_terms
  145. {
  146. get
  147. {
  148. List<string> list = new List<string>();
  149. foreach (string str in this.everyday_event_data_.condition_texts)
  150. {
  151. list.Add("SceneFreeModeSelect/条件文/" + str);
  152. }
  153. return list.ToArray();
  154. }
  155. }
  156. public override bool is_enabled
  157. {
  158. get
  159. {
  160. return this.is_enabled_;
  161. }
  162. }
  163. public override string play_file_name
  164. {
  165. get
  166. {
  167. return this.everyday_event_data_.call_file_name;
  168. }
  169. }
  170. public override AbstractFreeModeItem.ItemType type
  171. {
  172. get
  173. {
  174. if (this.scnerioType == FreeModeItemEveryday.ScnearioType.Story)
  175. {
  176. return AbstractFreeModeItem.ItemType.MainStory;
  177. }
  178. return AbstractFreeModeItem.ItemType.Normal;
  179. }
  180. }
  181. private static void CreateCsvData(FreeModeItemEveryday.ScnearioType type)
  182. {
  183. string fileName = string.Empty;
  184. string fixingFlagText;
  185. if (type == FreeModeItemEveryday.ScnearioType.Nitijyou)
  186. {
  187. fileName = "recollection_normal2.nei";
  188. fixingFlagText = "シーン鑑賞_一般_フラグ_";
  189. }
  190. else
  191. {
  192. if (type != FreeModeItemEveryday.ScnearioType.Story)
  193. {
  194. return;
  195. }
  196. fileName = "recollection_story.nei";
  197. fixingFlagText = "シーン鑑賞_メイン_フラグ_";
  198. }
  199. if (!FreeModeItemEveryday.DataDic.ContainsKey(type))
  200. {
  201. FreeModeItemEveryday.DataDic.Add(type, new FreeModeItemEveryday.ScnerioData(fixingFlagText));
  202. }
  203. if (FreeModeItemEveryday.DataDic[type].everyday_event_data_dic_ != null)
  204. {
  205. return;
  206. }
  207. FreeModeItemEveryday.DataDic[type].everyday_event_data_dic_ = new SortedDictionary<int, FreeModeItemEveryday.EverydayEventData>();
  208. FreeModeItemEveryday.CreateCsvData(type, fileName, AbstractFreeModeItem.GameMode.COM3D);
  209. if (GameUty.IsEnabledCompatibilityMode && type == FreeModeItemEveryday.ScnearioType.Nitijyou)
  210. {
  211. FreeModeItemEveryday.CreateLeagacyDisableIdList();
  212. FreeModeItemEveryday.CreateCsvData(type, fileName, AbstractFreeModeItem.GameMode.CM3D2);
  213. }
  214. }
  215. private static void CreateCsvData(FreeModeItemEveryday.ScnearioType type, string fileName, AbstractFreeModeItem.GameMode gameMode)
  216. {
  217. HashSet<int> hashSet;
  218. AFileBase afileBase;
  219. if (gameMode == AbstractFreeModeItem.GameMode.CM3D2)
  220. {
  221. hashSet = AbstractFreeModeItem.GetEnabledOldIdList();
  222. NDebug.Assert(GameUty.FileSystemOld.IsExistentFile(fileName), fileName + "\nopen failed.");
  223. afileBase = GameUty.FileSystemOld.FileOpen(fileName);
  224. }
  225. else
  226. {
  227. if (gameMode != AbstractFreeModeItem.GameMode.COM3D)
  228. {
  229. return;
  230. }
  231. hashSet = AbstractFreeModeItem.GetEnabledIdList();
  232. NDebug.Assert(GameUty.FileSystem.IsExistentFile(fileName), fileName + "\nopen failed.");
  233. afileBase = GameUty.FileSystem.FileOpen(fileName);
  234. }
  235. if (hashSet == null || hashSet.Count <= 0)
  236. {
  237. return;
  238. }
  239. using (afileBase)
  240. {
  241. using (CsvParser csvParser = new CsvParser())
  242. {
  243. bool condition = csvParser.Open(afileBase);
  244. NDebug.Assert(condition, fileName + "\nopen failed.");
  245. for (int i = 1; i < csvParser.max_cell_y; i++)
  246. {
  247. if (csvParser.IsCellToExistData(0, i))
  248. {
  249. int cellAsInteger = csvParser.GetCellAsInteger(0, i);
  250. if (hashSet.Contains(cellAsInteger))
  251. {
  252. FreeModeItemEveryday.EverydayEventData everydayEventData = new FreeModeItemEveryday.EverydayEventData();
  253. everydayEventData.id = cellAsInteger;
  254. int num = 1;
  255. if (gameMode != AbstractFreeModeItem.GameMode.CM3D2 || type != FreeModeItemEveryday.ScnearioType.Nitijyou || !FreeModeItemEveryday.disableIdList.Contains(everydayEventData.id))
  256. {
  257. everydayEventData.gameMode = gameMode;
  258. everydayEventData.name = csvParser.GetCellAsString(num++, i);
  259. everydayEventData.call_file_name = csvParser.GetCellAsString(num++, i);
  260. everydayEventData.check_flag_name = csvParser.GetCellAsString(num++, i);
  261. if (gameMode == AbstractFreeModeItem.GameMode.COM3D)
  262. {
  263. everydayEventData.netorare = (csvParser.GetCellAsString(num++, i) == "○");
  264. }
  265. everydayEventData.info_text = csvParser.GetCellAsString(num++, i);
  266. List<string> list = new List<string>();
  267. for (int j = 0; j < 9; j++)
  268. {
  269. if (csvParser.IsCellToExistData(num, i))
  270. {
  271. list.Add(csvParser.GetCellAsString(num, i));
  272. }
  273. num++;
  274. }
  275. everydayEventData.subHerionID = csvParser.GetCellAsInteger(num++, i);
  276. while (csvParser.IsCellToExistData(num, 0))
  277. {
  278. if (csvParser.GetCellAsString(num, i) == "○")
  279. {
  280. string cellAsString = csvParser.GetCellAsString(num, 0);
  281. Personal.Data data = Personal.GetData(cellAsString);
  282. everydayEventData.personalIdList.Add(data.id);
  283. }
  284. num++;
  285. }
  286. everydayEventData.condition_texts = list.ToArray();
  287. if (!FreeModeItemEveryday.DataDic[type].everyday_event_data_dic_.ContainsKey(everydayEventData.id))
  288. {
  289. if (!FreeModeItemEveryday.DataDic[type].flag_name_set_.Contains(everydayEventData.check_flag_name))
  290. {
  291. FreeModeItemEveryday.DataDic[type].flag_name_set_.Add(everydayEventData.check_flag_name);
  292. }
  293. FreeModeItemEveryday.DataDic[type].everyday_event_data_dic_.Add(everydayEventData.id, everydayEventData);
  294. }
  295. }
  296. }
  297. }
  298. }
  299. }
  300. }
  301. }
  302. private static void CreateLeagacyDisableIdList()
  303. {
  304. AFileBase afileBase = GameUty.FileSystem.FileOpen("recollection_legacy_disable.nei");
  305. using (afileBase)
  306. {
  307. using (CsvParser csvParser = new CsvParser())
  308. {
  309. bool flag = csvParser.Open(afileBase);
  310. FreeModeItemEveryday.disableIdList = new List<int>();
  311. int max_cell_y = csvParser.max_cell_y;
  312. for (int i = 1; i < max_cell_y; i++)
  313. {
  314. FreeModeItemEveryday.disableIdList.Add(csvParser.GetCellAsInteger(0, i));
  315. }
  316. }
  317. }
  318. }
  319. private static Dictionary<FreeModeItemEveryday.ScnearioType, FreeModeItemEveryday.ScnerioData> DataDic = new Dictionary<FreeModeItemEveryday.ScnearioType, FreeModeItemEveryday.ScnerioData>();
  320. private static List<int> disableIdList = new List<int>();
  321. private bool is_enabled_;
  322. private int item_id_;
  323. private FreeModeItemEveryday.EverydayEventData everyday_event_data_;
  324. private FreeModeItemEveryday.ScnearioType scnerioType;
  325. public enum ScnearioType
  326. {
  327. Story,
  328. Nitijyou
  329. }
  330. private class ScnerioData
  331. {
  332. public ScnerioData(string FixingFlagText)
  333. {
  334. this.FixingFlagText = FixingFlagText;
  335. }
  336. public SortedDictionary<int, FreeModeItemEveryday.EverydayEventData> everyday_event_data_dic_;
  337. public HashSet<string> flag_name_set_ = new HashSet<string>();
  338. public string FixingFlagText = "シーン鑑賞_一般_フラグ_";
  339. }
  340. private class EverydayEventData
  341. {
  342. public AbstractFreeModeItem.GameMode gameMode;
  343. public int id;
  344. public string name;
  345. public string call_file_name;
  346. public string check_flag_name;
  347. public string info_text;
  348. public bool netorare;
  349. public int subHerionID;
  350. public string[] condition_texts;
  351. public List<int> personalIdList = new List<int>();
  352. }
  353. }