MaidCostumeChangeController.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. namespace MaidExtension
  6. {
  7. public class MaidCostumeChangeController
  8. {
  9. public MaidCostumeChangeController(Maid maid)
  10. {
  11. this.manager = new MaidCostumeChangeController.MaidCostumeChangeManager(maid);
  12. }
  13. public Maid maid
  14. {
  15. get
  16. {
  17. return this.manager.maid;
  18. }
  19. set
  20. {
  21. this.manager.maid = value;
  22. }
  23. }
  24. public MaidCostumeChangeController.MaidCostumeChangeManager manager { get; private set; }
  25. public bool IsSupportedCostumeType(MaidCostumeChangeController.CostumeType type)
  26. {
  27. switch (type)
  28. {
  29. case MaidCostumeChangeController.CostumeType.MekureFront:
  30. return this.manager.IsSupportedCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.MekureFront);
  31. case MaidCostumeChangeController.CostumeType.MekureBack:
  32. return this.manager.IsSupportedCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.MekureBack);
  33. case MaidCostumeChangeController.CostumeType.Zurasi:
  34. return this.manager.IsSupportedCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.Zurasi);
  35. case MaidCostumeChangeController.CostumeType.Hadake:
  36. return this.manager.IsSupportedCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.Hadake);
  37. default:
  38. return false;
  39. }
  40. }
  41. public void SetEnabledCostumeType(MaidCostumeChangeController.CostumeType type, bool enabled, string targetMpnName = null)
  42. {
  43. this.SetEnabledCostumeType(new MaidCostumeChangeController.CostumeType[]
  44. {
  45. type
  46. }, enabled, targetMpnName);
  47. }
  48. public void SetEnabledCostumeType(MaidCostumeChangeController.CostumeType[] types, bool enabled, string targetMpnName = null)
  49. {
  50. if (this.maid == null)
  51. {
  52. Debug.LogWarning("MaidCostumeChangeController::SetEnabledCostumeType\n maid is null.");
  53. return;
  54. }
  55. if (types == null || types.Length == 0)
  56. {
  57. return;
  58. }
  59. HashSet<MaidCostumeChangeController.CostumeType> hashSet = new HashSet<MaidCostumeChangeController.CostumeType>();
  60. foreach (MaidCostumeChangeController.CostumeType item in types)
  61. {
  62. hashSet.Add(item);
  63. }
  64. if (enabled && hashSet.Contains(MaidCostumeChangeController.CostumeType.MekureFront) && hashSet.Contains(MaidCostumeChangeController.CostumeType.MekureBack))
  65. {
  66. hashSet.Remove(MaidCostumeChangeController.CostumeType.MekureBack);
  67. }
  68. bool flag = (!hashSet.Contains(MaidCostumeChangeController.CostumeType.Hadake)) ? this.IsEnabledCostumeType(MaidCostumeChangeController.CostumeType.Hadake) : enabled;
  69. bool flag2 = (!hashSet.Contains(MaidCostumeChangeController.CostumeType.MekureFront)) ? this.IsEnabledCostumeType(MaidCostumeChangeController.CostumeType.MekureFront) : enabled;
  70. bool flag3 = (!hashSet.Contains(MaidCostumeChangeController.CostumeType.MekureBack)) ? this.IsEnabledCostumeType(MaidCostumeChangeController.CostumeType.MekureBack) : enabled;
  71. bool flag4 = (!hashSet.Contains(MaidCostumeChangeController.CostumeType.Zurasi)) ? this.IsEnabledCostumeType(MaidCostumeChangeController.CostumeType.Zurasi) : enabled;
  72. if (flag2 && flag3)
  73. {
  74. if (hashSet.Contains(MaidCostumeChangeController.CostumeType.MekureFront))
  75. {
  76. flag3 = !enabled;
  77. }
  78. else
  79. {
  80. flag2 = !enabled;
  81. }
  82. }
  83. this.Reset(targetMpnName);
  84. bool flag5 = false;
  85. if (flag)
  86. {
  87. flag5 |= this.manager.SetEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.Hadake, true, false);
  88. }
  89. if (flag2)
  90. {
  91. flag5 |= this.manager.SetEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.MekureFront, true, false);
  92. if (flag)
  93. {
  94. flag5 |= this.manager.SetEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.HadakeAndMekureFront, true, false);
  95. }
  96. }
  97. if (flag3)
  98. {
  99. flag5 |= this.manager.SetEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.MekureBack, true, false);
  100. if (flag)
  101. {
  102. flag5 |= this.manager.SetEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.HadakeAndMekureBack, true, false);
  103. }
  104. }
  105. if (flag4)
  106. {
  107. flag5 |= this.manager.SetEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.Zurasi, true, false);
  108. if (flag)
  109. {
  110. flag5 |= this.manager.SetEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.HadakeAndZurasi, true, false);
  111. }
  112. }
  113. if (flag5)
  114. {
  115. this.maid.AllProcProp();
  116. }
  117. }
  118. public bool IsEnabledCostumeType(MaidCostumeChangeController.CostumeType type)
  119. {
  120. switch (type)
  121. {
  122. case MaidCostumeChangeController.CostumeType.MekureFront:
  123. return this.manager.IsEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.MekureFront) || this.manager.IsEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.HadakeAndMekureFront);
  124. case MaidCostumeChangeController.CostumeType.MekureBack:
  125. return this.manager.IsEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.MekureBack) || this.manager.IsEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.HadakeAndMekureBack);
  126. case MaidCostumeChangeController.CostumeType.Zurasi:
  127. return this.manager.IsEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.Zurasi) || this.manager.IsEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.HadakeAndZurasi);
  128. case MaidCostumeChangeController.CostumeType.Hadake:
  129. return this.manager.IsEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.Hadake) || this.manager.IsEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.HadakeAndMekureFront) || this.manager.IsEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.HadakeAndMekureBack) || this.manager.IsEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.HadakeAndZurasi);
  130. default:
  131. return false;
  132. }
  133. }
  134. public void Reset(string targetMpnName = null)
  135. {
  136. this.manager.Reset(targetMpnName);
  137. }
  138. public class MaidCostumeChangeManager
  139. {
  140. public MaidCostumeChangeManager(Maid maid)
  141. {
  142. this.maid = maid;
  143. }
  144. public static string[] GetTargetMpnNames(Maid maid, MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType type)
  145. {
  146. if (maid == null)
  147. {
  148. Debug.LogWarning("MaidCostumeChangeManager::GetTargetMpnNames\n maid is null.");
  149. return new string[0];
  150. }
  151. switch (type)
  152. {
  153. case MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.MekureFront:
  154. case MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.MekureBack:
  155. return new string[]
  156. {
  157. "skirt",
  158. "onepiece"
  159. };
  160. case MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.Zurasi:
  161. {
  162. string[] result;
  163. if (maid.IsCrcBody)
  164. {
  165. string[] array = new string[4];
  166. array[0] = "mizugi_buttom";
  167. array[1] = "mizugi";
  168. array[2] = "panz";
  169. result = array;
  170. array[3] = "slip";
  171. }
  172. else
  173. {
  174. string[] array2 = new string[2];
  175. array2[0] = "panz";
  176. result = array2;
  177. array2[1] = "mizugi";
  178. }
  179. return result;
  180. }
  181. case MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.Hadake:
  182. {
  183. string[] result2;
  184. if (maid.IsCrcBody)
  185. {
  186. string[] array3 = new string[6];
  187. array3[0] = "wear";
  188. array3[1] = "onepiece";
  189. array3[2] = "mizugi_top";
  190. array3[3] = "mizugi";
  191. array3[4] = "bra";
  192. result2 = array3;
  193. array3[5] = "slip";
  194. }
  195. else
  196. {
  197. result2 = new string[0];
  198. }
  199. return result2;
  200. }
  201. case MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.HadakeAndMekureFront:
  202. case MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.HadakeAndMekureBack:
  203. {
  204. string[] result3;
  205. if (maid.IsCrcBody)
  206. {
  207. (result3 = new string[1])[0] = "onepiece";
  208. }
  209. else
  210. {
  211. result3 = new string[0];
  212. }
  213. return result3;
  214. }
  215. case MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.HadakeAndZurasi:
  216. {
  217. string[] result4;
  218. if (maid.IsCrcBody)
  219. {
  220. (result4 = new string[1])[0] = "mizugi";
  221. }
  222. else
  223. {
  224. result4 = new string[0];
  225. }
  226. return result4;
  227. }
  228. default:
  229. return new string[0];
  230. }
  231. }
  232. public static string GetItemChangeNames(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType type)
  233. {
  234. switch (type)
  235. {
  236. case MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.MekureFront:
  237. return "めくれスカート";
  238. case MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.MekureBack:
  239. return "めくれスカート後ろ";
  240. case MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.Zurasi:
  241. return "パンツずらし";
  242. case MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.Hadake:
  243. return "はだけ";
  244. case MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.HadakeAndMekureFront:
  245. return "めくれスカートはだけ";
  246. case MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.HadakeAndMekureBack:
  247. return "めくれスカート後ろはだけ";
  248. case MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType.HadakeAndZurasi:
  249. return "パンツずらしはだけ";
  250. default:
  251. return string.Empty;
  252. }
  253. }
  254. public bool IsSupportedCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType type)
  255. {
  256. if (this.maid == null)
  257. {
  258. Debug.LogWarning("MaidCostumeChangeManager::IsSupportedCostumeType\n maid is null.");
  259. return false;
  260. }
  261. if (Product.isPublic)
  262. {
  263. return false;
  264. }
  265. string itemChangeNames = MaidCostumeChangeController.MaidCostumeChangeManager.GetItemChangeNames(type);
  266. foreach (string mpn in MaidCostumeChangeController.MaidCostumeChangeManager.GetTargetMpnNames(this.maid, type))
  267. {
  268. if (this.maid.IsItemChangeEnabled(mpn, itemChangeNames))
  269. {
  270. return true;
  271. }
  272. }
  273. return false;
  274. }
  275. public bool SetEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType type, bool enabled, bool runAllProcProp = true)
  276. {
  277. if (this.maid == null)
  278. {
  279. Debug.LogWarning("MaidCostumeChangeManager::SetEnabledCostumeType\n maid is null.");
  280. return false;
  281. }
  282. bool flag = false;
  283. string[] targetMpnNames = MaidCostumeChangeController.MaidCostumeChangeManager.GetTargetMpnNames(this.maid, type);
  284. if (enabled)
  285. {
  286. string itemChangeNames = MaidCostumeChangeController.MaidCostumeChangeManager.GetItemChangeNames(type);
  287. foreach (string mpn in targetMpnNames)
  288. {
  289. if (this.maid.IsItemChangeEnabled(mpn, itemChangeNames) && !this.maid.IsItemChange(mpn, itemChangeNames))
  290. {
  291. this.maid.ItemChangeTemp(mpn, itemChangeNames);
  292. flag = true;
  293. }
  294. }
  295. }
  296. else
  297. {
  298. flag = true;
  299. foreach (string mpn2 in targetMpnNames)
  300. {
  301. this.maid.ResetProp(mpn2, true);
  302. }
  303. }
  304. if (!flag)
  305. {
  306. return false;
  307. }
  308. if (!enabled || runAllProcProp)
  309. {
  310. this.maid.AllProcProp();
  311. }
  312. return true;
  313. }
  314. public bool IsEnabledCostumeType(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType type)
  315. {
  316. if (this.maid == null)
  317. {
  318. Debug.LogWarning("MaidCostumeChangeManager::IsEnabledCostumeType\n maid is null.");
  319. return false;
  320. }
  321. if (Product.isPublic)
  322. {
  323. return false;
  324. }
  325. string itemChangeNames = MaidCostumeChangeController.MaidCostumeChangeManager.GetItemChangeNames(type);
  326. foreach (string mpn in MaidCostumeChangeController.MaidCostumeChangeManager.GetTargetMpnNames(this.maid, type))
  327. {
  328. if (this.maid.IsItemChange(mpn, itemChangeNames))
  329. {
  330. return true;
  331. }
  332. }
  333. return false;
  334. }
  335. public void Reset(string targetMpnName = null)
  336. {
  337. if (this.maid == null)
  338. {
  339. Debug.LogWarning("MaidCostumeChangeManager::Reset\n maid is null.");
  340. return;
  341. }
  342. if (targetMpnName == null)
  343. {
  344. HashSet<string> hashSet = new HashSet<string>();
  345. IEnumerator enumerator = Enum.GetValues(typeof(MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType)).GetEnumerator();
  346. try
  347. {
  348. while (enumerator.MoveNext())
  349. {
  350. object obj = enumerator.Current;
  351. MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType type = (MaidCostumeChangeController.MaidCostumeChangeManager.CostumeType)obj;
  352. foreach (string item in MaidCostumeChangeController.MaidCostumeChangeManager.GetTargetMpnNames(this.maid, type))
  353. {
  354. hashSet.Add(item);
  355. }
  356. }
  357. }
  358. finally
  359. {
  360. IDisposable disposable;
  361. if ((disposable = (enumerator as IDisposable)) != null)
  362. {
  363. disposable.Dispose();
  364. }
  365. }
  366. foreach (string mpn in hashSet)
  367. {
  368. this.maid.ResetProp(mpn, false);
  369. }
  370. }
  371. else
  372. {
  373. this.maid.ResetProp(targetMpnName, false);
  374. }
  375. this.maid.AllProcProp();
  376. }
  377. public Maid maid;
  378. public enum CostumeType
  379. {
  380. MekureFront,
  381. MekureBack,
  382. Zurasi,
  383. Hadake,
  384. HadakeAndMekureFront,
  385. HadakeAndMekureBack,
  386. HadakeAndZurasi
  387. }
  388. }
  389. public enum CostumeType
  390. {
  391. MekureFront,
  392. MekureBack,
  393. Zurasi,
  394. Hadake
  395. }
  396. }
  397. }