EmpireLifeModeAPI.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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. list.Add(maid);
  124. }
  125. }
  126. }
  127. }
  128. return list;
  129. }
  130. public static List<string> GetEnabledPersonalListOfRecollection()
  131. {
  132. List<string> list = new List<string>();
  133. foreach (Personal.Data data in Personal.GetAllDatas(true))
  134. {
  135. string uniqueName = data.uniqueName;
  136. if (data.oldPersonal)
  137. {
  138. if (uniqueName == "Pure" || uniqueName == "Cool" || uniqueName == "Pride")
  139. {
  140. if (GameMain.Instance.CharacterMgr.status.isAvailableTransfer)
  141. {
  142. list.Add(uniqueName);
  143. }
  144. }
  145. else if (data.single)
  146. {
  147. list.Add(uniqueName);
  148. }
  149. else if (!string.IsNullOrEmpty(GameMain.Instance.CMSystem.CM3D2Path) && data.compatible)
  150. {
  151. list.Add(uniqueName);
  152. }
  153. }
  154. else
  155. {
  156. list.Add(uniqueName);
  157. }
  158. }
  159. return list;
  160. }
  161. public static int GetPriorityScenarioType(this EmpireLifeModeData.Data data)
  162. {
  163. return EmpireLifeModeAPI.GetPriorityScenarioType(data.dataScenarioType);
  164. }
  165. public static List<Maid> GetCorrectMaidList(this EmpireLifeModeData.Data data, IEnumerable<Maid> maidList)
  166. {
  167. List<Maid> list = new List<Maid>();
  168. foreach (Maid maid in maidList)
  169. {
  170. if (data.IsCorrectMaid(maid))
  171. {
  172. list.Add(maid);
  173. }
  174. }
  175. return list;
  176. }
  177. public static List<Facility> GetCorrectFacilityList(this EmpireLifeModeData.Data data)
  178. {
  179. List<Facility> list = new List<Facility>();
  180. foreach (Facility facility in EmpireLifeModeAPI.GetEnabledFacilityList())
  181. {
  182. foreach (string b in data.dataFacilityUniqueNameArray)
  183. {
  184. if (facility.defaultData.name == b)
  185. {
  186. list.Add(facility);
  187. break;
  188. }
  189. }
  190. }
  191. return list;
  192. }
  193. public static bool IsCorrectMaid(this EmpireLifeModeData.Data data, Maid maid)
  194. {
  195. 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);
  196. }
  197. public static bool IsCorrectUniqueComparisonObject(this EmpireLifeModeData.Data data)
  198. {
  199. return data.IsCorrectNTRBlock() && data.IsCorrectTimeZone() && data.IsCorrectPlayerFlag() && data.IsCorrectScenarioAnyNumberPlay() && data.IsCorrectPersonalGP002();
  200. }
  201. public static bool IsCorrectScenarioType(this EmpireLifeModeData.Data data, EmpireLifeModeData.ScenarioType scenarioType)
  202. {
  203. return data.dataScenarioType == scenarioType;
  204. }
  205. public static bool IsCorrectScenarioAnyNumberPlay(this EmpireLifeModeData.Data data)
  206. {
  207. return data.dataScenarioAnyNumberPlay || 0 >= GameMain.Instance.LifeModeMgr.GetScenarioExecuteCount(data.ID);
  208. }
  209. public static bool IsCorrectNTRBlock(this EmpireLifeModeData.Data data)
  210. {
  211. return data.IsCorrectNTRBlock(GameMain.Instance.CharacterMgr.status.lockNTRPlay);
  212. }
  213. public static bool IsCorrectNTRBlock(this EmpireLifeModeData.Data data, bool NowNTRBlockingFlag)
  214. {
  215. if (data.dataNTRBlock == null)
  216. {
  217. return true;
  218. }
  219. if (NowNTRBlockingFlag)
  220. {
  221. return data.dataNTRBlock.Value;
  222. }
  223. return !data.dataNTRBlock.Value;
  224. }
  225. public static bool IsCorrectFacility(this EmpireLifeModeData.Data data, string facilityUniqueName)
  226. {
  227. foreach (string a in data.dataFacilityUniqueNameArray)
  228. {
  229. if (a == facilityUniqueName)
  230. {
  231. return true;
  232. }
  233. }
  234. return false;
  235. }
  236. public static bool IsCorrectTimeZone(this EmpireLifeModeData.Data data)
  237. {
  238. if (data.dataTimeZone == null)
  239. {
  240. return true;
  241. }
  242. ScheduleMgr.ScheduleTime nowTimeZone = (!GameMain.Instance.CharacterMgr.status.isDaytime) ? ScheduleMgr.ScheduleTime.Night : ScheduleMgr.ScheduleTime.DayTime;
  243. return data.IsCorrectTimeZone(nowTimeZone);
  244. }
  245. public static bool IsCorrectTimeZone(this EmpireLifeModeData.Data data, ScheduleMgr.ScheduleTime nowTimeZone)
  246. {
  247. return data.dataTimeZone == null || nowTimeZone == data.dataTimeZone.Value;
  248. }
  249. public static bool IsCorrectPlayerFlag(this EmpireLifeModeData.Data data)
  250. {
  251. if (data.dataFlagPlayer == null)
  252. {
  253. return true;
  254. }
  255. foreach (KeyValuePair<string, int> keyValuePair in data.dataFlagPlayer)
  256. {
  257. if (GameMain.Instance.CharacterMgr.status.GetFlag(keyValuePair.Key) != keyValuePair.Value)
  258. {
  259. return false;
  260. }
  261. }
  262. return true;
  263. }
  264. public static bool IsCorrectPersonalGP002(this EmpireLifeModeData.Data data)
  265. {
  266. return data.IsEnableGP002PersonalCheck;
  267. }
  268. public static bool IsCorrectMaidFlag(this EmpireLifeModeData.Data data, Maid maid)
  269. {
  270. if (data.dataFlagMaid == null)
  271. {
  272. return true;
  273. }
  274. foreach (KeyValuePair<string, int> keyValuePair in data.dataFlagMaid)
  275. {
  276. if (maid.status.GetFlag(keyValuePair.Key) != keyValuePair.Value)
  277. {
  278. return false;
  279. }
  280. }
  281. return true;
  282. }
  283. public static bool IsCorrectMaidPersonalType(this EmpireLifeModeData.Data data, Maid maid)
  284. {
  285. foreach (KeyValuePair<int, string> keyValuePair in data.dataMaidPersonalUniqueNameAndActiveSlotDic)
  286. {
  287. string value = keyValuePair.Value;
  288. if (value == maid.status.personal.uniqueName)
  289. {
  290. return true;
  291. }
  292. }
  293. return false;
  294. }
  295. public static bool IsCorrectMaidMainCharaOnly(this EmpireLifeModeData.Data data, Maid maid)
  296. {
  297. return data.dataMaidMainCharaOnly == null || maid.status.mainChara == data.dataMaidMainCharaOnly;
  298. }
  299. public static bool IsCorrectMaidContract(this EmpireLifeModeData.Data data, Maid maid)
  300. {
  301. return data.IsCorrectContract(maid.status.contract);
  302. }
  303. public static bool IsCorrectContract(this EmpireLifeModeData.Data data, Contract contract)
  304. {
  305. return data.dataMaidContract == null || data.dataMaidContract == contract;
  306. }
  307. public static bool IsCorrectMaidRelation(this EmpireLifeModeData.Data data, Maid maid)
  308. {
  309. return data.IsCorrectRelation(maid.status.relation);
  310. }
  311. public static bool IsCorrectRelation(this EmpireLifeModeData.Data data, Relation relation)
  312. {
  313. return data.dataMaidRelation == null || data.dataMaidRelation == relation;
  314. }
  315. public static bool IsCorrectMaidStatus(this EmpireLifeModeData.Data data, Maid maid)
  316. {
  317. return data.dataMaidStatus == null || data.dataMaidStatus.GreaterThanOrEqualToStatus(maid.status);
  318. }
  319. public static bool IsCorrectMaidSeikeiken(this EmpireLifeModeData.Data data, Maid maid)
  320. {
  321. if (data.dataMaidSeikeiken == null)
  322. {
  323. return true;
  324. }
  325. foreach (Seikeiken seikeiken in data.dataMaidSeikeiken)
  326. {
  327. if (seikeiken == maid.status.seikeiken)
  328. {
  329. return true;
  330. }
  331. }
  332. return false;
  333. }
  334. public static bool IsCorrectMaidExecuteCount(this EmpireLifeModeData.Data data, Maid maid)
  335. {
  336. if (data.dataScenarioType != EmpireLifeModeData.ScenarioType.一般)
  337. {
  338. return true;
  339. }
  340. int maidScenarioExecuteCount = GameMain.Instance.LifeModeMgr.GetMaidScenarioExecuteCount(data.ID, maid);
  341. return maidScenarioExecuteCount <= 0;
  342. }
  343. private static ReadOnlyDictionary<EmpireLifeModeData.ScenarioType, int> m_ScenarioTypePriorityDic = new ReadOnlyDictionary<EmpireLifeModeData.ScenarioType, int>(new Dictionary<EmpireLifeModeData.ScenarioType, int>
  344. {
  345. {
  346. EmpireLifeModeData.ScenarioType.スト\u30FCリ\u30FC,
  347. 4
  348. },
  349. {
  350. EmpireLifeModeData.ScenarioType.一般,
  351. 3
  352. },
  353. {
  354. EmpireLifeModeData.ScenarioType.Hシ\u30FCン,
  355. 2
  356. },
  357. {
  358. EmpireLifeModeData.ScenarioType.セクハラ,
  359. 2
  360. },
  361. {
  362. EmpireLifeModeData.ScenarioType.汎用,
  363. 1
  364. }
  365. });
  366. private static Dictionary<EmpireLifeModeData.ScenarioType, Texture2D> m_ScenarioTypeIconDic = null;
  367. private static List<string> m_EnabledFacilityUniqueNameList;
  368. }