MaidProp.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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(MaidProp.MAID_PROP_VER);
  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. f_bwWrite.Write(this.isCrcParts);
  104. return true;
  105. }
  106. public bool SerializeLowCapacity(BinaryWriter writer)
  107. {
  108. writer.Write(this.value);
  109. writer.Write(this.nFileNameRID);
  110. return true;
  111. }
  112. public bool Deserialize(BinaryReader f_brRead)
  113. {
  114. NDebug.Assert(f_brRead.ReadString() == "CM3D2_MPROP", "メイドプロパティのヘッダーが不正です。");
  115. int num = f_brRead.ReadInt32();
  116. this.idx = f_brRead.ReadInt32();
  117. if (num <= 110 && 10 <= this.idx)
  118. {
  119. this.idx += 2;
  120. }
  121. this.name = f_brRead.ReadString();
  122. this.idx = (int)Enum.Parse(typeof(MPN), this.name, true);
  123. this.type = f_brRead.ReadInt32();
  124. this.value_Default = f_brRead.ReadInt32();
  125. this.value = f_brRead.ReadInt32();
  126. if (101 <= num)
  127. {
  128. this.temp_value = f_brRead.ReadInt32();
  129. }
  130. this.value_LinkMAX = f_brRead.ReadInt32();
  131. this.strFileName = f_brRead.ReadString();
  132. this.nFileNameRID = f_brRead.ReadInt32();
  133. this.boDut = f_brRead.ReadBoolean();
  134. this.max = f_brRead.ReadInt32();
  135. this.min = f_brRead.ReadInt32();
  136. if (!string.IsNullOrEmpty(this.strFileName))
  137. {
  138. this.nFileNameRID = this.strFileName.ToLower().GetHashCode();
  139. }
  140. if (this.listSubProp != null && this.listSubProp.Count != 0)
  141. {
  142. this.listSubProp = null;
  143. }
  144. if (200 <= num)
  145. {
  146. int num2 = f_brRead.ReadInt32();
  147. if (num2 != 0)
  148. {
  149. this.listSubProp = new List<SubProp>();
  150. }
  151. for (int i = 0; i < num2; i++)
  152. {
  153. bool flag = f_brRead.ReadBoolean();
  154. if (flag)
  155. {
  156. SubProp subProp = new SubProp();
  157. subProp.bDut = f_brRead.ReadBoolean();
  158. subProp.strFileName = f_brRead.ReadString();
  159. subProp.nFileNameRID = f_brRead.ReadInt32();
  160. if (211 <= num)
  161. {
  162. subProp.fTexMulAlpha = f_brRead.ReadSingle();
  163. }
  164. subProp.bDut = true;
  165. this.listSubProp.Add(subProp);
  166. }
  167. else
  168. {
  169. this.listSubProp.Add(null);
  170. }
  171. }
  172. }
  173. else if (this.type == 3 && (this.name == "acctatoo" || this.name == "hokuro") && !string.IsNullOrEmpty(this.strFileName) && !this.strFileName.Contains("_del"))
  174. {
  175. this.listSubProp = new List<SubProp>();
  176. SubProp subProp2 = new SubProp();
  177. subProp2.bDut = true;
  178. subProp2.strFileName = this.strFileName;
  179. subProp2.nFileNameRID = this.nFileNameRID;
  180. this.listSubProp.Add(subProp2);
  181. this.strFileName = CM3.dicDelItem[(MPN)Enum.Parse(typeof(MPN), this.name, true)];
  182. this.nFileNameRID = this.strFileName.ToLower().GetHashCode();
  183. }
  184. if (num < 2000)
  185. {
  186. if (this.name == "eye_hi" && string.IsNullOrEmpty(this.strFileName))
  187. {
  188. this.strFileName = "_I_SkinHi.menu";
  189. this.nFileNameRID = this.strFileName.ToLower().GetHashCode();
  190. }
  191. else if (this.name == "mayu" && string.IsNullOrEmpty(this.strFileName))
  192. {
  193. this.strFileName = "_I_mayu_001_mugen.menu";
  194. this.nFileNameRID = this.strFileName.ToLower().GetHashCode();
  195. }
  196. }
  197. if (num <= 208 && this.idx == 150 && this.strFileName.ToLower() == "_I_acctatoo_del.menu".ToLower())
  198. {
  199. this.strFileName = CM3.dicDelItem[MPN.accnail];
  200. this.nFileNameRID = this.strFileName.ToLower().GetHashCode();
  201. }
  202. this.m_dicTBodySkinPos.Clear();
  203. this.m_dicTBodyAttachPos.Clear();
  204. this.m_dicMaterialProp.Clear();
  205. this.m_dicBoneLength.Clear();
  206. if (200 <= num)
  207. {
  208. int num3 = f_brRead.ReadInt32();
  209. for (int j = 0; j < num3; j++)
  210. {
  211. TBody.SlotID key = (TBody.SlotID)f_brRead.ReadInt32();
  212. int key2 = f_brRead.ReadInt32();
  213. BoneAttachPos boneAttachPos = new BoneAttachPos();
  214. boneAttachPos.bEnable = f_brRead.ReadBoolean();
  215. boneAttachPos.pss.position.x = f_brRead.ReadSingle();
  216. boneAttachPos.pss.position.y = f_brRead.ReadSingle();
  217. boneAttachPos.pss.position.z = f_brRead.ReadSingle();
  218. boneAttachPos.pss.rotation.x = f_brRead.ReadSingle();
  219. boneAttachPos.pss.rotation.y = f_brRead.ReadSingle();
  220. boneAttachPos.pss.rotation.z = f_brRead.ReadSingle();
  221. boneAttachPos.pss.rotation.w = f_brRead.ReadSingle();
  222. boneAttachPos.pss.scale.x = f_brRead.ReadSingle();
  223. boneAttachPos.pss.scale.y = f_brRead.ReadSingle();
  224. boneAttachPos.pss.scale.z = f_brRead.ReadSingle();
  225. KeyValuePair<int, BoneAttachPos> keyValuePair = new KeyValuePair<int, BoneAttachPos>(key2, boneAttachPos);
  226. this.m_dicTBodySkinPos[key] = keyValuePair;
  227. }
  228. int num4 = f_brRead.ReadInt32();
  229. for (int k = 0; k < num4; k++)
  230. {
  231. TBody.SlotID key3 = (TBody.SlotID)f_brRead.ReadInt32();
  232. int num5 = f_brRead.ReadInt32();
  233. Dictionary<string, KeyValuePair<int, VtxAttachPos>> dictionary = new Dictionary<string, KeyValuePair<int, VtxAttachPos>>();
  234. for (int l = 0; l < num5; l++)
  235. {
  236. string key4 = f_brRead.ReadString();
  237. int key5 = f_brRead.ReadInt32();
  238. VtxAttachPos vtxAttachPos = new VtxAttachPos();
  239. vtxAttachPos.bEnable = f_brRead.ReadBoolean();
  240. vtxAttachPos.vtxcount = f_brRead.ReadInt32();
  241. vtxAttachPos.vidx = f_brRead.ReadInt32();
  242. vtxAttachPos.prs.position.x = f_brRead.ReadSingle();
  243. vtxAttachPos.prs.position.y = f_brRead.ReadSingle();
  244. vtxAttachPos.prs.position.z = f_brRead.ReadSingle();
  245. vtxAttachPos.prs.rotation.x = f_brRead.ReadSingle();
  246. vtxAttachPos.prs.rotation.y = f_brRead.ReadSingle();
  247. vtxAttachPos.prs.rotation.z = f_brRead.ReadSingle();
  248. vtxAttachPos.prs.rotation.w = f_brRead.ReadSingle();
  249. vtxAttachPos.prs.scale.x = f_brRead.ReadSingle();
  250. vtxAttachPos.prs.scale.y = f_brRead.ReadSingle();
  251. vtxAttachPos.prs.scale.z = f_brRead.ReadSingle();
  252. dictionary.Add(key4, new KeyValuePair<int, VtxAttachPos>(key5, vtxAttachPos));
  253. }
  254. this.m_dicTBodyAttachPos.Add(key3, dictionary);
  255. }
  256. int num6 = f_brRead.ReadInt32();
  257. for (int m = 0; m < num6; m++)
  258. {
  259. TBody.SlotID slotID = (TBody.SlotID)f_brRead.ReadInt32();
  260. int key6 = f_brRead.ReadInt32();
  261. MatPropSave matPropSave = new MatPropSave();
  262. matPropSave.nMatNo = f_brRead.ReadInt32();
  263. matPropSave.strPropName = f_brRead.ReadString();
  264. matPropSave.strTypeName = f_brRead.ReadString();
  265. matPropSave.strValue = f_brRead.ReadString();
  266. if (num < 204 && slotID == TBody.SlotID.head && matPropSave.nMatNo == 3 && (matPropSave.strPropName == "_ZTest" || matPropSave.strPropName == "ZTest"))
  267. {
  268. matPropSave.strPropName = "_ZTest2";
  269. matPropSave.strValue = ((!(matPropSave.strValue == "8")) ? "1" : "7");
  270. }
  271. this.m_dicMaterialProp.Add(slotID, new KeyValuePair<int, MatPropSave>(key6, matPropSave));
  272. }
  273. if (213 <= num)
  274. {
  275. int num7 = f_brRead.ReadInt32();
  276. for (int n = 0; n < num7; n++)
  277. {
  278. TBody.SlotID key7 = (TBody.SlotID)f_brRead.ReadInt32();
  279. int key8 = f_brRead.ReadInt32();
  280. int num8 = f_brRead.ReadInt32();
  281. Dictionary<string, float> dictionary2 = new Dictionary<string, float>();
  282. for (int num9 = 0; num9 < num8; num9++)
  283. {
  284. string key9 = f_brRead.ReadString();
  285. float num10 = f_brRead.ReadSingle();
  286. dictionary2.Add(key9, num10);
  287. }
  288. this.m_dicBoneLength[key7] = new KeyValuePair<int, Dictionary<string, float>>(key8, dictionary2);
  289. }
  290. }
  291. }
  292. if (2001 <= num)
  293. {
  294. this.isCrcParts = f_brRead.ReadBoolean();
  295. }
  296. if (num < 2002)
  297. {
  298. string text = this.strFileName.ToLower();
  299. this.isCrcParts = (text.IndexOf("crc_") == 0 || text.IndexOf("crx_") == 0 || text.IndexOf("gp03_") == 0);
  300. if (2000 <= num && string.IsNullOrEmpty(this.strFileName))
  301. {
  302. this.nFileNameRID = 0;
  303. string text2;
  304. if (CM3.dicDelItem.TryGetValue((MPN)this.idx, out text2))
  305. {
  306. this.strFileName = text2;
  307. this.nFileNameRID = this.strFileName.ToLower().GetHashCode();
  308. }
  309. }
  310. }
  311. if (num < 200 && this.idx == 143 && Path.GetFileNameWithoutExtension(this.strFileName.ToLower()) == "hair_r095_i_")
  312. {
  313. this.strFileName = "hair_r110_i_.menu";
  314. this.nFileNameRID = this.strFileName.ToLower().GetHashCode();
  315. }
  316. this.boDut = true;
  317. this.boTempDut = false;
  318. this.strTempFileName = string.Empty;
  319. this.nTempFileNameRID = 0;
  320. return true;
  321. }
  322. [Obsolete("GameUty.RidMenuDic廃止により使用不可", true)]
  323. public bool DeserializeLowCapacity(BinaryReader reader)
  324. {
  325. this.value = reader.ReadInt32();
  326. this.nFileNameRID = reader.ReadInt32();
  327. if (this.nFileNameRID != 0)
  328. {
  329. this.strFileName = ((!GameUty.RidMenuDic.ContainsKey(this.nFileNameRID)) ? string.Empty : GameUty.RidMenuDic[this.nFileNameRID]);
  330. if (string.IsNullOrEmpty(this.strFileName))
  331. {
  332. this.nFileNameRID = 0;
  333. }
  334. }
  335. else
  336. {
  337. this.strFileName = string.Empty;
  338. }
  339. this.boDut = true;
  340. this.boTempDut = false;
  341. this.strTempFileName = string.Empty;
  342. this.nTempFileNameRID = 0;
  343. return true;
  344. }
  345. public void CopyTo(MaidProp otherProp)
  346. {
  347. using (MemoryStream memoryStream = new MemoryStream())
  348. {
  349. BinaryWriter f_bwWrite = new BinaryWriter(memoryStream);
  350. this.Serialize(f_bwWrite);
  351. using (MemoryStream memoryStream2 = new MemoryStream(memoryStream.ToArray()))
  352. {
  353. BinaryReader f_brRead = new BinaryReader(memoryStream2);
  354. otherProp.Deserialize(f_brRead);
  355. }
  356. }
  357. }
  358. private static int MAID_PROP_VER = 2002;
  359. public int idx;
  360. public string name;
  361. public int type;
  362. public int value_Default;
  363. public int value;
  364. public int temp_value;
  365. public int value_LinkMAX;
  366. public string strFileName = string.Empty;
  367. public int nFileNameRID;
  368. public string strTempFileName = string.Empty;
  369. public int nTempFileNameRID;
  370. public bool boDut;
  371. public bool boTempDut;
  372. public int max;
  373. public int min;
  374. public bool bSubDut;
  375. public List<SubProp> listSubProp;
  376. public bool bNoScale;
  377. public bool boAdjustDut;
  378. public Dictionary<TBody.SlotID, KeyValuePair<int, BoneAttachPos>> m_dicTBodySkinPos = new Dictionary<TBody.SlotID, KeyValuePair<int, BoneAttachPos>>();
  379. public Dictionary<TBody.SlotID, Dictionary<string, KeyValuePair<int, VtxAttachPos>>> m_dicTBodyAttachPos = new Dictionary<TBody.SlotID, Dictionary<string, KeyValuePair<int, VtxAttachPos>>>();
  380. public Dictionary<TBody.SlotID, KeyValuePair<int, MatPropSave>> m_dicMaterialProp = new Dictionary<TBody.SlotID, KeyValuePair<int, MatPropSave>>();
  381. public Dictionary<TBody.SlotID, KeyValuePair<int, Dictionary<string, float>>> m_dicBoneLength = new Dictionary<TBody.SlotID, KeyValuePair<int, Dictionary<string, float>>>();
  382. public bool isCrcParts;
  383. }