MaidProp.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. [Serializable]
  5. public class MaidProp
  6. {
  7. public bool Serialize(BinaryWriter f_bwWrite)
  8. {
  9. f_bwWrite.Write("CM3D2_MPROP");
  10. f_bwWrite.Write(1130);
  11. f_bwWrite.Write(this.idx);
  12. f_bwWrite.Write(this.name);
  13. f_bwWrite.Write(this.type);
  14. f_bwWrite.Write(this.value_Default);
  15. f_bwWrite.Write(this.value);
  16. f_bwWrite.Write(this.temp_value);
  17. f_bwWrite.Write(this.value_LinkMAX);
  18. f_bwWrite.Write(this.strFileName);
  19. f_bwWrite.Write(this.nFileNameRID);
  20. f_bwWrite.Write(this.boDut);
  21. f_bwWrite.Write(this.max);
  22. f_bwWrite.Write(this.min);
  23. f_bwWrite.Write((this.listSubProp != null) ? this.listSubProp.Count : 0);
  24. if (this.listSubProp != null)
  25. {
  26. for (int i = 0; i < this.listSubProp.Count; i++)
  27. {
  28. SubProp subProp = this.listSubProp[i];
  29. f_bwWrite.Write(subProp != null);
  30. if (subProp != null)
  31. {
  32. f_bwWrite.Write(subProp.bDut);
  33. f_bwWrite.Write(subProp.strFileName);
  34. f_bwWrite.Write(subProp.nFileNameRID);
  35. f_bwWrite.Write(subProp.fTexMulAlpha);
  36. }
  37. }
  38. }
  39. f_bwWrite.Write(this.m_dicTBodySkinPos.Count);
  40. foreach (KeyValuePair<TBody.SlotID, KeyValuePair<int, BoneAttachPos>> keyValuePair in this.m_dicTBodySkinPos)
  41. {
  42. f_bwWrite.Write((int)keyValuePair.Key);
  43. f_bwWrite.Write(keyValuePair.Value.Key);
  44. f_bwWrite.Write(keyValuePair.Value.Value.bEnable);
  45. f_bwWrite.Write(keyValuePair.Value.Value.pss.position.x);
  46. f_bwWrite.Write(keyValuePair.Value.Value.pss.position.y);
  47. f_bwWrite.Write(keyValuePair.Value.Value.pss.position.z);
  48. f_bwWrite.Write(keyValuePair.Value.Value.pss.rotation.x);
  49. f_bwWrite.Write(keyValuePair.Value.Value.pss.rotation.y);
  50. f_bwWrite.Write(keyValuePair.Value.Value.pss.rotation.z);
  51. f_bwWrite.Write(keyValuePair.Value.Value.pss.rotation.w);
  52. f_bwWrite.Write(keyValuePair.Value.Value.pss.scale.x);
  53. f_bwWrite.Write(keyValuePair.Value.Value.pss.scale.y);
  54. f_bwWrite.Write(keyValuePair.Value.Value.pss.scale.z);
  55. }
  56. f_bwWrite.Write(this.m_dicTBodyAttachPos.Count);
  57. foreach (KeyValuePair<TBody.SlotID, Dictionary<string, KeyValuePair<int, VtxAttachPos>>> keyValuePair2 in this.m_dicTBodyAttachPos)
  58. {
  59. f_bwWrite.Write((int)keyValuePair2.Key);
  60. f_bwWrite.Write(keyValuePair2.Value.Count);
  61. foreach (KeyValuePair<string, KeyValuePair<int, VtxAttachPos>> keyValuePair3 in keyValuePair2.Value)
  62. {
  63. f_bwWrite.Write(keyValuePair3.Key);
  64. f_bwWrite.Write(keyValuePair3.Value.Key);
  65. VtxAttachPos vtxAttachPos = keyValuePair3.Value.Value;
  66. f_bwWrite.Write(vtxAttachPos.bEnable);
  67. f_bwWrite.Write(vtxAttachPos.vtxcount);
  68. f_bwWrite.Write(vtxAttachPos.vidx);
  69. f_bwWrite.Write(vtxAttachPos.prs.position.x);
  70. f_bwWrite.Write(vtxAttachPos.prs.position.y);
  71. f_bwWrite.Write(vtxAttachPos.prs.position.z);
  72. f_bwWrite.Write(vtxAttachPos.prs.rotation.x);
  73. f_bwWrite.Write(vtxAttachPos.prs.rotation.y);
  74. f_bwWrite.Write(vtxAttachPos.prs.rotation.z);
  75. f_bwWrite.Write(vtxAttachPos.prs.rotation.w);
  76. f_bwWrite.Write(vtxAttachPos.prs.scale.x);
  77. f_bwWrite.Write(vtxAttachPos.prs.scale.y);
  78. f_bwWrite.Write(vtxAttachPos.prs.scale.z);
  79. }
  80. }
  81. f_bwWrite.Write(this.m_dicMaterialProp.Count);
  82. foreach (KeyValuePair<TBody.SlotID, KeyValuePair<int, MatPropSave>> keyValuePair4 in this.m_dicMaterialProp)
  83. {
  84. f_bwWrite.Write((int)keyValuePair4.Key);
  85. f_bwWrite.Write(keyValuePair4.Value.Key);
  86. f_bwWrite.Write(keyValuePair4.Value.Value.nMatNo);
  87. f_bwWrite.Write(keyValuePair4.Value.Value.strPropName);
  88. f_bwWrite.Write(keyValuePair4.Value.Value.strTypeName);
  89. f_bwWrite.Write(keyValuePair4.Value.Value.strValue);
  90. }
  91. f_bwWrite.Write(this.m_dicBoneLength.Count);
  92. foreach (KeyValuePair<TBody.SlotID, KeyValuePair<int, Dictionary<string, float>>> keyValuePair5 in this.m_dicBoneLength)
  93. {
  94. f_bwWrite.Write((int)keyValuePair5.Key);
  95. f_bwWrite.Write(keyValuePair5.Value.Key);
  96. f_bwWrite.Write(keyValuePair5.Value.Value.Count);
  97. foreach (KeyValuePair<string, float> keyValuePair6 in keyValuePair5.Value.Value)
  98. {
  99. f_bwWrite.Write(keyValuePair6.Key);
  100. f_bwWrite.Write(keyValuePair6.Value);
  101. }
  102. }
  103. return true;
  104. }
  105. public bool SerializeLowCapacity(BinaryWriter writer)
  106. {
  107. writer.Write(this.value);
  108. writer.Write(this.nFileNameRID);
  109. return true;
  110. }
  111. public bool Deserialize(BinaryReader f_brRead)
  112. {
  113. NDebug.Assert(f_brRead.ReadString() == "CM3D2_MPROP", "メイドプロパティのヘッダーが不正です。");
  114. int num = f_brRead.ReadInt32();
  115. this.idx = f_brRead.ReadInt32();
  116. if (num <= 110 && 10 <= this.idx)
  117. {
  118. this.idx += 2;
  119. }
  120. this.name = f_brRead.ReadString();
  121. this.idx = (int)Enum.Parse(typeof(MPN), this.name, true);
  122. this.type = f_brRead.ReadInt32();
  123. this.value_Default = f_brRead.ReadInt32();
  124. this.value = f_brRead.ReadInt32();
  125. if (101 <= num)
  126. {
  127. this.temp_value = f_brRead.ReadInt32();
  128. }
  129. this.value_LinkMAX = f_brRead.ReadInt32();
  130. this.strFileName = f_brRead.ReadString();
  131. this.nFileNameRID = f_brRead.ReadInt32();
  132. this.boDut = f_brRead.ReadBoolean();
  133. this.max = f_brRead.ReadInt32();
  134. this.min = f_brRead.ReadInt32();
  135. if (this.listSubProp != null && this.listSubProp.Count != 0)
  136. {
  137. this.listSubProp = null;
  138. }
  139. if (200 <= num)
  140. {
  141. int num2 = f_brRead.ReadInt32();
  142. if (num2 != 0)
  143. {
  144. this.listSubProp = new List<SubProp>();
  145. }
  146. for (int i = 0; i < num2; i++)
  147. {
  148. bool flag = f_brRead.ReadBoolean();
  149. if (flag)
  150. {
  151. SubProp subProp = new SubProp();
  152. subProp.bDut = f_brRead.ReadBoolean();
  153. subProp.strFileName = f_brRead.ReadString();
  154. subProp.nFileNameRID = f_brRead.ReadInt32();
  155. if (211 <= num)
  156. {
  157. subProp.fTexMulAlpha = f_brRead.ReadSingle();
  158. }
  159. subProp.bDut = true;
  160. this.listSubProp.Add(subProp);
  161. }
  162. else
  163. {
  164. this.listSubProp.Add(null);
  165. }
  166. }
  167. }
  168. else if (this.type == 3 && (this.name == "acctatoo" || this.name == "hokuro") && !string.IsNullOrEmpty(this.strFileName) && !this.strFileName.Contains("_del"))
  169. {
  170. this.listSubProp = new List<SubProp>();
  171. SubProp subProp2 = new SubProp();
  172. subProp2.bDut = true;
  173. subProp2.strFileName = this.strFileName;
  174. subProp2.nFileNameRID = this.nFileNameRID;
  175. this.listSubProp.Add(subProp2);
  176. this.strFileName = CM3.dicDelItem[(MPN)Enum.Parse(typeof(MPN), this.name, true)];
  177. this.nFileNameRID = this.strFileName.ToLower().GetHashCode();
  178. }
  179. if (this.name == "eye_hi" && string.IsNullOrEmpty(this.strFileName))
  180. {
  181. this.strFileName = "_I_SkinHi.menu";
  182. this.nFileNameRID = this.strFileName.ToLower().GetHashCode();
  183. }
  184. else if (this.name == "mayu" && string.IsNullOrEmpty(this.strFileName))
  185. {
  186. this.strFileName = "_I_mayu_001_mugen.menu";
  187. this.nFileNameRID = this.strFileName.ToLower().GetHashCode();
  188. }
  189. if (num <= 208 && this.idx == 44 && this.strFileName.ToLower() == "_I_acctatoo_del.menu".ToLower())
  190. {
  191. this.strFileName = CM3.dicDelItem[MPN.accnail];
  192. this.nFileNameRID = this.strFileName.ToLower().GetHashCode();
  193. }
  194. this.m_dicTBodySkinPos.Clear();
  195. this.m_dicTBodyAttachPos.Clear();
  196. this.m_dicMaterialProp.Clear();
  197. this.m_dicBoneLength.Clear();
  198. if (200 <= num)
  199. {
  200. int num3 = f_brRead.ReadInt32();
  201. for (int j = 0; j < num3; j++)
  202. {
  203. TBody.SlotID key = (TBody.SlotID)f_brRead.ReadInt32();
  204. int key2 = f_brRead.ReadInt32();
  205. BoneAttachPos boneAttachPos = new BoneAttachPos();
  206. boneAttachPos.bEnable = f_brRead.ReadBoolean();
  207. boneAttachPos.pss.position.x = f_brRead.ReadSingle();
  208. boneAttachPos.pss.position.y = f_brRead.ReadSingle();
  209. boneAttachPos.pss.position.z = f_brRead.ReadSingle();
  210. boneAttachPos.pss.rotation.x = f_brRead.ReadSingle();
  211. boneAttachPos.pss.rotation.y = f_brRead.ReadSingle();
  212. boneAttachPos.pss.rotation.z = f_brRead.ReadSingle();
  213. boneAttachPos.pss.rotation.w = f_brRead.ReadSingle();
  214. boneAttachPos.pss.scale.x = f_brRead.ReadSingle();
  215. boneAttachPos.pss.scale.y = f_brRead.ReadSingle();
  216. boneAttachPos.pss.scale.z = f_brRead.ReadSingle();
  217. KeyValuePair<int, BoneAttachPos> keyValuePair = new KeyValuePair<int, BoneAttachPos>(key2, boneAttachPos);
  218. this.m_dicTBodySkinPos[key] = keyValuePair;
  219. }
  220. int num4 = f_brRead.ReadInt32();
  221. for (int k = 0; k < num4; k++)
  222. {
  223. TBody.SlotID key3 = (TBody.SlotID)f_brRead.ReadInt32();
  224. int num5 = f_brRead.ReadInt32();
  225. Dictionary<string, KeyValuePair<int, VtxAttachPos>> dictionary = new Dictionary<string, KeyValuePair<int, VtxAttachPos>>();
  226. for (int l = 0; l < num5; l++)
  227. {
  228. string key4 = f_brRead.ReadString();
  229. int key5 = f_brRead.ReadInt32();
  230. VtxAttachPos vtxAttachPos = new VtxAttachPos();
  231. vtxAttachPos.bEnable = f_brRead.ReadBoolean();
  232. vtxAttachPos.vtxcount = f_brRead.ReadInt32();
  233. vtxAttachPos.vidx = f_brRead.ReadInt32();
  234. vtxAttachPos.prs.position.x = f_brRead.ReadSingle();
  235. vtxAttachPos.prs.position.y = f_brRead.ReadSingle();
  236. vtxAttachPos.prs.position.z = f_brRead.ReadSingle();
  237. vtxAttachPos.prs.rotation.x = f_brRead.ReadSingle();
  238. vtxAttachPos.prs.rotation.y = f_brRead.ReadSingle();
  239. vtxAttachPos.prs.rotation.z = f_brRead.ReadSingle();
  240. vtxAttachPos.prs.rotation.w = f_brRead.ReadSingle();
  241. vtxAttachPos.prs.scale.x = f_brRead.ReadSingle();
  242. vtxAttachPos.prs.scale.y = f_brRead.ReadSingle();
  243. vtxAttachPos.prs.scale.z = f_brRead.ReadSingle();
  244. dictionary.Add(key4, new KeyValuePair<int, VtxAttachPos>(key5, vtxAttachPos));
  245. }
  246. this.m_dicTBodyAttachPos.Add(key3, dictionary);
  247. }
  248. int num6 = f_brRead.ReadInt32();
  249. for (int m = 0; m < num6; m++)
  250. {
  251. TBody.SlotID slotID = (TBody.SlotID)f_brRead.ReadInt32();
  252. int key6 = f_brRead.ReadInt32();
  253. MatPropSave matPropSave = new MatPropSave();
  254. matPropSave.nMatNo = f_brRead.ReadInt32();
  255. matPropSave.strPropName = f_brRead.ReadString();
  256. matPropSave.strTypeName = f_brRead.ReadString();
  257. matPropSave.strValue = f_brRead.ReadString();
  258. if (num < 204 && slotID == TBody.SlotID.head && matPropSave.nMatNo == 3 && (matPropSave.strPropName == "_ZTest" || matPropSave.strPropName == "ZTest"))
  259. {
  260. matPropSave.strPropName = "_ZTest2";
  261. matPropSave.strValue = ((!(matPropSave.strValue == "8")) ? "1" : "7");
  262. }
  263. this.m_dicMaterialProp.Add(slotID, new KeyValuePair<int, MatPropSave>(key6, matPropSave));
  264. }
  265. if (213 <= num)
  266. {
  267. int num7 = f_brRead.ReadInt32();
  268. for (int n = 0; n < num7; n++)
  269. {
  270. TBody.SlotID key7 = (TBody.SlotID)f_brRead.ReadInt32();
  271. int key8 = f_brRead.ReadInt32();
  272. int num8 = f_brRead.ReadInt32();
  273. Dictionary<string, float> dictionary2 = new Dictionary<string, float>();
  274. for (int num9 = 0; num9 < num8; num9++)
  275. {
  276. string key9 = f_brRead.ReadString();
  277. float num10 = f_brRead.ReadSingle();
  278. dictionary2.Add(key9, num10);
  279. }
  280. this.m_dicBoneLength[key7] = new KeyValuePair<int, Dictionary<string, float>>(key8, dictionary2);
  281. }
  282. }
  283. }
  284. if (num < 200 && this.idx == 37 && Path.GetFileNameWithoutExtension(this.strFileName.ToLower()) == "hair_r095_i_")
  285. {
  286. this.strFileName = "hair_r110_i_.menu";
  287. this.nFileNameRID = this.strFileName.ToLower().GetHashCode();
  288. }
  289. this.boDut = true;
  290. this.boTempDut = false;
  291. this.strTempFileName = string.Empty;
  292. this.nTempFileNameRID = 0;
  293. return true;
  294. }
  295. public bool DeserializeLowCapacity(BinaryReader reader)
  296. {
  297. this.value = reader.ReadInt32();
  298. this.nFileNameRID = reader.ReadInt32();
  299. if (this.nFileNameRID != 0)
  300. {
  301. this.strFileName = ((!GameUty.RidMenuDic.ContainsKey(this.nFileNameRID)) ? string.Empty : GameUty.RidMenuDic[this.nFileNameRID]);
  302. if (string.IsNullOrEmpty(this.strFileName))
  303. {
  304. this.nFileNameRID = 0;
  305. }
  306. }
  307. else
  308. {
  309. this.strFileName = string.Empty;
  310. }
  311. this.boDut = true;
  312. this.boTempDut = false;
  313. this.strTempFileName = string.Empty;
  314. this.nTempFileNameRID = 0;
  315. return true;
  316. }
  317. public int idx;
  318. public string name;
  319. public int type;
  320. public int value_Default;
  321. public int value;
  322. public int temp_value;
  323. public int value_LinkMAX;
  324. public string strFileName = string.Empty;
  325. public int nFileNameRID;
  326. public string strTempFileName = string.Empty;
  327. public int nTempFileNameRID;
  328. public bool boDut;
  329. public bool boTempDut;
  330. public int max;
  331. public int min;
  332. public bool bSubDut;
  333. public List<SubProp> listSubProp;
  334. public bool bNoScale;
  335. public bool boAdjustDut;
  336. public Dictionary<TBody.SlotID, KeyValuePair<int, BoneAttachPos>> m_dicTBodySkinPos = new Dictionary<TBody.SlotID, KeyValuePair<int, BoneAttachPos>>();
  337. public Dictionary<TBody.SlotID, Dictionary<string, KeyValuePair<int, VtxAttachPos>>> m_dicTBodyAttachPos = new Dictionary<TBody.SlotID, Dictionary<string, KeyValuePair<int, VtxAttachPos>>>();
  338. public Dictionary<TBody.SlotID, KeyValuePair<int, MatPropSave>> m_dicMaterialProp = new Dictionary<TBody.SlotID, KeyValuePair<int, MatPropSave>>();
  339. public Dictionary<TBody.SlotID, KeyValuePair<int, Dictionary<string, float>>> m_dicBoneLength = new Dictionary<TBody.SlotID, KeyValuePair<int, Dictionary<string, float>>>();
  340. }