EmpireLifeModeAPI.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. using System;
  2. using System.Collections.Generic;
  3. using MaidStatus;
  4. using UnityEngine;
  5. using wf;
  6. public static class EmpireLifeModeAPI
  7. {
  8. public static int GetPriorityScenarioType(EmpireLifeModeData.ScenarioType scenarioType)
  9. {
  10. return EmpireLifeModeAPI.m_ScenarioTypePriorityDic[scenarioType];
  11. }
  12. private static void CreateScenarioTypeIconDic()
  13. {
  14. if (EmpireLifeModeAPI.m_ScenarioTypeIconDic != null && EmpireLifeModeAPI.m_ScenarioTypeIconDic.Count > 0)
  15. {
  16. return;
  17. }
  18. EmpireLifeModeAPI.m_ScenarioTypeIconDic = new Dictionary<EmpireLifeModeData.ScenarioType, Texture2D>();
  19. Func<string, Texture2D> func = delegate(string strFileName)
  20. {
  21. if (!string.IsNullOrEmpty(strFileName) && GameUty.FileSystem.IsExistentFile(strFileName + ".tex"))
  22. {
  23. return ImportCM.CreateTexture(strFileName + ".tex");
  24. }
  25. return null;
  26. };
  27. EmpireLifeModeAPI.m_ScenarioTypeIconDic.Add(EmpireLifeModeData.ScenarioType.一般, func("life_icon02_exclamation"));
  28. EmpireLifeModeAPI.m_ScenarioTypeIconDic.Add(EmpireLifeModeData.ScenarioType.汎用, null);
  29. EmpireLifeModeAPI.m_ScenarioTypeIconDic.Add(EmpireLifeModeData.ScenarioType.スト\u30FCリ\u30FC, func("life_icon01_ster"));
  30. EmpireLifeModeAPI.m_ScenarioTypeIconDic.Add(EmpireLifeModeData.ScenarioType.Hシ\u30FCン, func("life_icon03_heart"));
  31. EmpireLifeModeAPI.m_ScenarioTypeIconDic.Add(EmpireLifeModeData.ScenarioType.セクハラ, func("life_icon03_heart"));
  32. }
  33. public static Texture2D GetIconScenarioType(EmpireLifeModeData.ScenarioType scenarioType)
  34. {
  35. EmpireLifeModeAPI.CreateScenarioTypeIconDic();
  36. return EmpireLifeModeAPI.m_ScenarioTypeIconDic[scenarioType];
  37. }
  38. public static void DestroyScenarioTypeIconDic()
  39. {
  40. if (EmpireLifeModeAPI.m_ScenarioTypeIconDic == null)
  41. {
  42. return;
  43. }
  44. Dictionary<EmpireLifeModeData.ScenarioType, Texture2D>.ValueCollection values = EmpireLifeModeAPI.m_ScenarioTypeIconDic.Values;
  45. using (Dictionary<EmpireLifeModeData.ScenarioType, Texture2D>.ValueCollection.Enumerator enumerator = values.GetEnumerator())
  46. {
  47. while (enumerator.MoveNext())
  48. {
  49. if (enumerator.Current != null)
  50. {
  51. UnityEngine.Object.DestroyImmediate(enumerator.Current);
  52. }
  53. }
  54. }
  55. EmpireLifeModeAPI.m_ScenarioTypeIconDic.Clear();
  56. }
  57. public static List<string> GetEnabledFacilityUniqueNameList()
  58. {
  59. if (EmpireLifeModeAPI.m_EnabledFacilityUniqueNameList == null || EmpireLifeModeAPI.m_EnabledFacilityUniqueNameList.Count <= 0)
  60. {
  61. EmpireLifeModeAPI.m_EnabledFacilityUniqueNameList = new List<string>();
  62. foreach (EmpireLifeModeData.Data data in EmpireLifeModeData.GetAllDatas(true))
  63. {
  64. if (data.IsCorrectPersonalGP002())
  65. {
  66. foreach (string item in data.dataFacilityUniqueNameArray)
  67. {
  68. if (!EmpireLifeModeAPI.m_EnabledFacilityUniqueNameList.Contains(item))
  69. {
  70. EmpireLifeModeAPI.m_EnabledFacilityUniqueNameList.Add(item);
  71. }
  72. }
  73. }
  74. }
  75. }
  76. return new List<string>(EmpireLifeModeAPI.m_EnabledFacilityUniqueNameList);
  77. }
  78. public static List<Facility> GetEnabledFacilityList()
  79. {
  80. List<string> enabledFacilityUniqueNameList = EmpireLifeModeAPI.GetEnabledFacilityUniqueNameList();
  81. List<Facility> list = new List<Facility>();
  82. foreach (Facility facility in GameMain.Instance.FacilityMgr.GetFacilityArray())
  83. {
  84. if (!(facility == null))
  85. {
  86. if (enabledFacilityUniqueNameList.Contains(facility.defaultData.name))
  87. {
  88. list.Add(facility);
  89. }
  90. }
  91. }
  92. return list;
  93. }
  94. public static int GetMaxMaidCount()
  95. {
  96. int num = 0;
  97. int num2 = 0;
  98. foreach (Facility facility in EmpireLifeModeAPI.GetEnabledFacilityList())
  99. {
  100. FacilityDataTable.FacilityDefaultData defaultData = facility.defaultData;
  101. if (defaultData.isDefaultPlace)
  102. {
  103. num++;
  104. }
  105. else
  106. {
  107. num2++;
  108. }
  109. }
  110. return num * 2 + num2 + 2 * (num2 / 5) + 2 * (num2 / 10) + num2 / 10;
  111. }
  112. public static List<Maid> SelectionMaidList(IEnumerable<Maid> maidList)
  113. {
  114. List<Maid> list = new List<Maid>();
  115. foreach (Maid maid in maidList)
  116. {
  117. if (!(maid == null))
  118. {
  119. if (maid.status.heroineType != HeroineType.Sub)
  120. {
  121. if (EmpireLifeModeData.Data.personalUniqueNameEnabledList.Contains(maid.status.personal.uniqueName))
  122. {
  123. if (PersonalEventBlocker.IsEnabledLifeMode(maid.status.personal))
  124. {
  125. list.Add(maid);
  126. }
  127. }
  128. }
  129. }
  130. }
  131. return list;
  132. }
  133. public static List<string> GetEnabledPersonalListOfRecollection()
  134. {
  135. List<string> list = new List<string>();
  136. foreach (Personal.Data data in Personal.GetAllDatas(true))
  137. {
  138. string uniqueName = data.uniqueName;
  139. if (data.oldPersonal)
  140. {
  141. if (uniqueName == "Pure" || uniqueName == "Cool" || uniqueName == "Pride")
  142. {
  143. if (GameMain.Instance.CharacterMgr.status.isAvailableTransfer)
  144. {
  145. list.Add(uniqueName);
  146. }
  147. }
  148. else if (data.single)
  149. {
  150. list.Add(uniqueName);
  151. }
  152. else if (!string.IsNullOrEmpty(GameMain.Instance.CMSystem.CM3D2Path) && data.compatible)
  153. {
  154. list.Add(uniqueName);
  155. }
  156. }
  157. else
  158. {
  159. list.Add(uniqueName);
  160. }
  161. }
  162. return list;
  163. }
  164. public static int GetPriorityScenarioType(this EmpireLifeModeData.Data data)
  165. {
  166. return EmpireLifeModeAPI.GetPriorityScenarioType(data.dataScenarioType);
  167. }
  168. public static List<Maid> GetCorrectMaidList(this EmpireLifeModeData.Data data, IEnumerable<Maid> maidList)
  169. {
  170. List<Maid> list = new List<Maid>();
  171. foreach (Maid maid in maidList)
  172. {
  173. if (data.IsCorrectMaid(maid))
  174. {
  175. list.Add(maid);
  176. }
  177. }
  178. return list;
  179. }
  180. public static List<Facility> GetCorrectFacilityList(this EmpireLifeModeData.Data data)
  181. {
  182. List<Facility> list = new List<Facility>();
  183. foreach (Facility facility in EmpireLifeModeAPI.GetEnabledFacilityList())
  184. {
  185. foreach (string b in data.dataFacilityUniqueNameArray)
  186. {
  187. if (facility.defaultData.name == b)
  188. {
  189. list.Add(facility);
  190. break;
  191. }
  192. }
  193. }
  194. return list;
  195. }
  196. public static bool IsCorrectMaid(this EmpireLifeModeData.Data data, Maid maid)
  197. {
  198. return data.IsCorrectMaidMainCharaOnly(maid) && data.IsCorrectMaidSeikeiken(maid) && data.IsCorrectMaidPersonalType(maid) && data.IsCorrectMaidFlag(maid) && data.IsCorrectMaidStatus(maid) && data.IsCorrectMaidExecuteCount(maid) && data.IsCorrectMaidContract(maid) && data.IsCorrectMaidRelation(maid);
  199. }
  200. public static bool IsCorrectUniqueComparisonObject(this EmpireLifeModeData.Data data)
  201. {
  202. return data.IsCorrectNTRBlock() && data.IsCorrectTimeZone() && data.IsCorrectPlayerFlag() && data.IsCorrectScenarioAnyNumberPlay() && data.IsCorrectPersonalGP002();
  203. }
  204. public static bool IsCorrectScenarioType(this EmpireLifeModeData.Data data, EmpireLifeModeData.ScenarioType scenarioType)
  205. {
  206. return data.dataScenarioType == scenarioType;
  207. }
  208. public static bool IsCorrectScenarioAnyNumberPlay(this EmpireLifeModeData.Data data)
  209. {
  210. return data.dataScenarioAnyNumberPlay || 0 >= GameMain.Instance.LifeModeMgr.GetScenarioExecuteCount(data.ID);
  211. }
  212. public static bool IsCorrectNTRBlock(this EmpireLifeModeData.Data data)
  213. {
  214. return data.IsCorrectNTRBlock(GameMain.Instance.CharacterMgr.status.lockNTRPlay);
  215. }
  216. public static bool IsCorrectNTRBlock(this EmpireLifeModeData.Data data, bool NowNTRBlockingFlag)
  217. {
  218. if (data.dataNTRBlock == null)
  219. {
  220. return true;
  221. }
  222. if (NowNTRBlockingFlag)
  223. {
  224. return data.dataNTRBlock.Value;
  225. }
  226. return !data.dataNTRBlock.Value;
  227. }
  228. public static bool IsCorrectFacility(this EmpireLifeModeData.Data data, string facilityUniqueName)
  229. {
  230. foreach (string a in data.dataFacilityUniqueNameArray)
  231. {
  232. if (a == facilityUniqueName)
  233. {
  234. return true;
  235. }
  236. }
  237. return false;
  238. }
  239. public static bool IsCorrectTimeZone(this EmpireLifeModeData.Data data)
  240. {
  241. if (data.dataTimeZone == null)
  242. {
  243. return true;
  244. }
  245. ScheduleMgr.ScheduleTime nowTimeZone = (!GameMain.Instance.CharacterMgr.status.isDaytime) ? ScheduleMgr.ScheduleTime.Night : ScheduleMgr.ScheduleTime.DayTime;
  246. return data.IsCorrectTimeZone(nowTimeZone);
  247. }
  248. public static bool IsCorrectTimeZone(this EmpireLifeModeData.Data data, ScheduleMgr.ScheduleTime nowTimeZone)
  249. {
  250. return data.dataTimeZone == null || nowTimeZone == data.dataTimeZone.Value;
  251. }
  252. public static bool IsCorrectPlayerFlag(this EmpireLifeModeData.Data data)
  253. {
  254. if (data.dataFlagPlayer == null)
  255. {
  256. return true;
  257. }
  258. foreach (KeyValuePair<string, int> keyValuePair in data.dataFlagPlayer)
  259. {
  260. if (GameMain.Instance.CharacterMgr.status.GetFlag(keyValuePair.Key) != keyValuePair.Value)
  261. {
  262. return false;
  263. }
  264. }
  265. return true;
  266. }
  267. public static bool IsCorrectPersonalGP002(this EmpireLifeModeData.Data data)
  268. {
  269. return data.IsEnableGP002PersonalCheck;
  270. }
  271. public static bool IsCorrectMaidFlag(this EmpireLifeModeData.Data data, Maid maid)
  272. {
  273. if (data.dataFlagMaid == null)
  274. {
  275. return true;
  276. }
  277. foreach (KeyValuePair<string, int> keyValuePair in data.dataFlagMaid)
  278. {
  279. if (maid.status.GetFlag(keyValuePair.Key) != keyValuePair.Value)
  280. {
  281. return false;
  282. }
  283. }
  284. return true;
  285. }
  286. public static bool IsCorrectMaidPersonalType(this EmpireLifeModeData.Data data, Maid maid)
  287. {
  288. foreach (KeyValuePair<int, string> keyValuePair in data.dataMaidPersonalUniqueNameAndActiveSlotDic)
  289. {
  290. string value = keyValuePair.Value;
  291. if (value == maid.status.personal.uniqueName)
  292. {
  293. return true;
  294. }
  295. }
  296. return false;
  297. }
  298. public static bool IsCorrectMaidMainCharaOnly(this EmpireLifeModeData.Data data, Maid maid)
  299. {
  300. return data.dataMaidMainCharaOnly == null || maid.status.mainChara == data.dataMaidMainCharaOnly;
  301. }
  302. public static bool IsCorrectMaidContract(this EmpireLifeModeData.Data data, Maid maid)
  303. {
  304. return data.IsCorrectContract(maid.status.contract);
  305. }
  306. public static bool IsCorrectContract(this EmpireLifeModeData.Data data, Contract contract)
  307. {
  308. return data.dataMaidContract == null || data.dataMaidContract == contract;
  309. }
  310. public static bool IsCorrectMaidRelation(this EmpireLifeModeData.Data data, Maid maid)
  311. {
  312. return data.IsCorrectRelation(maid.status.relation);
  313. }
  314. public static bool IsCorrectRelation(this EmpireLifeModeData.Data data, Relation relation)
  315. {
  316. return data.dataMaidRelation == null || data.dataMaidRelation == relation;
  317. }
  318. public static bool IsCorrectMaidStatus(this EmpireLifeModeData.Data data, Maid maid)
  319. {
  320. return data.dataMaidStatus == null || data.dataMaidStatus.GreaterThanOrEqualToStatus(maid.status);
  321. }
  322. public static bool IsCorrectMaidSeikeiken(this EmpireLifeModeData.Data data, Maid maid)
  323. {
  324. if (data.dataMaidSeikeiken == null)
  325. {
  326. return true;
  327. }
  328. foreach (Seikeiken seikeiken in data.dataMaidSeikeiken)
  329. {
  330. if (seikeiken == maid.status.seikeiken)
  331. {
  332. return true;
  333. }
  334. }
  335. return false;
  336. }
  337. public static bool IsCorrectMaidExecuteCount(this EmpireLifeModeData.Data data, Maid maid)
  338. {
  339. if (data.dataScenarioType != EmpireLifeModeData.ScenarioType.一般)
  340. {
  341. return true;
  342. }
  343. int maidScenarioExecuteCount = GameMain.Instance.LifeModeMgr.GetMaidScenarioExecuteCount(data.ID, maid);
  344. return maidScenarioExecuteCount <= 0;
  345. }
  346. private static ReadOnlyDictionary<EmpireLifeModeData.ScenarioType, int> m_ScenarioTypePriorityDic = new ReadOnlyDictionary<EmpireLifeModeData.ScenarioType, int>(new Dictionary<EmpireLifeModeData.ScenarioType, int>
  347. {
  348. {
  349. EmpireLifeModeData.ScenarioType.スト\u30FCリ\u30FC,
  350. 4
  351. },
  352. {
  353. EmpireLifeModeData.ScenarioType.一般,
  354. 3
  355. },
  356. {
  357. EmpireLifeModeData.ScenarioType.Hシ\u30FCン,
  358. 2
  359. },
  360. {
  361. EmpireLifeModeData.ScenarioType.セクハラ,
  362. 2
  363. },
  364. {
  365. EmpireLifeModeData.ScenarioType.汎用,
  366. 1
  367. }
  368. });
  369. private static Dictionary<EmpireLifeModeData.ScenarioType, Texture2D> m_ScenarioTypeIconDic = null;
  370. private static List<string> m_EnabledFacilityUniqueNameList;
  371. }