1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ADTReader.Chunks
  7. {
  8. enum MCNKFlags// 03-29-2005 By ObscuR
  9. {
  10. FLAG_MCSH,
  11. FLAG_IMPASS,
  12. FLAG_LQ_RIVER,
  13. FLAG_LQ_OCEAN,
  14. FLAG_LQ_MAGMA,
  15. FLAG_MCCV,
  16. }
  17. class MCNK : Chunk
  18. {
  19. MCNKFlags flags;
  20. UInt32 IndexX;
  21. UInt32 IndexY;
  22. UInt32 nLayers; // maximum 4
  23. UInt32 nDoodadRefs;
  24. UInt32 ofsHeight;
  25. UInt32 ofsNormal;
  26. UInt32 ofsLayer;
  27. UInt32 ofsRefs;
  28. UInt32 ofsAlpha;
  29. UInt32 sizeAlpha;
  30. UInt32 ofsShadow; // only with flags&0x1
  31. UInt32 sizeShadow;
  32. UInt32 areaid;
  33. UInt32 nMapObjRefs;
  34. UInt32 holes;
  35. UInt16[] s; // It is used to determine which detail doodads to show. Values are an array of two bit unsigned integers, naming the layer.
  36. UInt32 data1;
  37. UInt32 data2;
  38. UInt32 data3;
  39. UInt32 predTex; // 03-29-2005 By ObscuR; TODO: Investigate
  40. UInt32 noEffectDoodad; // 03-29-2005 By ObscuR; TODO: Investigate
  41. UInt32 ofsSndEmitters;
  42. UInt32 nSndEmitters; //will be set to 0 in the client if ofsSndEmitters doesn't point to MCSE!
  43. UInt32 ofsLiquid;
  44. UInt32 sizeLiquid; // 8 when not used; only read if >8.
  45. Vector3 position;
  46. UInt32 ofsMCCV; // only with flags&0x40, had UINT32 textureId; in ObscuR's structure.
  47. UInt32 ofsMCLV; // introduced in Cataclysm
  48. UInt32 effectId; // currently unused
  49. public MCNK(byte[] buff) : base(buff, "MCNK") { }
  50. public override void Read()
  51. {
  52. this.flags = (MCNKFlags)base.Reader.ReadUInt32();
  53. this.IndexX = base.Reader.ReadUInt32();
  54. this.IndexY = base.Reader.ReadUInt32();
  55. this.nLayers = base.Reader.ReadUInt32();
  56. this.nDoodadRefs = base.Reader.ReadUInt32();
  57. this.ofsHeight = base.Reader.ReadUInt32();
  58. this.ofsNormal = base.Reader.ReadUInt32();
  59. this.ofsLayer = base.Reader.ReadUInt32();
  60. this.ofsRefs = base.Reader.ReadUInt32();
  61. this.ofsAlpha = base.Reader.ReadUInt32();
  62. this.sizeAlpha = base.Reader.ReadUInt32();
  63. this.ofsShadow = base.Reader.ReadUInt32();
  64. this.sizeShadow = base.Reader.ReadUInt32();
  65. this.areaid = base.Reader.ReadUInt32();
  66. this.nMapObjRefs = base.Reader.ReadUInt32();
  67. this.holes = base.Reader.ReadUInt32();
  68. this.s = new UInt16[2];
  69. for (int i = 0; i < 2; i++)
  70. this.s[i] = base.Reader.ReadUInt16();
  71. this.data1 = base.Reader.ReadUInt32();
  72. this.data2 = base.Reader.ReadUInt32();
  73. this.data3 = base.Reader.ReadUInt32();
  74. this.predTex = base.Reader.ReadUInt32();
  75. this.noEffectDoodad = base.Reader.ReadUInt32();
  76. this.ofsSndEmitters = base.Reader.ReadUInt32();
  77. this.nSndEmitters = base.Reader.ReadUInt32();
  78. this.ofsLiquid = base.Reader.ReadUInt32();
  79. this.sizeLiquid = base.Reader.ReadUInt32();
  80. this.position = new Vector3();
  81. this.position.z = base.Reader.ReadSingle();
  82. this.position.x = base.Reader.ReadSingle();
  83. this.position.y = base.Reader.ReadSingle();
  84. this.ofsMCCV = base.Reader.ReadUInt32();
  85. this.ofsMCLV = base.Reader.ReadUInt32();
  86. this.effectId = base.Reader.ReadUInt32();
  87. }
  88. public override string ToString()
  89. {
  90. StringBuilder sb = new StringBuilder();
  91. sb.AppendLine("MCNK chunk");
  92. sb.AppendFormat("Area Id: {0}", areaid);
  93. sb.AppendLine();
  94. sb.AppendFormat("Flags: {0}", this.flags);
  95. sb.AppendLine();
  96. sb.AppendFormat("Index X:Y: {0}:{1}", this.IndexX, this.IndexY);
  97. sb.AppendLine();
  98. sb.AppendFormat("nLayers: {0}", nLayers);
  99. sb.AppendLine();
  100. sb.AppendFormat("nDoodadRefs: {0}", nDoodadRefs);
  101. sb.AppendLine();
  102. sb.AppendFormat("ofsHeight: {0}", ofsHeight);
  103. sb.AppendLine();
  104. sb.AppendFormat("ofsNormal: {0}", ofsNormal);
  105. sb.AppendLine();
  106. sb.AppendFormat("ofsLayer: {0}", ofsLayer);
  107. sb.AppendLine();
  108. sb.AppendFormat("ofsRefs: {0}", ofsRefs);
  109. sb.AppendLine();
  110. sb.AppendFormat("ofsAlpha: {0}", ofsAlpha);
  111. sb.AppendLine();
  112. sb.AppendFormat("sizeAlpha: {0}", sizeAlpha);
  113. sb.AppendLine();
  114. sb.AppendFormat("ofsShadow: {0}", ofsShadow);
  115. sb.AppendLine();
  116. sb.AppendFormat("sizeShadow: {0}", sizeShadow);
  117. sb.AppendLine();
  118. sb.AppendFormat("nMapObjRefs: {0}", nMapObjRefs);
  119. sb.AppendLine();
  120. sb.AppendFormat("Holes: {0}", holes);
  121. sb.AppendLine();
  122. sb.AppendFormat("data1: {0}", data1);
  123. sb.AppendLine();
  124. sb.AppendFormat("data2: {0}", data2);
  125. sb.AppendLine();
  126. sb.AppendFormat("data3: {0}", data3);
  127. sb.AppendLine();
  128. sb.AppendFormat("predTex: {0}", predTex);
  129. sb.AppendLine();
  130. sb.AppendFormat("noEffectDoodad: {0}", noEffectDoodad);
  131. sb.AppendLine();
  132. sb.AppendFormat("ofsSndEmitters: {0}", ofsSndEmitters);
  133. sb.AppendLine();
  134. sb.AppendFormat("ofsLiquid: {0}", ofsLiquid);
  135. sb.AppendLine();
  136. sb.AppendFormat("sizeLiquid: {0}", sizeLiquid);
  137. sb.AppendLine();
  138. sb.AppendFormat("Position: {0}", position);
  139. sb.AppendLine();
  140. sb.AppendFormat("ofsMCCV: {0}", ofsMCCV);
  141. sb.AppendLine();
  142. sb.AppendFormat("ofsMCLV: {0}", ofsMCLV);
  143. sb.AppendLine();
  144. sb.AppendFormat("effectId: {0}", effectId);
  145. sb.AppendLine();
  146. return sb.ToString();
  147. }
  148. }
  149. }