CharacterMgr.cs 41 KB

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