EmpireLifeModeAPI.cs 10 KB

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