EmpireLifeModeAPI.cs 11 KB

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