Meido.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. using System;
  2. using System.IO;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Xml.Linq;
  7. using UnityEngine;
  8. using static TBody;
  9. namespace COM3D2.MeidoPhotoStudio.Plugin
  10. {
  11. internal class Meido : ISerializable
  12. {
  13. public const int meidoDataVersion = 1000;
  14. public static readonly PoseInfo DefaultPose =
  15. new PoseInfo(Constants.PoseGroupList[0], Constants.PoseDict[Constants.PoseGroupList[0]][0]);
  16. public static readonly string defaultFaceBlendSet = "通常";
  17. public static readonly string[] faceKeys = new string[24]
  18. {
  19. "eyeclose", "eyeclose2", "eyeclose3", "eyebig", "eyeclose6", "eyeclose5", "hitomih",
  20. "hitomis", "mayuha", "mayuw", "mayuup", "mayuv", "mayuvhalf", "moutha", "mouths",
  21. "mouthc", "mouthi", "mouthup", "mouthdw", "mouthhe", "mouthuphalf", "tangout",
  22. "tangup", "tangopen"
  23. };
  24. public static readonly string[] faceToggleKeys = new string[12]
  25. {
  26. // blush, shade, nose up, tears, drool, teeth
  27. "hoho2", "shock", "nosefook", "namida", "yodare", "toothoff",
  28. // cry 1, cry 2, cry 3, blush 1, blush 2, blush 3
  29. "tear1", "tear2", "tear3", "hohos", "hoho", "hohol"
  30. };
  31. public enum Curl
  32. {
  33. front, back, shift
  34. }
  35. private bool initialized;
  36. public event EventHandler<MeidoUpdateEventArgs> UpdateMeido;
  37. public int StockNo { get; }
  38. public Maid Maid { get; private set; }
  39. public TBody Body => Maid.body0;
  40. public MeidoDragPointManager IKManager { get; private set; }
  41. public Texture2D Portrait { get; private set; }
  42. public PoseInfo CachedPose { get; private set; } = DefaultPose;
  43. public string FaceBlendSet { get; private set; } = defaultFaceBlendSet;
  44. public int Slot { get; private set; }
  45. public bool Loading { get; private set; }
  46. public string FirstName => Maid.status.firstName;
  47. public string LastName => Maid.status.lastName;
  48. public bool Busy => Maid.IsBusy && Loading;
  49. public bool CurlingFront => Maid.IsItemChange("skirt", "めくれスカート")
  50. || Maid.IsItemChange("onepiece", "めくれスカート");
  51. public bool CurlingBack => Maid.IsItemChange("skirt", "めくれスカート後ろ")
  52. || Maid.IsItemChange("onepiece", "めくれスカート後ろ");
  53. public bool PantsuShift => Maid.IsItemChange("panz", "パンツずらし")
  54. || Maid.IsItemChange("mizugi", "パンツずらし");
  55. private bool freeLook;
  56. public bool FreeLook
  57. {
  58. get => freeLook;
  59. set
  60. {
  61. if (this.freeLook == value) return;
  62. this.freeLook = value;
  63. Body.trsLookTarget = this.freeLook ? null : GameMain.Instance.MainCamera.transform;
  64. OnUpdateMeido();
  65. }
  66. }
  67. public bool Stop
  68. {
  69. get
  70. {
  71. if (!Body.isLoadedBody) return true;
  72. else return !Maid.GetAnimation().isPlaying;
  73. }
  74. set
  75. {
  76. if (!Body.isLoadedBody || value == Stop) return;
  77. else
  78. {
  79. if (value) Maid.GetAnimation().Stop();
  80. else this.SetPose(this.CachedPose.Pose);
  81. OnUpdateMeido();
  82. }
  83. }
  84. }
  85. public bool IK
  86. {
  87. get => IKManager.Active;
  88. set
  89. {
  90. if (value == IKManager.Active) return;
  91. else IKManager.Active = value;
  92. }
  93. }
  94. public bool Bone
  95. {
  96. get => IKManager.IsBone;
  97. set
  98. {
  99. if (value == Bone) return;
  100. else IKManager.IsBone = value;
  101. OnUpdateMeido();
  102. }
  103. }
  104. public float[] BlendValuesBackup { get; private set; }
  105. public float[] BlendValues { get; private set; }
  106. public Quaternion DefaultEyeRotL { get; private set; }
  107. public Quaternion DefaultEyeRotR { get; private set; }
  108. public Meido(int stockMaidIndex)
  109. {
  110. this.StockNo = stockMaidIndex;
  111. this.Maid = GameMain.Instance.CharacterMgr.GetStockMaid(stockMaidIndex);
  112. this.Portrait = Maid.GetThumIcon();
  113. Maid.boAllProcPropBUSY = false;
  114. IKManager = new MeidoDragPointManager(this);
  115. IKManager.SelectMaid += (s, args) => OnUpdateMeido((MeidoUpdateEventArgs)args);
  116. }
  117. public void BeginLoad()
  118. {
  119. FreeLook = false;
  120. Maid.Visible = true;
  121. Body.boHeadToCam = true;
  122. Body.boEyeToCam = true;
  123. Body.SetBoneHitHeightY(-1000f);
  124. }
  125. public void Load(int slot)
  126. {
  127. Slot = slot;
  128. Loading = true;
  129. if (!Body.isLoadedBody)
  130. {
  131. Maid.DutPropAll();
  132. Maid.AllProcPropSeqStart();
  133. }
  134. GameMain.Instance.StartCoroutine(Load());
  135. }
  136. private IEnumerator Load()
  137. {
  138. while (Maid.IsBusy) yield return null;
  139. yield return new WaitForEndOfFrame();
  140. OnBodyLoad();
  141. }
  142. public void Unload()
  143. {
  144. if (Body.isLoadedBody)
  145. {
  146. DetachAllMpnAttach();
  147. Body.jbMuneL.enabled = true;
  148. Body.jbMuneR.enabled = true;
  149. }
  150. Body.MuneYureL(1f);
  151. Body.MuneYureR(1f);
  152. Body.SetMaskMode(MaskMode.None);
  153. Body.SetBoneHitHeightY(0f);
  154. Maid.Visible = false;
  155. IKManager.Destroy();
  156. }
  157. public void Deactivate()
  158. {
  159. Unload();
  160. Maid.SetPos(Vector3.zero);
  161. Maid.SetRot(Vector3.zero);
  162. Maid.SetPosOffset(Vector3.zero);
  163. Body.transform.localScale = Vector3.one;
  164. Maid.DelPrefabAll();
  165. Maid.ActiveSlotNo = -1;
  166. }
  167. public void SetPose(PoseInfo poseInfo)
  168. {
  169. CachedPose = poseInfo;
  170. SetPose(poseInfo.Pose);
  171. }
  172. public void SetPose(string pose)
  173. {
  174. if (!Body.isLoadedBody) return;
  175. if (pose.StartsWith(Constants.customPosePath))
  176. {
  177. byte[] poseBuffer = File.ReadAllBytes(pose);
  178. string hash = Path.GetFileName(pose).GetHashCode().ToString();
  179. Body.CrossFade(hash, poseBuffer, loop: true, fade: 0f);
  180. }
  181. else
  182. {
  183. string[] poseComponents = pose.Split(',');
  184. pose = poseComponents[0] + ".anm";
  185. Maid.CrossFade(pose, loop: true, val: 0f);
  186. Maid.GetAnimation().Play();
  187. if (poseComponents.Length > 1)
  188. {
  189. Maid.GetAnimation()[pose].time = float.Parse(poseComponents[1]);
  190. Maid.GetAnimation()[pose].speed = 0f;
  191. }
  192. }
  193. Maid.SetAutoTwistAll(true);
  194. SetMune();
  195. }
  196. public void CopyPose(Meido fromMeido)
  197. {
  198. byte[] poseBinary = fromMeido.SerializePose();
  199. string tag = $"copy_{fromMeido.Maid.status.guid}";
  200. Body.CrossFade(tag, poseBinary, false, true, false, 0f);
  201. Maid.SetAutoTwistAll(true);
  202. Maid.transform.rotation = fromMeido.Maid.transform.rotation;
  203. SetMune();
  204. }
  205. public void SetMune(bool drag = false)
  206. {
  207. bool momiOrPaizuri = CachedPose.Pose.Contains("_momi") || CachedPose.Pose.Contains("paizuri_");
  208. float onL = (drag || momiOrPaizuri) ? 0f : 1f;
  209. Body.MuneYureL(onL);
  210. Body.MuneYureR(onL);
  211. Body.jbMuneL.enabled = !drag;
  212. Body.jbMuneR.enabled = !drag;
  213. }
  214. public void SetHandPreset(string filename, bool right)
  215. {
  216. XDocument handDocument = XDocument.Load(filename);
  217. XElement handElement = handDocument.Element("FingerData");
  218. if (handElement.IsEmpty || handElement.Element("GameVersion").IsEmpty
  219. || handElement.Element("RightData").IsEmpty || handElement.Element("BinaryData").IsEmpty
  220. ) return;
  221. Stop = true;
  222. bool rightData = bool.Parse(handElement.Element("RightData").Value);
  223. string base64Data = handElement.Element("BinaryData").Value;
  224. byte[] handData = Convert.FromBase64String(base64Data);
  225. IKManager.DeserializeHand(handData, right, rightData != right);
  226. }
  227. public byte[] SerializePose(bool frameBinary = false)
  228. {
  229. CacheBoneDataArray cache = GetCacheBoneData();
  230. return frameBinary ? cache.GetFrameBinary(true, true) : cache.GetAnmBinary(true, true);
  231. }
  232. public void SetFaceBlendSet(string blendSet)
  233. {
  234. FaceBlendSet = blendSet;
  235. Maid.boMabataki = false;
  236. TMorph morph = Body.Face.morph;
  237. morph.EyeMabataki = 0f;
  238. morph.MulBlendValues(blendSet, 1f);
  239. morph.FixBlendValues_Face();
  240. OnUpdateMeido();
  241. }
  242. public void SetFaceBlendValue(string hash, float value)
  243. {
  244. TMorph morph = Body.Face.morph;
  245. if (hash == "nosefook")
  246. {
  247. morph.boNoseFook = value > 0f;
  248. Maid.boNoseFook = morph.boNoseFook;
  249. }
  250. else
  251. {
  252. bool gp01FBFace = morph.bodyskin.PartsVersion >= 120;
  253. float[] blendValues = hash.StartsWith("eyeclose") && !(gp01FBFace && (hash == "eyeclose3"))
  254. ? this.BlendValuesBackup
  255. : this.BlendValues;
  256. hash = Utility.GP01FbFaceHash(morph, hash);
  257. try
  258. {
  259. blendValues[(int)morph.hash[hash]] = value;
  260. }
  261. catch { }
  262. }
  263. Maid.boMabataki = false;
  264. morph.EyeMabataki = 0f;
  265. morph.FixBlendValues_Face();
  266. }
  267. public void SetMaskMode(MaskMode maskMode)
  268. {
  269. bool invisibleBody = !Body.GetMask(SlotID.body);
  270. Body.SetMaskMode(maskMode);
  271. if (invisibleBody) SetBodyMask(false);
  272. }
  273. public void SetBodyMask(bool enabled)
  274. {
  275. Hashtable table = Utility.GetFieldValue<TBody, Hashtable>(Body, "m_hFoceHide");
  276. foreach (SlotID bodySlot in MaidDressingPane.bodySlots)
  277. {
  278. table[bodySlot] = enabled;
  279. }
  280. if (Body.goSlot[19].m_strModelFileName.Contains("melala_body"))
  281. {
  282. table[SlotID.accHana] = enabled;
  283. }
  284. Body.FixMaskFlag();
  285. Body.FixVisibleFlag(false);
  286. }
  287. public void SetCurling(Curl curling, bool enabled)
  288. {
  289. string[] name = curling == Curl.shift
  290. ? new[] { "panz", "mizugi" }
  291. : new[] { "skirt", "onepiece" };
  292. if (enabled)
  293. {
  294. string action = curling == Curl.shift
  295. ? "パンツずらし" : curling == Curl.front
  296. ? "めくれスカート" : "めくれスカート後ろ";
  297. Maid.ItemChangeTemp(name[0], action);
  298. Maid.ItemChangeTemp(name[1], action);
  299. }
  300. else
  301. {
  302. Maid.ResetProp(name[0]);
  303. Maid.ResetProp(name[1]);
  304. }
  305. Maid.AllProcProp();
  306. }
  307. public void SetMpnProp(MpnAttachProp prop, bool detach)
  308. {
  309. if (detach) Maid.ResetProp(prop.Tag, false);
  310. else Maid.SetProp(prop.Tag, prop.MenuFile, 0, true);
  311. Maid.AllProcProp();
  312. }
  313. public void DetachAllMpnAttach(bool unload = false)
  314. {
  315. Maid.ResetProp(MPN.kousoku_lower, false);
  316. Maid.ResetProp(MPN.kousoku_upper, false);
  317. Maid.AllProcProp();
  318. }
  319. private CacheBoneDataArray GetCacheBoneData()
  320. {
  321. CacheBoneDataArray cache = this.Maid.gameObject.GetComponent<CacheBoneDataArray>();
  322. if (cache == null)
  323. {
  324. cache = this.Maid.gameObject.AddComponent<CacheBoneDataArray>();
  325. cache.CreateCache(this.Maid.body0.GetBone("Bip01"));
  326. }
  327. return cache;
  328. }
  329. private void OnBodyLoad()
  330. {
  331. if (!initialized)
  332. {
  333. TMorph faceMorph = Body.Face.morph;
  334. BlendValuesBackup = Utility.GetFieldValue<TMorph, float[]>(faceMorph, "BlendValuesBackup");
  335. BlendValues = Utility.GetFieldValue<TMorph, float[]>(faceMorph, "BlendValues");
  336. DefaultEyeRotL = Body.quaDefEyeL;
  337. DefaultEyeRotR = Body.quaDefEyeR;
  338. initialized = true;
  339. }
  340. IKManager.Initialize();
  341. IK = true;
  342. Stop = false;
  343. Bone = false;
  344. Loading = false;
  345. }
  346. public void OnUpdateMeido(MeidoUpdateEventArgs args = null)
  347. {
  348. this.UpdateMeido?.Invoke(this, args ?? MeidoUpdateEventArgs.Empty);
  349. }
  350. public void Serialize(BinaryWriter binaryWriter)
  351. {
  352. using (MemoryStream memoryStream = new MemoryStream())
  353. using (BinaryWriter tempWriter = new BinaryWriter(memoryStream))
  354. {
  355. // transform
  356. tempWriter.WriteVector3(Maid.transform.position);
  357. tempWriter.WriteQuaternion(Maid.transform.rotation);
  358. tempWriter.WriteVector3(Maid.transform.localScale);
  359. // pose
  360. byte[] poseBuffer = SerializePose(true);
  361. tempWriter.Write(poseBuffer.Length);
  362. tempWriter.Write(poseBuffer);
  363. CachedPose.Serialize(tempWriter);
  364. // eye direction
  365. tempWriter.WriteQuaternion(Body.quaDefEyeL * Quaternion.Inverse(DefaultEyeRotL));
  366. tempWriter.WriteQuaternion(Body.quaDefEyeR * Quaternion.Inverse(DefaultEyeRotR));
  367. // free look
  368. tempWriter.Write(FreeLook);
  369. tempWriter.WriteVector3(Body.offsetLookTarget);
  370. // face
  371. SerializeFace(tempWriter);
  372. // body visible
  373. tempWriter.Write(Body.GetMask(SlotID.body));
  374. // clothing
  375. foreach (SlotID clothingSlot in MaidDressingPane.clothingSlots)
  376. {
  377. bool value = true;
  378. if (clothingSlot == SlotID.wear)
  379. {
  380. if (MaidDressingPane.wearSlots.Any(slot => Body.GetSlotLoaded(slot)))
  381. {
  382. value = MaidDressingPane.wearSlots.Any(slot => Body.GetMask(slot));
  383. }
  384. }
  385. else if (clothingSlot == SlotID.megane)
  386. {
  387. SlotID[] slots = new[] { SlotID.megane, SlotID.accHead };
  388. if (slots.Any(slot => Body.GetSlotLoaded(slot)))
  389. {
  390. value = slots.Any(slot => Body.GetMask(slot));
  391. }
  392. }
  393. else if (Body.GetSlotLoaded(clothingSlot))
  394. {
  395. value = Body.GetMask(clothingSlot);
  396. }
  397. tempWriter.Write(value);
  398. }
  399. // zurashi and mekure
  400. tempWriter.Write(CurlingFront);
  401. tempWriter.Write(CurlingBack);
  402. tempWriter.Write(PantsuShift);
  403. bool hasKousokuUpper = Body.GetSlotLoaded(SlotID.kousoku_upper);
  404. tempWriter.Write(hasKousokuUpper);
  405. if (hasKousokuUpper) tempWriter.Write(Maid.GetProp(MPN.kousoku_upper).strTempFileName);
  406. bool hasKousokuLower = Body.GetSlotLoaded(SlotID.kousoku_lower);
  407. tempWriter.Write(hasKousokuLower);
  408. if (hasKousokuLower) tempWriter.Write(Maid.GetProp(MPN.kousoku_lower).strTempFileName);
  409. binaryWriter.Write(memoryStream.Length);
  410. binaryWriter.Write(memoryStream.ToArray());
  411. }
  412. }
  413. private void SerializeFace(BinaryWriter binaryWriter)
  414. {
  415. binaryWriter.Write("MPS_FACE");
  416. TMorph morph = Maid.body0.Face.morph;
  417. bool gp01FBFace = morph.bodyskin.PartsVersion >= 120;
  418. foreach (string hash in faceKeys)
  419. {
  420. float[] blendValues = hash.StartsWith("eyeclose") && !(gp01FBFace && (hash == "eyeclose3"))
  421. ? this.BlendValuesBackup
  422. : this.BlendValues;
  423. string faceKey = Utility.GP01FbFaceHash(morph, hash);
  424. try
  425. {
  426. float value = blendValues[(int)morph.hash[faceKey]];
  427. binaryWriter.Write(hash);
  428. binaryWriter.Write(value);
  429. }
  430. catch { }
  431. }
  432. foreach (string hash in faceToggleKeys)
  433. {
  434. bool value = this.BlendValues[(int)morph.hash[hash]] > 0f;
  435. if (hash == "nosefook") value = morph.boNoseFook;
  436. binaryWriter.Write(hash);
  437. binaryWriter.Write(value);
  438. }
  439. binaryWriter.Write("END_FACE");
  440. }
  441. public void Deserialize(BinaryReader binaryReader) => Deserialize(binaryReader, meidoDataVersion, false);
  442. public void Deserialize(BinaryReader binaryReader, int dataVersion, bool mmScene)
  443. {
  444. Maid.GetAnimation().Stop();
  445. DetachAllMpnAttach();
  446. binaryReader.ReadInt64(); // meido buffer length
  447. // transform
  448. Maid.transform.position = binaryReader.ReadVector3();
  449. Maid.transform.rotation = binaryReader.ReadQuaternion();
  450. Maid.transform.localScale = binaryReader.ReadVector3();
  451. // pose
  452. if (mmScene) IKManager.Deserialize(binaryReader);
  453. else
  454. {
  455. int poseBufferLength = binaryReader.ReadInt32();
  456. byte[] poseBuffer = binaryReader.ReadBytes(poseBufferLength);
  457. GetCacheBoneData().SetFrameBinary(poseBuffer);
  458. }
  459. CachedPose = PoseInfo.Deserialize(binaryReader);
  460. // eye direction
  461. Body.quaDefEyeL = binaryReader.ReadQuaternion() * DefaultEyeRotL;
  462. Body.quaDefEyeR = binaryReader.ReadQuaternion() * DefaultEyeRotR;
  463. // free look
  464. FreeLook = binaryReader.ReadBoolean();
  465. Vector3 lookTarget = binaryReader.ReadVector3();
  466. if (FreeLook) Body.offsetLookTarget = lookTarget;
  467. // face
  468. DeserializeFace(binaryReader);
  469. // body visible
  470. SetBodyMask(binaryReader.ReadBoolean());
  471. // clothing
  472. foreach (SlotID clothingSlot in MaidDressingPane.clothingSlots)
  473. {
  474. bool value = binaryReader.ReadBoolean();
  475. if (clothingSlot == SlotID.wear)
  476. {
  477. Body.SetMask(SlotID.wear, value);
  478. Body.SetMask(SlotID.mizugi, value);
  479. Body.SetMask(SlotID.onepiece, value);
  480. }
  481. else if (clothingSlot == SlotID.megane)
  482. {
  483. Body.SetMask(SlotID.megane, value);
  484. Body.SetMask(SlotID.accHead, value);
  485. }
  486. else if (Body.GetSlotLoaded(clothingSlot))
  487. {
  488. Body.SetMask(clothingSlot, value);
  489. }
  490. }
  491. // zurashi and mekure
  492. bool curlingFront = binaryReader.ReadBoolean();
  493. bool curlingBack = binaryReader.ReadBoolean();
  494. if (CurlingFront != curlingFront) SetCurling(Curl.front, curlingFront);
  495. if (CurlingBack != curlingBack) SetCurling(Curl.back, curlingBack);
  496. SetCurling(Curl.shift, binaryReader.ReadBoolean());
  497. bool hasKousokuUpper = binaryReader.ReadBoolean();
  498. if (hasKousokuUpper)
  499. {
  500. try
  501. {
  502. SetMpnProp(new MpnAttachProp(MPN.kousoku_upper, binaryReader.ReadString()), false);
  503. }
  504. catch { }
  505. }
  506. bool hasKousokuLower = binaryReader.ReadBoolean();
  507. if (hasKousokuLower)
  508. {
  509. try
  510. {
  511. SetMpnProp(new MpnAttachProp(MPN.kousoku_lower, binaryReader.ReadString()), false);
  512. }
  513. catch { }
  514. }
  515. // OnUpdateMeido();
  516. }
  517. private void DeserializeFace(BinaryReader binaryReader)
  518. {
  519. binaryReader.ReadString(); // read face header
  520. TMorph morph = Maid.body0.Face.morph;
  521. bool gp01FBFace = morph.bodyskin.PartsVersion >= 120;
  522. HashSet<string> faceKeys = new HashSet<string>(Meido.faceKeys);
  523. string header;
  524. while ((header = binaryReader.ReadString()) != "END_FACE")
  525. {
  526. if (faceKeys.Contains(header))
  527. {
  528. float[] blendValues = header.StartsWith("eyeclose") && !(gp01FBFace && (header == "eyeclose3"))
  529. ? this.BlendValuesBackup
  530. : this.BlendValues;
  531. string hash = Utility.GP01FbFaceHash(morph, header);
  532. try
  533. {
  534. float value = binaryReader.ReadSingle();
  535. blendValues[(int)morph.hash[hash]] = value;
  536. }
  537. catch { }
  538. }
  539. else
  540. {
  541. bool value = binaryReader.ReadBoolean();
  542. if (header == "nosefook") this.Maid.boNoseFook = value;
  543. else this.BlendValues[(int)morph.hash[header]] = value ? 1f : 0f;
  544. }
  545. }
  546. Maid.boMabataki = false;
  547. morph.EyeMabataki = 0f;
  548. morph.FixBlendValues_Face();
  549. }
  550. }
  551. public struct PoseInfo
  552. {
  553. public string PoseGroup { get; }
  554. public string Pose { get; }
  555. public bool CustomPose { get; }
  556. public PoseInfo(string poseGroup, string pose, bool customPose = false)
  557. {
  558. this.PoseGroup = poseGroup;
  559. this.Pose = pose;
  560. this.CustomPose = customPose;
  561. }
  562. public void Serialize(BinaryWriter binaryWriter)
  563. {
  564. binaryWriter.Write(PoseGroup);
  565. binaryWriter.Write(Pose);
  566. binaryWriter.Write(CustomPose);
  567. }
  568. public static PoseInfo Deserialize(BinaryReader binaryReader)
  569. {
  570. return new PoseInfo
  571. (
  572. binaryReader.ReadString(),
  573. binaryReader.ReadString(),
  574. binaryReader.ReadBoolean()
  575. );
  576. }
  577. }
  578. }