CharacterMgr.cs 42 KB

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