CharacterMgr.cs 45 KB

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