FreeModeItemEveryday.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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 text
  117. {
  118. get
  119. {
  120. return this.everyday_event_data_.info_text;
  121. }
  122. }
  123. public override string[] condition_texts
  124. {
  125. get
  126. {
  127. return this.everyday_event_data_.condition_texts;
  128. }
  129. }
  130. public override bool is_enabled
  131. {
  132. get
  133. {
  134. return this.is_enabled_;
  135. }
  136. }
  137. public override string play_file_name
  138. {
  139. get
  140. {
  141. return this.everyday_event_data_.call_file_name;
  142. }
  143. }
  144. public override AbstractFreeModeItem.ItemType type
  145. {
  146. get
  147. {
  148. if (this.scnerioType == FreeModeItemEveryday.ScnearioType.Story)
  149. {
  150. return AbstractFreeModeItem.ItemType.MainStory;
  151. }
  152. return AbstractFreeModeItem.ItemType.Normal;
  153. }
  154. }
  155. private static void CreateCsvData(FreeModeItemEveryday.ScnearioType type)
  156. {
  157. string fileName = string.Empty;
  158. string fixingFlagText;
  159. if (type == FreeModeItemEveryday.ScnearioType.Nitijyou)
  160. {
  161. fileName = "recollection_normal2.nei";
  162. fixingFlagText = "シーン鑑賞_一般_フラグ_";
  163. }
  164. else
  165. {
  166. if (type != FreeModeItemEveryday.ScnearioType.Story)
  167. {
  168. return;
  169. }
  170. fileName = "recollection_story.nei";
  171. fixingFlagText = "シーン鑑賞_メイン_フラグ_";
  172. }
  173. if (!FreeModeItemEveryday.DataDic.ContainsKey(type))
  174. {
  175. FreeModeItemEveryday.DataDic.Add(type, new FreeModeItemEveryday.ScnerioData(fixingFlagText));
  176. }
  177. if (FreeModeItemEveryday.DataDic[type].everyday_event_data_dic_ != null)
  178. {
  179. return;
  180. }
  181. FreeModeItemEveryday.DataDic[type].everyday_event_data_dic_ = new SortedDictionary<int, FreeModeItemEveryday.EverydayEventData>();
  182. FreeModeItemEveryday.CreateCsvData(type, fileName, AbstractFreeModeItem.GameMode.COM3D);
  183. if (GameUty.IsEnabledCompatibilityMode && type == FreeModeItemEveryday.ScnearioType.Nitijyou)
  184. {
  185. FreeModeItemEveryday.CreateLeagacyDisableIdList();
  186. FreeModeItemEveryday.CreateCsvData(type, fileName, AbstractFreeModeItem.GameMode.CM3D2);
  187. }
  188. }
  189. private static void CreateCsvData(FreeModeItemEveryday.ScnearioType type, string fileName, AbstractFreeModeItem.GameMode gameMode)
  190. {
  191. HashSet<int> hashSet;
  192. AFileBase afileBase;
  193. if (gameMode == AbstractFreeModeItem.GameMode.CM3D2)
  194. {
  195. hashSet = AbstractFreeModeItem.GetEnabledOldIdList();
  196. NDebug.Assert(GameUty.FileSystemOld.IsExistentFile(fileName), fileName + "\nopen failed.");
  197. afileBase = GameUty.FileSystemOld.FileOpen(fileName);
  198. }
  199. else
  200. {
  201. if (gameMode != AbstractFreeModeItem.GameMode.COM3D)
  202. {
  203. return;
  204. }
  205. hashSet = AbstractFreeModeItem.GetEnabledIdList();
  206. NDebug.Assert(GameUty.FileSystem.IsExistentFile(fileName), fileName + "\nopen failed.");
  207. afileBase = GameUty.FileSystem.FileOpen(fileName);
  208. }
  209. if (hashSet == null || hashSet.Count <= 0)
  210. {
  211. return;
  212. }
  213. using (afileBase)
  214. {
  215. using (CsvParser csvParser = new CsvParser())
  216. {
  217. bool condition = csvParser.Open(afileBase);
  218. NDebug.Assert(condition, fileName + "\nopen failed.");
  219. for (int i = 1; i < csvParser.max_cell_y; i++)
  220. {
  221. if (csvParser.IsCellToExistData(0, i))
  222. {
  223. int cellAsInteger = csvParser.GetCellAsInteger(0, i);
  224. if (hashSet.Contains(cellAsInteger))
  225. {
  226. FreeModeItemEveryday.EverydayEventData everydayEventData = new FreeModeItemEveryday.EverydayEventData();
  227. everydayEventData.id = cellAsInteger;
  228. int num = 1;
  229. if (gameMode != AbstractFreeModeItem.GameMode.CM3D2 || type != FreeModeItemEveryday.ScnearioType.Nitijyou || !FreeModeItemEveryday.disableIdList.Contains(everydayEventData.id))
  230. {
  231. everydayEventData.gameMode = gameMode;
  232. everydayEventData.name = csvParser.GetCellAsString(num++, i);
  233. everydayEventData.call_file_name = csvParser.GetCellAsString(num++, i);
  234. everydayEventData.check_flag_name = csvParser.GetCellAsString(num++, i);
  235. if (gameMode == AbstractFreeModeItem.GameMode.COM3D)
  236. {
  237. everydayEventData.netorare = (csvParser.GetCellAsString(num++, i) == "○");
  238. }
  239. everydayEventData.info_text = csvParser.GetCellAsString(num++, i);
  240. List<string> list = new List<string>();
  241. for (int j = 0; j < 9; j++)
  242. {
  243. if (csvParser.IsCellToExistData(num, i))
  244. {
  245. list.Add(csvParser.GetCellAsString(num, i));
  246. }
  247. num++;
  248. }
  249. everydayEventData.subHerionID = csvParser.GetCellAsInteger(num++, i);
  250. while (csvParser.IsCellToExistData(num, 0))
  251. {
  252. if (csvParser.GetCellAsString(num, i) == "○")
  253. {
  254. string cellAsString = csvParser.GetCellAsString(num, 0);
  255. Personal.Data data = Personal.GetData(cellAsString);
  256. everydayEventData.personalIdList.Add(data.id);
  257. }
  258. num++;
  259. }
  260. everydayEventData.condition_texts = list.ToArray();
  261. if (!FreeModeItemEveryday.DataDic[type].everyday_event_data_dic_.ContainsKey(everydayEventData.id))
  262. {
  263. if (!FreeModeItemEveryday.DataDic[type].flag_name_set_.Contains(everydayEventData.check_flag_name))
  264. {
  265. FreeModeItemEveryday.DataDic[type].flag_name_set_.Add(everydayEventData.check_flag_name);
  266. }
  267. FreeModeItemEveryday.DataDic[type].everyday_event_data_dic_.Add(everydayEventData.id, everydayEventData);
  268. }
  269. }
  270. }
  271. }
  272. }
  273. }
  274. }
  275. }
  276. private static void CreateLeagacyDisableIdList()
  277. {
  278. AFileBase afileBase = GameUty.FileSystem.FileOpen("recollection_legacy_disable.nei");
  279. using (afileBase)
  280. {
  281. using (CsvParser csvParser = new CsvParser())
  282. {
  283. bool flag = csvParser.Open(afileBase);
  284. FreeModeItemEveryday.disableIdList = new List<int>();
  285. int max_cell_y = csvParser.max_cell_y;
  286. for (int i = 1; i < max_cell_y; i++)
  287. {
  288. FreeModeItemEveryday.disableIdList.Add(csvParser.GetCellAsInteger(0, i));
  289. }
  290. }
  291. }
  292. }
  293. private static Dictionary<FreeModeItemEveryday.ScnearioType, FreeModeItemEveryday.ScnerioData> DataDic = new Dictionary<FreeModeItemEveryday.ScnearioType, FreeModeItemEveryday.ScnerioData>();
  294. private static List<int> disableIdList = new List<int>();
  295. private bool is_enabled_;
  296. private int item_id_;
  297. private FreeModeItemEveryday.EverydayEventData everyday_event_data_;
  298. private FreeModeItemEveryday.ScnearioType scnerioType;
  299. public enum ScnearioType
  300. {
  301. Story,
  302. Nitijyou
  303. }
  304. private class ScnerioData
  305. {
  306. public ScnerioData(string FixingFlagText)
  307. {
  308. this.FixingFlagText = FixingFlagText;
  309. }
  310. public SortedDictionary<int, FreeModeItemEveryday.EverydayEventData> everyday_event_data_dic_;
  311. public HashSet<string> flag_name_set_ = new HashSet<string>();
  312. public string FixingFlagText = "シーン鑑賞_一般_フラグ_";
  313. }
  314. private class EverydayEventData
  315. {
  316. public AbstractFreeModeItem.GameMode gameMode;
  317. public int id;
  318. public string name;
  319. public string call_file_name;
  320. public string check_flag_name;
  321. public string info_text;
  322. public bool netorare;
  323. public int subHerionID;
  324. public string[] condition_texts;
  325. public List<int> personalIdList = new List<int>();
  326. }
  327. }