CharacterMgr.cs 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using I2.Loc;
  7. using MaidStatus;
  8. using PlayerStatus;
  9. using SceneNPCEdit;
  10. using Schedule;
  11. using UnityEngine;
  12. using wf;
  13. public class CharacterMgr : MonoBehaviour
  14. {
  15. public static Dictionary<string, CharacterMgr.NpcData> npcDatas { get; private set; }
  16. public static bool EditModeLookHaveItem
  17. {
  18. get
  19. {
  20. return CharacterMgr.m_bEditMode;
  21. }
  22. set
  23. {
  24. CharacterMgr.m_bEditMode = value;
  25. }
  26. }
  27. public string PresetDirectory
  28. {
  29. get
  30. {
  31. return Path.Combine(GameMain.Instance.SerializeStorageManager.StoreDirectoryPath, "Preset");
  32. }
  33. }
  34. public GameObject CharacterAll
  35. {
  36. get
  37. {
  38. return this.m_goCharacter;
  39. }
  40. }
  41. public PlayerStatus.Status status
  42. {
  43. get
  44. {
  45. return this.m_PlayerStatus;
  46. }
  47. }
  48. public Maid GetMaid(int nMaidNo)
  49. {
  50. return (this.m_gcActiveMaid.Length > nMaidNo) ? this.m_gcActiveMaid[nMaidNo] : null;
  51. }
  52. public Maid GetMaid(string guid)
  53. {
  54. for (int i = 0; i < this.m_gcActiveMaid.Length; i++)
  55. {
  56. if (this.m_gcActiveMaid[i] != null && this.m_gcActiveMaid[i].status.guid == guid)
  57. {
  58. return this.m_gcActiveMaid[i];
  59. }
  60. }
  61. return null;
  62. }
  63. public int GetMaidCount()
  64. {
  65. return this.m_gcActiveMaid.Length;
  66. }
  67. public Maid GetMan(int nManNo)
  68. {
  69. return (this.m_gcActiveMan.Length > nManNo) ? this.m_gcActiveMan[nManNo] : null;
  70. }
  71. public int GetManCount()
  72. {
  73. return this.m_gcActiveMan.Length;
  74. }
  75. public List<Maid> GetStockMaidList()
  76. {
  77. return this.m_listStockMaid;
  78. }
  79. public Maid GetStockMaid(int nStockNo)
  80. {
  81. return this.m_listStockMaid[nStockNo];
  82. }
  83. public Maid GetStockMaid(string guid)
  84. {
  85. for (int i = 0; i < this.m_listStockMaid.Count; i++)
  86. {
  87. if (this.m_listStockMaid[i].status.guid == guid)
  88. {
  89. return this.m_listStockMaid[i];
  90. }
  91. }
  92. return null;
  93. }
  94. public Maid GetStockNpcMaid(int nStockNo)
  95. {
  96. return this.m_listStockNpcMaid[nStockNo];
  97. }
  98. public Maid GetStockNpcMaid(string guid)
  99. {
  100. for (int i = 0; i < this.m_listStockNpcMaid.Count; i++)
  101. {
  102. if (this.m_listStockNpcMaid[i].status.guid == guid)
  103. {
  104. return this.m_listStockNpcMaid[i];
  105. }
  106. }
  107. return null;
  108. }
  109. public Maid GetStockMan(int nStockNo)
  110. {
  111. return this.m_listStockMan[nStockNo];
  112. }
  113. public Maid GetStockMan(string guid)
  114. {
  115. for (int i = 0; i < this.m_listStockMan.Count; i++)
  116. {
  117. if (this.m_listStockMan[i].status.guid == guid)
  118. {
  119. return this.m_listStockMan[i];
  120. }
  121. }
  122. return null;
  123. }
  124. public Maid GetStockNpcMan(int nStockNo)
  125. {
  126. return this.m_listStockNpcMan[nStockNo];
  127. }
  128. public Maid GetStockNpcMan(string guid)
  129. {
  130. for (int i = 0; i < this.m_listStockNpcMan.Count; i++)
  131. {
  132. if (this.m_listStockNpcMan[i].status.guid == guid)
  133. {
  134. return this.m_listStockNpcMan[i];
  135. }
  136. }
  137. return null;
  138. }
  139. public int GetStockMaidCount()
  140. {
  141. return this.m_listStockMaid.Count;
  142. }
  143. public int GetStockManCount()
  144. {
  145. return this.m_listStockMan.Count;
  146. }
  147. public static void CreateNpcData()
  148. {
  149. if (CharacterMgr.npcDatas != null)
  150. {
  151. return;
  152. }
  153. CharacterMgr.npcDatas = new Dictionary<string, CharacterMgr.NpcData>();
  154. string text = "character_preset_basedata.nei";
  155. using (AFileBase afileBase = GameUty.FileSystem.FileOpen(text))
  156. {
  157. using (CsvParser csvParser = new CsvParser())
  158. {
  159. bool condition = csvParser.Open(afileBase);
  160. NDebug.Assert(condition, text + "\nopen failed.");
  161. for (int i = 1; i < csvParser.max_cell_y; i++)
  162. {
  163. CharacterMgr.NpcData npcData = new CharacterMgr.NpcData(csvParser, i);
  164. CharacterMgr.npcDatas.Add(npcData.uniqueName, npcData);
  165. }
  166. }
  167. }
  168. }
  169. private void Awake()
  170. {
  171. CharacterMgr.CreateNpcData();
  172. }
  173. private void Start()
  174. {
  175. }
  176. public void OnDestroy()
  177. {
  178. foreach (Maid obj in this.m_listStockNpcMan)
  179. {
  180. UnityEngine.Object.DestroyImmediate(obj);
  181. }
  182. this.m_listStockNpcMan.Clear();
  183. foreach (Maid obj2 in this.m_listStockMan)
  184. {
  185. UnityEngine.Object.DestroyImmediate(obj2);
  186. }
  187. this.m_listStockMan.Clear();
  188. foreach (Maid obj3 in this.m_listStockNpcMaid)
  189. {
  190. UnityEngine.Object.DestroyImmediate(obj3);
  191. }
  192. this.m_listStockNpcMaid.Clear();
  193. foreach (Maid obj4 in this.m_listStockMaid)
  194. {
  195. UnityEngine.Object.DestroyImmediate(obj4);
  196. }
  197. this.m_listStockMaid.Clear();
  198. }
  199. public void Init(GameMain f_gcGameMain)
  200. {
  201. BoneMorph.Init();
  202. this.m_PlayerStatus = new PlayerStatus.Status();
  203. this.m_goCharacter = new GameObject("Character");
  204. this.m_goCharacter.transform.parent = f_gcGameMain.transform;
  205. this.m_goActive = new GameObject("Active");
  206. this.m_goActive.transform.parent = this.m_goCharacter.transform;
  207. this.m_goAllOffset = new GameObject("AllOffset");
  208. this.m_goAllOffset.transform.parent = this.m_goActive.transform;
  209. this.m_goStock = new GameObject("Stock");
  210. this.m_goStock.transform.parent = this.m_goCharacter.transform;
  211. this.m_goStockMaid = new GameObject("Maid");
  212. this.m_goStockMaid.transform.SetParent(this.m_goStock.transform, false);
  213. this.m_goStockNpcMaid = new GameObject("NpcMaid");
  214. this.m_goStockNpcMaid.transform.SetParent(this.m_goStock.transform, false);
  215. this.m_goStockMan = new GameObject("Man");
  216. this.m_goStockMan.transform.SetParent(this.m_goStock.transform, false);
  217. this.m_goStockNpcMan = new GameObject("NpcMan");
  218. this.m_goStockNpcMan.transform.SetParent(this.m_goStock.transform, false);
  219. this.m_goChaches = new GameObject("_Caches");
  220. this.m_goChaches.transform.SetParent(this.m_goCharacter.transform, false);
  221. }
  222. public bool TryGetCacheObject(string f_key, out GameObject f_outObj)
  223. {
  224. return this.m_dicCaches.TryGetValue(f_key, out f_outObj);
  225. }
  226. public void AddCacheObject(string f_key, GameObject f_obj)
  227. {
  228. f_obj.transform.SetParent(this.m_goChaches.transform, false);
  229. this.m_dicCaches[f_key] = f_obj;
  230. }
  231. public Maid AddStockMaid()
  232. {
  233. return this.AddStock(false, false);
  234. }
  235. public Maid AddStockNpcMaid()
  236. {
  237. return this.AddStock(false, true);
  238. }
  239. public Maid AddStockNpcMan()
  240. {
  241. return this.AddStock(true, true);
  242. }
  243. public Maid AddStockMan()
  244. {
  245. return this.AddStock(true, false);
  246. }
  247. private Maid AddStock(bool f_bMan, bool f_bNpc)
  248. {
  249. GameObject gameObject = new GameObject();
  250. gameObject.name = ((!f_bMan) ? ((!f_bNpc) ? "StockMaid" : "StockNpcMaid") : ((!f_bNpc) ? "StockMan" : "StockNpcMan"));
  251. gameObject.transform.SetParent((!f_bMan) ? ((!f_bNpc) ? this.m_goStockMaid.transform : this.m_goStockNpcMaid.transform) : ((!f_bNpc) ? this.m_goStockMan.transform : this.m_goStockNpcMan.transform), false);
  252. Maid maid = gameObject.AddComponent<Maid>();
  253. maid.boNPC = f_bNpc;
  254. ((!f_bMan) ? ((!f_bNpc) ? this.m_listStockMaid : this.m_listStockNpcMaid) : ((!f_bNpc) ? this.m_listStockMan : this.m_listStockNpcMan)).Add(maid);
  255. maid.Initialize((!f_bMan) ? "Maid" : "Man", f_bMan);
  256. maid.Visible = false;
  257. return maid;
  258. }
  259. public void SetActiveMaid(Maid f_maid, int f_nActiveSlotNo)
  260. {
  261. this.SetActive(f_maid, f_nActiveSlotNo, false);
  262. }
  263. public void SetActiveMan(Maid f_maid, int f_nActiveSlotNo)
  264. {
  265. this.SetActive(f_maid, f_nActiveSlotNo, true);
  266. }
  267. private void SetActive(Maid f_maid, int f_nActiveSlotNo, bool f_bMan)
  268. {
  269. GameObject[] array = (!f_bMan) ? this.m_objActiveMaid : this.m_objActiveMan;
  270. Maid[] array2 = (!f_bMan) ? this.m_gcActiveMaid : this.m_gcActiveMan;
  271. if (array2[f_nActiveSlotNo] == f_maid)
  272. {
  273. return;
  274. }
  275. if (array[f_nActiveSlotNo] != null)
  276. {
  277. this.Deactivate(f_nActiveSlotNo, f_bMan);
  278. }
  279. f_maid.ActiveSlotNo = f_nActiveSlotNo;
  280. GameObject gameObject = f_maid.gameObject;
  281. gameObject.transform.SetParent(this.m_goAllOffset.transform, false);
  282. for (int i = 0; i < array.Length; i++)
  283. {
  284. if (array[i] == gameObject)
  285. {
  286. array[i] = null;
  287. array2[i] = null;
  288. }
  289. }
  290. gameObject.name = ((!f_bMan) ? "Maid[" : "Man[") + f_nActiveSlotNo.ToString() + "]";
  291. if (!f_bMan)
  292. {
  293. GameObject gameObject2 = gameObject;
  294. string name = gameObject2.name;
  295. gameObject2.name = string.Concat(new string[]
  296. {
  297. name,
  298. " ",
  299. f_maid.status.firstName,
  300. " ",
  301. f_maid.status.lastName
  302. });
  303. }
  304. array[f_nActiveSlotNo] = gameObject;
  305. array2[f_nActiveSlotNo] = f_maid;
  306. if (!f_bMan && f_maid.status != null)
  307. {
  308. if (f_maid.status.heroineType != HeroineType.Sub)
  309. {
  310. f_maid.status.voiceGroup = VoiceGroup.Heroine;
  311. }
  312. if (f_maid.status.subCharaStatus != null)
  313. {
  314. string contractText = f_maid.status.subCharaStatus.contractText;
  315. f_maid.status.voiceGroup = ((!(contractText == "ユニーク")) ? VoiceGroup.Extra : VoiceGroup.Sub);
  316. }
  317. }
  318. f_maid.DutPropAll();
  319. f_maid.AllProcPropSeqStart();
  320. }
  321. public Maid Activate(int f_nActiveSlot, int f_nStockSlot, bool f_bMan, bool f_bNpc)
  322. {
  323. List<Maid> list = (!f_bMan) ? ((!f_bNpc) ? this.m_listStockMaid : this.m_listStockNpcMaid) : ((!f_bNpc) ? this.m_listStockMan : this.m_listStockNpcMan);
  324. Maid maid = list[f_nStockSlot];
  325. if (f_bMan)
  326. {
  327. this.SetActiveMan(maid, f_nActiveSlot);
  328. }
  329. else
  330. {
  331. this.SetActiveMaid(maid, f_nActiveSlot);
  332. }
  333. return maid;
  334. }
  335. public Maid ActivateNpc(int f_nActiveSlot)
  336. {
  337. for (int i = 0; i < 3; i++)
  338. {
  339. Maid stockNpcMaid = this.GetStockNpcMaid(i);
  340. if (stockNpcMaid.ActiveSlotNo == -1)
  341. {
  342. return this.Activate(f_nActiveSlot, i, false, true);
  343. }
  344. }
  345. NDebug.Assert("Subメイドとして同時に扱える上限を超えています(" + 3.ToString() + "体までです", false);
  346. return null;
  347. }
  348. public void SwapActiveSlot(int slotNoA, int slotNoB, bool isMan)
  349. {
  350. GameObject[] array = (!isMan) ? this.m_objActiveMaid : this.m_objActiveMan;
  351. Maid[] array2 = (!isMan) ? this.m_gcActiveMaid : this.m_gcActiveMan;
  352. GameObject gameObject = array[slotNoA];
  353. array[slotNoA] = array[slotNoB];
  354. array[slotNoB] = gameObject;
  355. string text = (!(array2[slotNoA] != null)) ? null : array2[slotNoA].gameObject.name;
  356. if (array2[slotNoA] && array2[slotNoB] != null)
  357. {
  358. array2[slotNoA].gameObject.name = array2[slotNoB].gameObject.name;
  359. }
  360. if (array2[slotNoB] != null && text != null)
  361. {
  362. array2[slotNoB].gameObject.name = text;
  363. }
  364. Maid maid = array2[slotNoA];
  365. array2[slotNoA] = array2[slotNoB];
  366. array2[slotNoB] = maid;
  367. int activeSlotNo = (!(array2[slotNoA] != null)) ? -1 : array2[slotNoA].ActiveSlotNo;
  368. if (array2[slotNoA])
  369. {
  370. array2[slotNoA].ActiveSlotNo = ((!(array2[slotNoB] != null)) ? -1 : array2[slotNoB].ActiveSlotNo);
  371. }
  372. if (array2[slotNoB])
  373. {
  374. array2[slotNoB].ActiveSlotNo = activeSlotNo;
  375. }
  376. }
  377. public void DeactivateCharaAll()
  378. {
  379. this.DeactivateMaidAll();
  380. this.DeactivateManAll();
  381. this.ResetCharaPosAll();
  382. }
  383. public void DeactivateMaid(int f_nActiveSlotNo)
  384. {
  385. this.Deactivate(f_nActiveSlotNo, false);
  386. }
  387. public void DeactivateMaid(Maid f_maidActive)
  388. {
  389. this.Deactivate(f_maidActive.ActiveSlotNo, false);
  390. }
  391. public void DeactivateMaidAll()
  392. {
  393. this.CharaVisible(0, false, false);
  394. Maid maid = this.GetMaid(0);
  395. for (int i = 1; i < this.m_gcActiveMaid.Length; i++)
  396. {
  397. this.Deactivate(i, false);
  398. }
  399. }
  400. public void DeactivateMan(int f_nActiveSlotNo)
  401. {
  402. this.Deactivate(f_nActiveSlotNo, true);
  403. }
  404. public void DeactivateMan(Maid f_manActive)
  405. {
  406. this.Deactivate(f_manActive.ActiveSlotNo, true);
  407. }
  408. public void DeactivateManAll()
  409. {
  410. for (int i = 0; i < this.GetManCount(); i++)
  411. {
  412. this.CharaVisible(i, false, true);
  413. }
  414. }
  415. public void Deactivate(int f_nActiveSlotNo, bool f_bMan)
  416. {
  417. if (f_nActiveSlotNo == -1)
  418. {
  419. return;
  420. }
  421. GameObject[] array = (!f_bMan) ? this.m_objActiveMaid : this.m_objActiveMan;
  422. Maid[] array2 = (!f_bMan) ? this.m_gcActiveMaid : this.m_gcActiveMan;
  423. GameObject gameObject = array[f_nActiveSlotNo];
  424. Maid maid = array2[f_nActiveSlotNo];
  425. if (gameObject == null || maid == null)
  426. {
  427. return;
  428. }
  429. Debug.Log("Deactivate " + maid.status.firstName);
  430. GameObject gameObject2 = (!f_bMan) ? ((!maid.boNPC) ? this.m_goStockMaid : this.m_goStockNpcMaid) : ((!maid.boNPC) ? this.m_goStockMan : this.m_goStockNpcMan);
  431. if (gameObject == null)
  432. {
  433. return;
  434. }
  435. if (!f_bMan && maid.body0 != null)
  436. {
  437. maid.body0.MuneYureL(1f);
  438. maid.body0.MuneYureR(1f);
  439. }
  440. maid.Visible = false;
  441. maid.ActiveSlotNo = -1;
  442. maid.Uninit();
  443. maid.LipSyncEnabled(true);
  444. gameObject.transform.SetParent(gameObject2.transform, false);
  445. gameObject.name = ((!f_bMan) ? ((!maid.boNPC) ? "StockMaid" : "StockNpcMaid") : ((!maid.boNPC) ? "StockMan" : "StockNpcMan"));
  446. if (!f_bMan)
  447. {
  448. GameObject gameObject3 = gameObject;
  449. string name = gameObject3.name;
  450. gameObject3.name = string.Concat(new string[]
  451. {
  452. name,
  453. " ",
  454. maid.status.firstName,
  455. " ",
  456. maid.status.lastName
  457. });
  458. }
  459. array[f_nActiveSlotNo] = null;
  460. array2[f_nActiveSlotNo] = null;
  461. }
  462. public void BanishmentMaid(int f_nStockNo)
  463. {
  464. this.Banishment(f_nStockNo, false);
  465. }
  466. public void BanishmentMaid(Maid f_maid)
  467. {
  468. this.BanishmentMaid(f_maid, false);
  469. }
  470. public void BanishmentMan(int f_nStockNo)
  471. {
  472. this.Banishment(f_nStockNo, true);
  473. }
  474. public void BanishmentMan(Maid f_maid)
  475. {
  476. this.BanishmentMaid(f_maid, true);
  477. }
  478. private void Banishment(int f_nStockNo, bool f_bMan)
  479. {
  480. List<Maid> list = (!f_bMan) ? this.m_listStockMaid : this.m_listStockMan;
  481. if (f_nStockNo < 0 || list.Count <= f_nStockNo)
  482. {
  483. NDebug.Assert("Banishment メイドストック数より大きいIndexが設定されました。" + f_nStockNo, false);
  484. }
  485. Maid maid = list[f_nStockNo];
  486. if (maid == null)
  487. {
  488. NDebug.Assert("Banishment メイドストックはあるのにメイドが居ません。" + f_nStockNo, false);
  489. }
  490. this.BanishmentMaid(maid, f_bMan);
  491. }
  492. public void BanishmentMaid(Maid f_maid, bool f_bMan)
  493. {
  494. List<Maid> list = (!f_bMan) ? this.m_listStockMaid : this.m_listStockMan;
  495. if (f_maid.ActiveSlotNo != -1)
  496. {
  497. this.Deactivate(f_maid.ActiveSlotNo, f_bMan);
  498. }
  499. list.Remove(f_maid);
  500. if (f_maid != null)
  501. {
  502. UnityEngine.Object.DestroyImmediate(f_maid.gameObject);
  503. }
  504. }
  505. public Maid CharaVisible(int f_nActiveSlot, bool f_bVisible, bool f_bMan)
  506. {
  507. Maid[] array = (!f_bMan) ? this.m_gcActiveMaid : this.m_gcActiveMan;
  508. Maid maid = array[f_nActiveSlot];
  509. if (maid == null)
  510. {
  511. return null;
  512. }
  513. maid.Visible = f_bVisible;
  514. return maid;
  515. }
  516. public void ManAlphaUpdate()
  517. {
  518. for (int i = 0; i < this.m_listStockMan.Count; i++)
  519. {
  520. this.m_listStockMan[i].ManColorUpdate();
  521. }
  522. }
  523. public void LoadDefault()
  524. {
  525. if (!this.IsBusy())
  526. {
  527. for (int i = 0; i < 3; i++)
  528. {
  529. Maid maid = this.AddStockNpcMaid();
  530. maid.Visible = false;
  531. }
  532. for (int j = 0; j < 6; j++)
  533. {
  534. Maid maid2 = this.AddStockMan();
  535. this.SetActiveMan(maid2, j);
  536. maid2.Visible = false;
  537. }
  538. }
  539. }
  540. public void VisibleAll(bool f_bVisible)
  541. {
  542. for (int i = 0; i < this.GetMaidCount(); i++)
  543. {
  544. Maid maid = this.GetMaid(i);
  545. if (maid != null)
  546. {
  547. maid.Visible = f_bVisible;
  548. }
  549. }
  550. for (int j = 0; j < this.GetManCount(); j++)
  551. {
  552. Maid man = this.GetMan(j);
  553. if (man != null)
  554. {
  555. man.Visible = f_bVisible;
  556. }
  557. }
  558. }
  559. public bool IsBusy()
  560. {
  561. bool flag = false;
  562. for (int i = 0; i < this.m_gcActiveMaid.Length; i++)
  563. {
  564. Maid maid = this.GetMaid(i);
  565. if (maid != null)
  566. {
  567. flag |= maid.IsBusy;
  568. }
  569. }
  570. for (int j = 0; j < this.m_gcActiveMan.Length; j++)
  571. {
  572. Maid man = this.GetMan(j);
  573. if (man != null)
  574. {
  575. flag |= man.IsBusy;
  576. }
  577. }
  578. return flag;
  579. }
  580. public void ResetCharaPosAll()
  581. {
  582. this.SetCharaAllPos(Vector3.zero);
  583. this.SetCharaAllRot(Vector3.zero);
  584. this.CharaAllOfsetPos(Vector3.zero);
  585. this.CharaAllOfsetRot(Vector3.zero);
  586. for (int i = 0; i < this.m_listStockMaid.Count; i++)
  587. {
  588. Maid maid = this.m_listStockMaid[i];
  589. maid.SetPos(Vector3.zero);
  590. maid.SetRot(Vector3.zero);
  591. maid.baseOffset = (maid.baseEulerAngles = Vector3.zero);
  592. maid.rotateLinkMaid = string.Empty;
  593. maid.SetPosOffset(Vector3.zero);
  594. if (maid.body0 != null)
  595. {
  596. maid.body0.SetBoneHitHeightY(0f);
  597. }
  598. }
  599. for (int j = 0; j < this.m_listStockNpcMaid.Count; j++)
  600. {
  601. Maid maid2 = this.m_listStockNpcMaid[j];
  602. maid2.SetPos(Vector3.zero);
  603. maid2.SetRot(Vector3.zero);
  604. maid2.baseOffset = (maid2.baseEulerAngles = Vector3.zero);
  605. maid2.rotateLinkMaid = string.Empty;
  606. maid2.SetPosOffset(Vector3.zero);
  607. if (maid2.body0 != null)
  608. {
  609. maid2.body0.SetBoneHitHeightY(0f);
  610. }
  611. }
  612. for (int k = 0; k < this.m_listStockMan.Count; k++)
  613. {
  614. Maid maid3 = this.m_listStockMan[k];
  615. maid3.SetPos(Vector3.zero);
  616. maid3.SetRot(Vector3.zero);
  617. maid3.baseOffset = (maid3.baseEulerAngles = Vector3.zero);
  618. maid3.rotateLinkMaid = string.Empty;
  619. maid3.SetPosOffset(Vector3.zero);
  620. if (maid3.body0 != null)
  621. {
  622. maid3.body0.SetBoneHitHeightY(0f);
  623. }
  624. }
  625. for (int l = 0; l < this.m_listStockNpcMan.Count; l++)
  626. {
  627. Maid maid4 = this.m_listStockNpcMan[l];
  628. maid4.SetPos(Vector3.zero);
  629. maid4.SetRot(Vector3.zero);
  630. maid4.baseOffset = (maid4.baseEulerAngles = Vector3.zero);
  631. maid4.rotateLinkMaid = string.Empty;
  632. maid4.SetPosOffset(Vector3.zero);
  633. if (maid4.body0 != null)
  634. {
  635. maid4.body0.SetBoneHitHeightY(0f);
  636. }
  637. }
  638. }
  639. public void SetCharaAllPos(Vector3 f_vecLocalPos)
  640. {
  641. this.m_goActive.transform.localPosition = f_vecLocalPos;
  642. }
  643. public Vector3 GetCharaAllPos()
  644. {
  645. return this.m_goActive.transform.localPosition;
  646. }
  647. public void SetCharaAllRot(Vector3 f_vecLocalRot)
  648. {
  649. this.m_goActive.transform.localRotation = Quaternion.Euler(f_vecLocalRot);
  650. }
  651. public Vector3 GetCharaAllRot()
  652. {
  653. return this.m_goActive.transform.localRotation.eulerAngles;
  654. }
  655. public void CharaAllOfsetPos(Vector3 f_vecLocalPos)
  656. {
  657. this.m_goAllOffset.transform.localPosition = f_vecLocalPos;
  658. }
  659. public Vector3 GetCharaAllOfsetPos()
  660. {
  661. return this.m_goAllOffset.transform.localPosition;
  662. }
  663. public void CharaAllOfsetRot(Vector3 f_vecLocalRot)
  664. {
  665. this.m_goAllOffset.transform.localRotation = Quaternion.Euler(f_vecLocalRot);
  666. }
  667. public Vector3 GetCharaAllOfsetRot()
  668. {
  669. return this.m_goAllOffset.transform.localRotation.eulerAngles;
  670. }
  671. public void GetOffsetMaid(Maid f_maidMy, int f_nCSTSplitNum, out Vector3 f_vecOutCharOffset, out Vector3 f_vecOutAllOfs, CharacterMgr.CharaPer f_cIn)
  672. {
  673. f_cIn.vecOffsDouParGreater *= 100000f;
  674. f_cIn.vecOffsDouParLess *= 100000f;
  675. f_cIn.vecOffsShinChoGreater *= 100000f;
  676. f_cIn.vecOffsShinChoLess *= 100000f;
  677. f_cIn.vecOffsMuneLGreater *= 100000f;
  678. f_cIn.vecOffsMuneLLess *= 100000f;
  679. f_cIn.vecHaremDouPerGreater *= 100000f;
  680. f_cIn.vecHaremDouPerLess *= 100000f;
  681. f_cIn.vecHaremShinChoGreater *= 100000f;
  682. f_cIn.vecHaremShinChoLess *= 100000f;
  683. f_cIn.vecHaremMuneLGreater *= 100000f;
  684. f_cIn.vecHaremMuneLLess *= 100000f;
  685. NDebug.Assert(f_nCSTSplitNum != 0, "分割数は0以外でなければいけません。");
  686. MaidProp prop = f_maidMy.GetProp(MPN.DouPer);
  687. int num;
  688. if (prop.boTempDut)
  689. {
  690. num = prop.temp_value - 50;
  691. }
  692. else
  693. {
  694. num = prop.value - 50;
  695. }
  696. prop = f_maidMy.GetProp(MPN.sintyou);
  697. int num2;
  698. if (prop.boTempDut)
  699. {
  700. num2 = prop.temp_value - 50;
  701. }
  702. else
  703. {
  704. num2 = prop.value - 50;
  705. }
  706. Vector3 a;
  707. Vector3 a2;
  708. if (0 <= num)
  709. {
  710. a = (float)num * f_cIn.vecOffsDouParGreater / (float)f_nCSTSplitNum;
  711. a2 = (float)num * f_cIn.vecHaremDouPerGreater / (float)f_nCSTSplitNum;
  712. }
  713. else
  714. {
  715. int num3 = f_nCSTSplitNum * -1;
  716. a = (float)num * f_cIn.vecOffsDouParLess / (float)num3;
  717. a2 = (float)num * f_cIn.vecHaremDouPerLess / (float)num3;
  718. }
  719. Vector3 b;
  720. Vector3 b2;
  721. if (0 <= num2)
  722. {
  723. b = (float)num2 * f_cIn.vecOffsShinChoGreater / (float)f_nCSTSplitNum;
  724. b2 = (float)num2 * f_cIn.vecHaremShinChoGreater / (float)f_nCSTSplitNum;
  725. }
  726. else
  727. {
  728. int num4 = f_nCSTSplitNum * -1;
  729. b = (float)num2 * f_cIn.vecOffsShinChoLess / (float)num4;
  730. b2 = (float)num2 * f_cIn.vecHaremShinChoLess / (float)num4;
  731. }
  732. prop = f_maidMy.GetProp(MPN.MuneL);
  733. int num5;
  734. if (prop.boTempDut)
  735. {
  736. num5 = prop.temp_value - 50;
  737. }
  738. else
  739. {
  740. num5 = prop.value - 50;
  741. }
  742. Vector3 b3;
  743. Vector3 b4;
  744. if (0 <= num5)
  745. {
  746. b3 = (float)num5 * f_cIn.vecOffsMuneLGreater / (float)f_nCSTSplitNum;
  747. b4 = (float)num5 * f_cIn.vecHaremMuneLGreater / (float)f_nCSTSplitNum;
  748. }
  749. else
  750. {
  751. int num6 = f_nCSTSplitNum * -1;
  752. b3 = (float)num5 * f_cIn.vecOffsMuneLLess / (float)num6;
  753. b4 = (float)num5 * f_cIn.vecHaremMuneLLess / (float)num6;
  754. }
  755. f_vecOutCharOffset = a + b + b3;
  756. f_vecOutCharOffset /= 100000f;
  757. f_vecOutAllOfs = a2 + b2 + b4;
  758. f_vecOutAllOfs /= 100000f;
  759. }
  760. public void GetOffsetMan(Maid f_maidTarget, int f_nCSTSplitNum, bool f_bPenisDetailMode, out Vector3 f_vecOutPenis, out Vector3 f_vecOutCharOffset, CharacterMgr.CharaPer f_cIn, CharacterMgr.PenisPer f_cPenisPer)
  761. {
  762. f_cIn.vecOffsDouParGreater *= 100000f;
  763. f_cIn.vecOffsDouParLess *= 100000f;
  764. f_cIn.vecOffsShinChoGreater *= 100000f;
  765. f_cIn.vecOffsShinChoLess *= 100000f;
  766. f_cIn.vecOffsMuneLGreater *= 100000f;
  767. f_cIn.vecOffsMuneLLess *= 100000f;
  768. f_cIn.vecHaremDouPerGreater *= 100000f;
  769. f_cIn.vecHaremDouPerLess *= 100000f;
  770. f_cIn.vecHaremShinChoGreater *= 100000f;
  771. f_cIn.vecHaremShinChoLess *= 100000f;
  772. f_cIn.vecHaremMuneLGreater *= 100000f;
  773. f_cIn.vecHaremMuneLLess *= 100000f;
  774. f_cPenisPer.vecPenisCommonBase *= 100000f;
  775. f_cPenisPer.vecPenisAmend *= 100000f;
  776. f_cPenisPer.vecPenisDouPerGreater *= 100000f;
  777. f_cPenisPer.vecPenisDouPerLess *= 100000f;
  778. f_cPenisPer.vecPenisShinchoGreater *= 100000f;
  779. f_cPenisPer.vecPenisShinchoLess *= 100000f;
  780. MaidProp prop = f_maidTarget.GetProp(MPN.DouPer);
  781. int num;
  782. if (prop.boTempDut)
  783. {
  784. num = prop.temp_value - 50;
  785. }
  786. else
  787. {
  788. num = prop.value - 50;
  789. }
  790. prop = f_maidTarget.GetProp(MPN.sintyou);
  791. int num2;
  792. if (prop.boTempDut)
  793. {
  794. num2 = prop.temp_value - 50;
  795. }
  796. else
  797. {
  798. num2 = prop.value - 50;
  799. }
  800. Vector3 a;
  801. if (0 <= num)
  802. {
  803. a = (float)num * f_cIn.vecOffsDouParGreater / (float)f_nCSTSplitNum;
  804. }
  805. else
  806. {
  807. int num3 = f_nCSTSplitNum * -1;
  808. a = (float)num * f_cIn.vecOffsDouParLess / (float)num3;
  809. }
  810. Vector3 b;
  811. if (0 <= num2)
  812. {
  813. b = (float)num2 * f_cIn.vecOffsShinChoGreater / (float)f_nCSTSplitNum;
  814. }
  815. else
  816. {
  817. int num4 = f_nCSTSplitNum * -1;
  818. b = (float)num2 * f_cIn.vecOffsShinChoLess / (float)num4;
  819. }
  820. prop = f_maidTarget.GetProp(MPN.MuneL);
  821. int num5;
  822. if (prop.boTempDut)
  823. {
  824. num5 = prop.temp_value - 50;
  825. }
  826. else
  827. {
  828. num5 = prop.value - 50;
  829. }
  830. Vector3 b2;
  831. if (0 <= num5)
  832. {
  833. b2 = (float)num5 * f_cIn.vecOffsMuneLGreater / (float)f_nCSTSplitNum;
  834. }
  835. else
  836. {
  837. int num6 = f_nCSTSplitNum * -1;
  838. b2 = (float)num5 * f_cIn.vecOffsMuneLLess / (float)num6;
  839. }
  840. Vector3 vector = a + b + b2;
  841. Vector3 a2 = Vector3.zero;
  842. Vector3 b3 = Vector3.zero;
  843. if (f_bPenisDetailMode)
  844. {
  845. if (0 <= num)
  846. {
  847. a2 = (float)num * (f_cPenisPer.vecPenisDouPerGreater - f_cPenisPer.vecPenisCommonBase) / (float)f_nCSTSplitNum;
  848. }
  849. else
  850. {
  851. int num3 = f_nCSTSplitNum * -1;
  852. a2 = (float)num * (f_cPenisPer.vecPenisDouPerLess - f_cPenisPer.vecPenisCommonBase) / (float)num3;
  853. }
  854. if (0 <= num2)
  855. {
  856. b3 = (float)num2 * (f_cPenisPer.vecPenisShinchoGreater - f_cPenisPer.vecPenisCommonBase) / (float)f_nCSTSplitNum;
  857. }
  858. else
  859. {
  860. int num4 = f_nCSTSplitNum * -1;
  861. b3 = (float)num2 * (f_cPenisPer.vecPenisShinchoLess - f_cPenisPer.vecPenisCommonBase) / (float)num4;
  862. }
  863. }
  864. f_vecOutPenis = a2 + b3 + f_cPenisPer.vecPenisCommonBase + f_cPenisPer.vecPenisAmend;
  865. f_vecOutPenis /= 100000f;
  866. f_vecOutCharOffset = vector;
  867. f_vecOutCharOffset /= 100000f;
  868. }
  869. public Vector3 SetMaidOffsetPos(Maid f_maid, int f_nCSTSplitNum, CharacterMgr.CharaPer f_cIn)
  870. {
  871. Vector3 zero = Vector3.zero;
  872. Vector3 zero2 = Vector3.zero;
  873. this.GetOffsetMaid(f_maid, f_nCSTSplitNum, out zero, out zero2, f_cIn);
  874. if (ScriptManager.isGP001Mode)
  875. {
  876. f_maid.motionOffset = zero;
  877. f_maid.UpdateTransformData();
  878. }
  879. else
  880. {
  881. f_maid.SetPos(zero);
  882. }
  883. return zero2;
  884. }
  885. public void SetMaidOffsetOther(List<KeyValuePair<Maid, CharacterMgr.CharaPer>> f_listMaid, int f_nCSTSplitNum)
  886. {
  887. Vector3 vector = Vector3.zero;
  888. Vector3 vector2 = Vector3.zero;
  889. for (int i = 0; i < f_listMaid.Count; i++)
  890. {
  891. vector = this.SetMaidOffsetPos(f_listMaid[i].Key, f_nCSTSplitNum, f_listMaid[i].Value);
  892. if (vector2.y < vector.y)
  893. {
  894. vector2 = vector;
  895. }
  896. }
  897. if (!ScriptManager.isGP001Mode)
  898. {
  899. this.CharaAllOfsetPos(new Vector3(0f, vector2.y, 0f));
  900. }
  901. }
  902. public void SetManOffsetPos(Maid f_manMy, Maid f_maidTarget, int f_nCSTSplitNum, bool f_bPenisDetailMode, CharacterMgr.CharaPer f_cIn, CharacterMgr.PenisPer f_cPenisPer)
  903. {
  904. Vector3 vecChinkoOffset;
  905. Vector3 vector;
  906. this.GetOffsetMan(f_maidTarget, f_nCSTSplitNum, f_bPenisDetailMode, out vecChinkoOffset, out vector, f_cIn, f_cPenisPer);
  907. f_manMy.body0.vecChinkoOffset = vecChinkoOffset;
  908. if (ScriptManager.isGP001Mode)
  909. {
  910. f_manMy.motionOffset = vector;
  911. f_manMy.UpdateTransformData();
  912. }
  913. else
  914. {
  915. f_manMy.SetPos(vector);
  916. }
  917. }
  918. public Texture2D ThumShot(Maid f_maid)
  919. {
  920. return GameMain.Instance.ThumCamera.GetComponent<ThumShot>().ShotThumPreset(f_maid);
  921. }
  922. public static string CreatePresetLowCapacityData(Maid maid, CharacterMgr.PresetType presset_type)
  923. {
  924. MemoryStream memoryStream = new MemoryStream();
  925. BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
  926. string result = string.Empty;
  927. binaryWriter.Write("CM3D2_PRESET_S");
  928. binaryWriter.Write(1470);
  929. binaryWriter.Write((char)presset_type);
  930. maid.SerializePropLowCapacity(binaryWriter);
  931. maid.SerializeMultiColor(binaryWriter);
  932. result = "^CM3D2P^" + Convert.ToBase64String(Utility.ZlibCompresss(memoryStream.ToArray()));
  933. binaryWriter.Close();
  934. memoryStream.Dispose();
  935. return result;
  936. }
  937. public CharacterMgr.Preset PresetSave(Maid f_maid, CharacterMgr.PresetType f_type)
  938. {
  939. CharacterMgr.Preset preset = new CharacterMgr.Preset();
  940. Texture2D texture2D = this.ThumShot(f_maid);
  941. MemoryStream memoryStream = new MemoryStream();
  942. BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
  943. binaryWriter.Write("CM3D2_PRESET");
  944. binaryWriter.Write(1470);
  945. binaryWriter.Write((int)f_type);
  946. if (texture2D != null)
  947. {
  948. byte[] array = texture2D.EncodeToPNG();
  949. binaryWriter.Write(array.Length);
  950. binaryWriter.Write(array);
  951. }
  952. else
  953. {
  954. binaryWriter.Write(0);
  955. }
  956. f_maid.SerializeProp(binaryWriter);
  957. f_maid.SerializeMultiColor(binaryWriter);
  958. f_maid.SerializeBody(binaryWriter);
  959. string text = string.Concat(new string[]
  960. {
  961. "pre_",
  962. f_maid.status.lastName,
  963. f_maid.status.firstName,
  964. "_",
  965. DateTime.Now.ToString("yyyyMMddHHmmss")
  966. });
  967. text = UTY.FileNameEscape(text);
  968. text += ".preset";
  969. string presetDirectory = this.PresetDirectory;
  970. if (!Directory.Exists(presetDirectory))
  971. {
  972. Directory.CreateDirectory(presetDirectory);
  973. }
  974. File.WriteAllBytes(presetDirectory + "\\" + text, memoryStream.ToArray());
  975. memoryStream.Dispose();
  976. preset.texThum = texture2D;
  977. preset.strFileName = text;
  978. preset.ePreType = f_type;
  979. return preset;
  980. }
  981. public byte[] PresetSaveNotWriteFile(Maid f_maid, CharacterMgr.PresetType f_type)
  982. {
  983. CharacterMgr.Preset preset = new CharacterMgr.Preset();
  984. Texture2D texture2D = this.ThumShot(f_maid);
  985. MemoryStream memoryStream = new MemoryStream();
  986. BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
  987. binaryWriter.Write("CM3D2_PRESET");
  988. binaryWriter.Write(1470);
  989. binaryWriter.Write((int)f_type);
  990. if (texture2D != null)
  991. {
  992. byte[] array = texture2D.EncodeToPNG();
  993. binaryWriter.Write(array.Length);
  994. binaryWriter.Write(array);
  995. }
  996. else
  997. {
  998. binaryWriter.Write(0);
  999. }
  1000. f_maid.SerializeProp(binaryWriter);
  1001. f_maid.SerializeMultiColor(binaryWriter);
  1002. f_maid.SerializeBody(binaryWriter);
  1003. return memoryStream.ToArray();
  1004. }
  1005. public void PresetSaveAsQRCode(Maid f_maid, CharacterMgr.PresetType f_type)
  1006. {
  1007. Texture2D texture2D = Utility.CreateQRCodeTexture(CharacterMgr.CreatePresetLowCapacityData(f_maid, f_type), 512, 512);
  1008. Sprite sprite = Sprite.Create(texture2D, new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height), default(Vector2));
  1009. sprite.name = "qr";
  1010. byte[] bytes = texture2D.EncodeToPNG();
  1011. string text = string.Concat(new string[]
  1012. {
  1013. "pre_",
  1014. f_maid.status.lastName,
  1015. f_maid.status.firstName,
  1016. "_",
  1017. DateTime.Now.ToString("yyyyMMddHHmmss")
  1018. });
  1019. text = UTY.FileNameEscape(text);
  1020. text += ".png";
  1021. string presetDirectory = this.PresetDirectory;
  1022. if (!Directory.Exists(presetDirectory))
  1023. {
  1024. Directory.CreateDirectory(presetDirectory);
  1025. }
  1026. File.WriteAllBytes(presetDirectory + "\\" + text, bytes);
  1027. }
  1028. public static CharacterMgr.Preset LoadePresetLowCapacityData(string data_text)
  1029. {
  1030. if (string.IsNullOrEmpty(data_text) || data_text.IndexOf("^CM3D2P^") != 0)
  1031. {
  1032. return null;
  1033. }
  1034. data_text = data_text.Replace("^CM3D2P^", string.Empty);
  1035. byte[] array = Convert.FromBase64String(data_text);
  1036. array = Utility.ZlibUncompress(array);
  1037. CharacterMgr.Preset preset = new CharacterMgr.Preset();
  1038. preset.strFileName = string.Empty;
  1039. using (MemoryStream memoryStream = new MemoryStream(array))
  1040. {
  1041. BinaryReader binaryReader = new BinaryReader(memoryStream);
  1042. string a = binaryReader.ReadString();
  1043. NDebug.Assert(a == "CM3D2_PRESET_S", "低用量プリセットファイルのヘッダーが不正です。");
  1044. int num = binaryReader.ReadInt32();
  1045. preset.ePreType = (CharacterMgr.PresetType)binaryReader.ReadChar();
  1046. preset.listMprop = Maid.DeserializePropLowCapacity(binaryReader);
  1047. preset.aryPartsColor = Maid.DeserializeMultiColorPre(binaryReader);
  1048. binaryReader.Close();
  1049. }
  1050. return preset;
  1051. }
  1052. public CharacterMgr.Preset PresetLoad(string f_strFileName)
  1053. {
  1054. FileStream fileStream = new FileStream(f_strFileName, FileMode.Open);
  1055. if (fileStream == null)
  1056. {
  1057. return null;
  1058. }
  1059. byte[] buffer = new byte[fileStream.Length];
  1060. fileStream.Read(buffer, 0, (int)fileStream.Length);
  1061. fileStream.Close();
  1062. fileStream.Dispose();
  1063. BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer));
  1064. CharacterMgr.Preset result = this.PresetLoad(binaryReader, Path.GetFileName(f_strFileName));
  1065. binaryReader.Close();
  1066. return result;
  1067. }
  1068. public CharacterMgr.Preset PresetLoadFromResources(string f_strFileName)
  1069. {
  1070. TextAsset textAsset = Resources.Load("Preset/" + f_strFileName) as TextAsset;
  1071. NDebug.Assert(textAsset != null, "内部Resourcesからファイル[" + f_strFileName + "]を読み込めませんでした");
  1072. BinaryReader binaryReader = new BinaryReader(new MemoryStream(textAsset.bytes));
  1073. CharacterMgr.Preset result = this.PresetLoad(binaryReader, Path.GetFileName(f_strFileName));
  1074. binaryReader.Close();
  1075. Resources.UnloadAsset(textAsset);
  1076. return result;
  1077. }
  1078. public CharacterMgr.Preset PresetLoad(BinaryReader brRead, string f_strFileName)
  1079. {
  1080. CharacterMgr.Preset preset = new CharacterMgr.Preset();
  1081. preset.strFileName = f_strFileName;
  1082. string a = brRead.ReadString();
  1083. NDebug.Assert(a == "CM3D2_PRESET", "プリセットファイルのヘッダーが不正です。");
  1084. int num = brRead.ReadInt32();
  1085. preset.nVersion = num;
  1086. int ePreType = brRead.ReadInt32();
  1087. preset.ePreType = (CharacterMgr.PresetType)ePreType;
  1088. int num2 = brRead.ReadInt32();
  1089. if (num2 != 0)
  1090. {
  1091. byte[] data = brRead.ReadBytes(num2);
  1092. preset.texThum = new Texture2D(1, 1);
  1093. preset.texThum.LoadImage(data);
  1094. preset.texThum.wrapMode = TextureWrapMode.Clamp;
  1095. }
  1096. else
  1097. {
  1098. preset.texThum = null;
  1099. }
  1100. preset.listMprop = Maid.DeserializePropPre(brRead);
  1101. if (num >= 2)
  1102. {
  1103. preset.aryPartsColor = Maid.DeserializeMultiColorPre(brRead);
  1104. }
  1105. if (num >= 200)
  1106. {
  1107. Maid.DeserializeBodyPre(brRead);
  1108. }
  1109. return preset;
  1110. }
  1111. public void PresetDelete(CharacterMgr.Preset f_pre)
  1112. {
  1113. try
  1114. {
  1115. string presetDirectory = this.PresetDirectory;
  1116. string text = presetDirectory + "\\" + f_pre.strFileName;
  1117. if (File.Exists(text))
  1118. {
  1119. File.Delete(text);
  1120. }
  1121. else
  1122. {
  1123. Debug.LogWarning("PresetDelete削除失敗 ファイルがありません。" + text);
  1124. }
  1125. }
  1126. catch (Exception ex)
  1127. {
  1128. Debug.LogWarning("PresetDelete削除失敗 " + ex.Message);
  1129. }
  1130. }
  1131. public List<CharacterMgr.Preset> PresetListLoad()
  1132. {
  1133. List<CharacterMgr.Preset> list = new List<CharacterMgr.Preset>();
  1134. string presetDirectory = this.PresetDirectory;
  1135. if (!Directory.Exists(presetDirectory))
  1136. {
  1137. Directory.CreateDirectory(presetDirectory);
  1138. }
  1139. foreach (string f_strFileName in Directory.GetFiles(presetDirectory, "*.preset"))
  1140. {
  1141. CharacterMgr.Preset item = this.PresetLoad(f_strFileName);
  1142. list.Add(item);
  1143. }
  1144. return list;
  1145. }
  1146. private bool IsEnableMenu(string f_strFileName)
  1147. {
  1148. if (CharacterMgr.EditModeLookHaveItem)
  1149. {
  1150. return GameMain.Instance.CharacterMgr.status.IsHavePartsItem(f_strFileName) && GameUty.IsExistFile(f_strFileName, null);
  1151. }
  1152. return GameUty.IsExistFile(f_strFileName, null);
  1153. }
  1154. public void PresetSet(Maid f_maid, CharacterMgr.Preset f_prest)
  1155. {
  1156. MaidProp[] array;
  1157. if (f_prest.ePreType == CharacterMgr.PresetType.Body)
  1158. {
  1159. array = (from mp in f_prest.listMprop
  1160. where (1 <= mp.idx && mp.idx <= 66) || (101 <= mp.idx && mp.idx <= 105)
  1161. select mp).ToArray<MaidProp>();
  1162. }
  1163. else if (f_prest.ePreType == CharacterMgr.PresetType.Wear)
  1164. {
  1165. array = (from mp in f_prest.listMprop
  1166. where 67 <= mp.idx && mp.idx <= 96
  1167. select mp).ToArray<MaidProp>();
  1168. }
  1169. else
  1170. {
  1171. array = (from mp in f_prest.listMprop
  1172. where (1 <= mp.idx && mp.idx <= 96) || (101 <= mp.idx && mp.idx <= 105)
  1173. select mp).ToArray<MaidProp>();
  1174. }
  1175. NDebug.Assert(array != null, "プリセットを実行する配列が空です。");
  1176. foreach (MaidProp maidProp in array)
  1177. {
  1178. if (maidProp.type != 3)
  1179. {
  1180. f_maid.SetProp((MPN)maidProp.idx, maidProp.value, false);
  1181. }
  1182. else
  1183. {
  1184. if (string.IsNullOrEmpty(maidProp.strFileName))
  1185. {
  1186. string strFileName = maidProp.strFileName;
  1187. if (CM3.dicDelItem.TryGetValue((MPN)maidProp.idx, out strFileName))
  1188. {
  1189. maidProp.strFileName = strFileName;
  1190. }
  1191. }
  1192. if (this.IsEnableMenu(maidProp.strFileName))
  1193. {
  1194. f_maid.SetProp(maidProp);
  1195. }
  1196. else
  1197. {
  1198. f_maid.DelProp((MPN)maidProp.idx, false);
  1199. }
  1200. if (maidProp.listSubProp != null && maidProp.listSubProp.Count != 0)
  1201. {
  1202. f_maid.DelProp((MPN)maidProp.idx, false);
  1203. for (int j = 0; j < maidProp.listSubProp.Count; j++)
  1204. {
  1205. SubProp subProp = maidProp.listSubProp[j];
  1206. if (subProp != null)
  1207. {
  1208. if (this.IsEnableMenu(subProp.strFileName))
  1209. {
  1210. f_maid.SetSubProp((MPN)maidProp.idx, j, subProp.strFileName, subProp.nFileNameRID);
  1211. f_maid.GetSubProp((MPN)maidProp.idx, j).fTexMulAlpha = subProp.fTexMulAlpha;
  1212. }
  1213. else
  1214. {
  1215. f_maid.DelSubProp((MPN)maidProp.idx, j);
  1216. }
  1217. }
  1218. }
  1219. }
  1220. }
  1221. }
  1222. if ((f_prest.ePreType == CharacterMgr.PresetType.Body || f_prest.ePreType == CharacterMgr.PresetType.All) && f_prest.aryPartsColor != null)
  1223. {
  1224. for (int k = 0; k < f_prest.aryPartsColor.Length; k++)
  1225. {
  1226. f_maid.Parts.SetPartsColor((MaidParts.PARTS_COLOR)k, f_prest.aryPartsColor[k]);
  1227. }
  1228. }
  1229. if (Product.isPublic)
  1230. {
  1231. f_maid.SetProp(MPN.bra, "bra030_i_.menu", 0, false, false);
  1232. f_maid.SetProp(MPN.panz, "Pants030_i_.menu", 0, false, false);
  1233. }
  1234. f_maid.AllProcPropSeqStart();
  1235. }
  1236. public bool Serialize(BinaryWriter bwWrite)
  1237. {
  1238. bwWrite.Write("CM3D2_CHR_MGR");
  1239. bwWrite.Write(1470);
  1240. this.m_PlayerStatus.Serialize(bwWrite);
  1241. bwWrite.Write(this.m_listStockMan.Count);
  1242. for (int i = 0; i < this.m_listStockMan.Count; i++)
  1243. {
  1244. Maid maid = this.m_listStockMan[i];
  1245. maid.SerializeProp(bwWrite);
  1246. maid.SerializeMisc(bwWrite);
  1247. }
  1248. bwWrite.Write(this.m_listStockMaid.Count);
  1249. for (int j = 0; j < this.m_listStockMaid.Count; j++)
  1250. {
  1251. Maid maid2 = this.m_listStockMaid[j];
  1252. maid2.SerializeProp(bwWrite);
  1253. maid2.SerializeMultiColor(bwWrite);
  1254. maid2.status.Serialize(bwWrite);
  1255. maid2.SerializeMisc(bwWrite);
  1256. maid2.SerializeBody(bwWrite);
  1257. }
  1258. return true;
  1259. }
  1260. public bool Deserialize(BinaryReader brRead)
  1261. {
  1262. for (int i = 0; i < this.GetMaidCount(); i++)
  1263. {
  1264. Maid maid = this.GetMaid(i);
  1265. if (maid != null)
  1266. {
  1267. this.DeactivateMaid(maid);
  1268. }
  1269. }
  1270. while (this.GetStockMaidCount() != 0)
  1271. {
  1272. this.BanishmentMaid(0);
  1273. }
  1274. int manCount = this.GetManCount();
  1275. for (int j = 0; j < manCount; j++)
  1276. {
  1277. Maid man = this.GetMan(j);
  1278. if (man != null)
  1279. {
  1280. this.DeactivateMan(man);
  1281. }
  1282. }
  1283. string a = brRead.ReadString();
  1284. NDebug.Assert(a == "CM3D2_CHR_MGR", "セーブデータファイルのヘッダーが不正です。CHR_MGR");
  1285. int num = brRead.ReadInt32();
  1286. this.m_PlayerStatus.Deserialize(brRead);
  1287. int num2 = brRead.ReadInt32();
  1288. int num3 = 0;
  1289. for (int k = 0; k < num2; k++)
  1290. {
  1291. Maid maid2 = this.m_listStockMan[k];
  1292. maid2.DeserializeProp(brRead);
  1293. maid2.DeserializeMisc(brRead);
  1294. if (maid2.ActiveSlotNo != -1)
  1295. {
  1296. this.SetActiveMan(maid2, maid2.ActiveSlotNo);
  1297. num3 = System.Math.Max(num3, maid2.ActiveSlotNo);
  1298. }
  1299. }
  1300. int num4 = this.GetManCount() - 2;
  1301. for (int l = num3 + 1; l < num4; l++)
  1302. {
  1303. this.SetActiveMan(this.GetStockMan(l), l);
  1304. }
  1305. int num5 = brRead.ReadInt32();
  1306. for (int m = 0; m < num5; m++)
  1307. {
  1308. Maid maid3 = this.AddStockMaid();
  1309. maid3.DeserializeProp(brRead);
  1310. maid3.DeserializeMultiColor(brRead);
  1311. maid3.status.Deserialize(brRead);
  1312. maid3.DeserializeMisc(brRead);
  1313. if (num >= 200)
  1314. {
  1315. maid3.DeserializeBody(brRead);
  1316. }
  1317. if (maid3.ActiveSlotNo != -1)
  1318. {
  1319. this.SetActiveMaid(maid3, maid3.ActiveSlotNo);
  1320. }
  1321. }
  1322. Maid.DeletedTmpThumCards();
  1323. GameMain.Instance.MsgWnd.ClearBackLogData();
  1324. if (this.status.isDaytime)
  1325. {
  1326. ScheduleAPI.OccurNightWork();
  1327. }
  1328. return true;
  1329. }
  1330. public bool SerializeAddition(BinaryWriter writer)
  1331. {
  1332. if (this.subMaidBackupStatusList == null)
  1333. {
  1334. this.subMaidBackupStatusList = new List<SubMaid.BackupStatus>();
  1335. }
  1336. byte[] array = new byte[0];
  1337. MemoryStream memoryStream = new MemoryStream();
  1338. BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
  1339. int count = this.subMaidBackupStatusList.Count;
  1340. binaryWriter.Write(count);
  1341. for (int i = 0; i < this.subMaidBackupStatusList.Count; i++)
  1342. {
  1343. binaryWriter.Write(JsonUtility.ToJson(this.subMaidBackupStatusList[i]));
  1344. if (this.subMaidBackupStatusList[i].iconBinary == null)
  1345. {
  1346. this.subMaidBackupStatusList[i].iconBinary = new byte[0];
  1347. }
  1348. if (this.subMaidBackupStatusList[i].presetBinary == null)
  1349. {
  1350. this.subMaidBackupStatusList[i].presetBinary = new byte[0];
  1351. }
  1352. binaryWriter.Write(this.subMaidBackupStatusList[i].iconBinary.Length);
  1353. binaryWriter.Write(this.subMaidBackupStatusList[i].iconBinary);
  1354. binaryWriter.Write(this.subMaidBackupStatusList[i].presetBinary.Length);
  1355. binaryWriter.Write(this.subMaidBackupStatusList[i].presetBinary);
  1356. }
  1357. array = Utility.ZlibCompresss(memoryStream.ToArray());
  1358. writer.Write(array.Length);
  1359. writer.Write(array);
  1360. return true;
  1361. }
  1362. public bool DeserializeAddition(BinaryReader reader)
  1363. {
  1364. int count = reader.ReadInt32();
  1365. byte[] buffer = Utility.ZlibUncompress(reader.ReadBytes(count));
  1366. BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer));
  1367. if (this.subMaidBackupStatusList == null)
  1368. {
  1369. this.subMaidBackupStatusList = new List<SubMaid.BackupStatus>();
  1370. }
  1371. this.subMaidBackupStatusList.Clear();
  1372. int num = binaryReader.ReadInt32();
  1373. for (int i = 0; i < num; i++)
  1374. {
  1375. SubMaid.BackupStatus backupStatus = JsonUtility.FromJson<SubMaid.BackupStatus>(binaryReader.ReadString());
  1376. int count2 = binaryReader.ReadInt32();
  1377. backupStatus.iconBinary = binaryReader.ReadBytes(count2);
  1378. count2 = binaryReader.ReadInt32();
  1379. backupStatus.presetBinary = binaryReader.ReadBytes(count2);
  1380. this.subMaidBackupStatusList.Add(backupStatus);
  1381. }
  1382. return true;
  1383. }
  1384. public const int MaidStockMax = 999;
  1385. public const int ActiveMaidSlotCount = 18;
  1386. public const int NpcMaidCreateCount = 3;
  1387. public const int ActiveManSloatCount = 6;
  1388. private static bool m_bEditMode;
  1389. public List<SubMaid.BackupStatus> subMaidBackupStatusList = new List<SubMaid.BackupStatus>();
  1390. private GameObject m_goCharacter;
  1391. private GameObject m_goActive;
  1392. private GameObject m_goAllOffset;
  1393. private GameObject m_goStock;
  1394. private GameObject m_goStockMaid;
  1395. private GameObject m_goStockNpcMaid;
  1396. private GameObject m_goStockMan;
  1397. private GameObject m_goStockNpcMan;
  1398. private Dictionary<string, GameObject> m_dicCaches = new Dictionary<string, GameObject>();
  1399. private GameObject m_goChaches;
  1400. private PlayerStatus.Status m_PlayerStatus;
  1401. private List<Maid> m_listStockMaid = new List<Maid>();
  1402. private List<Maid> m_listStockNpcMaid = new List<Maid>();
  1403. private List<Maid> m_listStockMan = new List<Maid>();
  1404. private List<Maid> m_listStockNpcMan = new List<Maid>();
  1405. private Maid[] m_gcActiveMaid = new Maid[18];
  1406. private GameObject[] m_objActiveMaid = new GameObject[18];
  1407. private Maid[] m_gcActiveMan = new Maid[6];
  1408. private GameObject[] m_objActiveMan = new GameObject[6];
  1409. public class NpcData
  1410. {
  1411. public NpcData(CsvParser csv, int lineY)
  1412. {
  1413. int num = 0;
  1414. this.uniqueName = csv.GetCellAsString(num++, lineY);
  1415. this.lastName = csv.GetCellAsString(num++, lineY);
  1416. this.firstName = csv.GetCellAsString(num++, lineY);
  1417. string cellAsString = csv.GetCellAsString(num++, lineY);
  1418. this.voiceGroup = VoiceGroup.Mob;
  1419. if (!string.IsNullOrEmpty(cellAsString))
  1420. {
  1421. try
  1422. {
  1423. this.voiceGroup = (VoiceGroup)Enum.Parse(typeof(VoiceGroup), cellAsString);
  1424. }
  1425. catch (Exception ex)
  1426. {
  1427. Debug.LogError(ex.StackTrace);
  1428. Debug.LogError(ex.Message);
  1429. }
  1430. }
  1431. this.presetFileName = Path.GetFileNameWithoutExtension(csv.GetCellAsString(num++, lineY));
  1432. if (!string.IsNullOrEmpty(this.presetFileName))
  1433. {
  1434. this.isResourcesLoad = !GameUty.FileSystem.IsExistentFile(this.presetFileName + ".preset");
  1435. }
  1436. this.menuFileName = Path.GetFileNameWithoutExtension(csv.GetCellAsString(num++, lineY));
  1437. if (!string.IsNullOrEmpty(this.menuFileName))
  1438. {
  1439. this.menuFileName += ".menu";
  1440. }
  1441. NDebug.Assert(string.IsNullOrEmpty(this.presetFileName) || string.IsNullOrEmpty(this.menuFileName), "プリセットとメニューファイル両方が指定されています");
  1442. }
  1443. public string firstNameTerm
  1444. {
  1445. get
  1446. {
  1447. return "SubMaid/" + this.uniqueName + "/名前";
  1448. }
  1449. }
  1450. public string lastNameTerm
  1451. {
  1452. get
  1453. {
  1454. return "SubMaid/" + this.uniqueName + "/苗字";
  1455. }
  1456. }
  1457. public void Apply(Maid maid, bool onlyPartsLoad = false)
  1458. {
  1459. if (maid == null || GameMain.Instance.CharacterMgr == null)
  1460. {
  1461. return;
  1462. }
  1463. CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
  1464. maid.ResetAll();
  1465. if (!maid.boMAN)
  1466. {
  1467. NDebug.Assert(string.IsNullOrEmpty(this.menuFileName), "メイドに対して男用のNPCデータを適用しようとしています");
  1468. if (!onlyPartsLoad)
  1469. {
  1470. maid.status.firstName = this.firstName;
  1471. maid.status.lastName = this.lastName;
  1472. if (Product.supportMultiLanguage)
  1473. {
  1474. string translation = LocalizationManager.GetTranslation(this.lastNameTerm, true, 0, true, false, null, Product.EnumConvert.ToI2LocalizeLanguageName(Product.defaultLanguage));
  1475. if (!string.IsNullOrEmpty(translation))
  1476. {
  1477. maid.status.lastName = translation;
  1478. }
  1479. translation = LocalizationManager.GetTranslation(this.firstNameTerm, true, 0, true, false, null, Product.EnumConvert.ToI2LocalizeLanguageName(Product.defaultLanguage));
  1480. if (!string.IsNullOrEmpty(translation))
  1481. {
  1482. maid.status.firstName = translation;
  1483. }
  1484. }
  1485. }
  1486. CharacterMgr.Preset preset = SaveData.GetPreset(this);
  1487. if (preset != null)
  1488. {
  1489. characterMgr.PresetSet(maid, preset);
  1490. }
  1491. else if (this.isResourcesLoad)
  1492. {
  1493. characterMgr.PresetSet(maid, characterMgr.PresetLoadFromResources(this.presetFileName));
  1494. }
  1495. else
  1496. {
  1497. using (AFileBase afileBase = GameUty.FileOpen(this.presetFileName + ".preset", null))
  1498. {
  1499. if (afileBase != null && afileBase.IsValid())
  1500. {
  1501. byte[] buffer = afileBase.ReadAll();
  1502. using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer), Encoding.UTF8))
  1503. {
  1504. characterMgr.PresetSet(maid, characterMgr.PresetLoad(binaryReader, this.presetFileName));
  1505. }
  1506. }
  1507. }
  1508. }
  1509. maid.status.voiceGroup = this.voiceGroup;
  1510. }
  1511. else
  1512. {
  1513. NDebug.Assert(string.IsNullOrEmpty(this.presetFileName), "男に対してメイド用のNPCデータを適用しようとしています");
  1514. maid.SetUpModel(this.menuFileName);
  1515. }
  1516. }
  1517. public readonly string uniqueName;
  1518. public readonly string firstName;
  1519. public readonly string lastName;
  1520. public readonly VoiceGroup voiceGroup;
  1521. public readonly string presetFileName;
  1522. public readonly string menuFileName;
  1523. public readonly bool isResourcesLoad;
  1524. }
  1525. public class CharaPer
  1526. {
  1527. public Vector3 vecOffsDouParGreater;
  1528. public Vector3 vecOffsDouParLess;
  1529. public Vector3 vecOffsShinChoGreater;
  1530. public Vector3 vecOffsShinChoLess;
  1531. public Vector3 vecOffsMuneLGreater;
  1532. public Vector3 vecOffsMuneLLess;
  1533. public Vector3 vecHaremDouPerGreater;
  1534. public Vector3 vecHaremDouPerLess;
  1535. public Vector3 vecHaremShinChoGreater;
  1536. public Vector3 vecHaremShinChoLess;
  1537. public Vector3 vecHaremMuneLGreater;
  1538. public Vector3 vecHaremMuneLLess;
  1539. }
  1540. public class PenisPer
  1541. {
  1542. public Vector3 vecPenisCommonBase;
  1543. public Vector3 vecPenisAmend;
  1544. public Vector3 vecPenisDouPerGreater;
  1545. public Vector3 vecPenisDouPerLess;
  1546. public Vector3 vecPenisShinchoGreater;
  1547. public Vector3 vecPenisShinchoLess;
  1548. }
  1549. public enum PresetType
  1550. {
  1551. Wear,
  1552. Body,
  1553. All
  1554. }
  1555. public class Preset
  1556. {
  1557. public int nVersion;
  1558. public Texture2D texThum;
  1559. public string strFileName;
  1560. public CharacterMgr.PresetType ePreType;
  1561. public List<MaidProp> listMprop = new List<MaidProp>();
  1562. public MaidParts.PartsColor[] aryPartsColor;
  1563. }
  1564. }