- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ADTReader.Chunks
- {
- enum MCNKFlags// 03-29-2005 By ObscuR
- {
- FLAG_MCSH,
- FLAG_IMPASS,
- FLAG_LQ_RIVER,
- FLAG_LQ_OCEAN,
- FLAG_LQ_MAGMA,
- FLAG_MCCV,
- }
- class MCNK : Chunk
- {
- MCNKFlags flags;
- UInt32 IndexX;
- UInt32 IndexY;
- UInt32 nLayers; // maximum 4
- UInt32 nDoodadRefs;
- UInt32 ofsHeight;
- UInt32 ofsNormal;
- UInt32 ofsLayer;
- UInt32 ofsRefs;
- UInt32 ofsAlpha;
- UInt32 sizeAlpha;
- UInt32 ofsShadow; // only with flags&0x1
- UInt32 sizeShadow;
- UInt32 areaid;
- UInt32 nMapObjRefs;
- UInt32 holes;
- UInt16[] s; // It is used to determine which detail doodads to show. Values are an array of two bit unsigned integers, naming the layer.
- UInt32 data1;
- UInt32 data2;
- UInt32 data3;
- UInt32 predTex; // 03-29-2005 By ObscuR; TODO: Investigate
- UInt32 noEffectDoodad; // 03-29-2005 By ObscuR; TODO: Investigate
- UInt32 ofsSndEmitters;
- UInt32 nSndEmitters; //will be set to 0 in the client if ofsSndEmitters doesn't point to MCSE!
- UInt32 ofsLiquid;
- UInt32 sizeLiquid; // 8 when not used; only read if >8.
- Vector3 position;
- UInt32 ofsMCCV; // only with flags&0x40, had UINT32 textureId; in ObscuR's structure.
- UInt32 ofsMCLV; // introduced in Cataclysm
- UInt32 effectId; // currently unused
- public MCNK(byte[] buff) : base(buff, "MCNK") { }
- public override void Read()
- {
- this.flags = (MCNKFlags)base.Reader.ReadUInt32();
- this.IndexX = base.Reader.ReadUInt32();
- this.IndexY = base.Reader.ReadUInt32();
- this.nLayers = base.Reader.ReadUInt32();
- this.nDoodadRefs = base.Reader.ReadUInt32();
- this.ofsHeight = base.Reader.ReadUInt32();
- this.ofsNormal = base.Reader.ReadUInt32();
- this.ofsLayer = base.Reader.ReadUInt32();
- this.ofsRefs = base.Reader.ReadUInt32();
- this.ofsAlpha = base.Reader.ReadUInt32();
- this.sizeAlpha = base.Reader.ReadUInt32();
- this.ofsShadow = base.Reader.ReadUInt32();
- this.sizeShadow = base.Reader.ReadUInt32();
- this.areaid = base.Reader.ReadUInt32();
- this.nMapObjRefs = base.Reader.ReadUInt32();
- this.holes = base.Reader.ReadUInt32();
- this.s = new UInt16[2];
- for (int i = 0; i < 2; i++)
- this.s[i] = base.Reader.ReadUInt16();
- this.data1 = base.Reader.ReadUInt32();
- this.data2 = base.Reader.ReadUInt32();
- this.data3 = base.Reader.ReadUInt32();
- this.predTex = base.Reader.ReadUInt32();
- this.noEffectDoodad = base.Reader.ReadUInt32();
- this.ofsSndEmitters = base.Reader.ReadUInt32();
- this.nSndEmitters = base.Reader.ReadUInt32();
- this.ofsLiquid = base.Reader.ReadUInt32();
- this.sizeLiquid = base.Reader.ReadUInt32();
- this.position = new Vector3();
- this.position.z = base.Reader.ReadSingle();
- this.position.x = base.Reader.ReadSingle();
- this.position.y = base.Reader.ReadSingle();
- this.ofsMCCV = base.Reader.ReadUInt32();
- this.ofsMCLV = base.Reader.ReadUInt32();
- this.effectId = base.Reader.ReadUInt32();
- }
- public override string ToString()
- {
- StringBuilder sb = new StringBuilder();
- sb.AppendLine("MCNK chunk");
- sb.AppendFormat("Area Id: {0}", areaid);
- sb.AppendLine();
- sb.AppendFormat("Flags: {0}", this.flags);
- sb.AppendLine();
- sb.AppendFormat("Index X:Y: {0}:{1}", this.IndexX, this.IndexY);
- sb.AppendLine();
- sb.AppendFormat("nLayers: {0}", nLayers);
- sb.AppendLine();
- sb.AppendFormat("nDoodadRefs: {0}", nDoodadRefs);
- sb.AppendLine();
- sb.AppendFormat("ofsHeight: {0}", ofsHeight);
- sb.AppendLine();
- sb.AppendFormat("ofsNormal: {0}", ofsNormal);
- sb.AppendLine();
- sb.AppendFormat("ofsLayer: {0}", ofsLayer);
- sb.AppendLine();
- sb.AppendFormat("ofsRefs: {0}", ofsRefs);
- sb.AppendLine();
- sb.AppendFormat("ofsAlpha: {0}", ofsAlpha);
- sb.AppendLine();
- sb.AppendFormat("sizeAlpha: {0}", sizeAlpha);
- sb.AppendLine();
- sb.AppendFormat("ofsShadow: {0}", ofsShadow);
- sb.AppendLine();
- sb.AppendFormat("sizeShadow: {0}", sizeShadow);
- sb.AppendLine();
- sb.AppendFormat("nMapObjRefs: {0}", nMapObjRefs);
- sb.AppendLine();
- sb.AppendFormat("Holes: {0}", holes);
- sb.AppendLine();
- sb.AppendFormat("data1: {0}", data1);
- sb.AppendLine();
- sb.AppendFormat("data2: {0}", data2);
- sb.AppendLine();
- sb.AppendFormat("data3: {0}", data3);
- sb.AppendLine();
- sb.AppendFormat("predTex: {0}", predTex);
- sb.AppendLine();
- sb.AppendFormat("noEffectDoodad: {0}", noEffectDoodad);
- sb.AppendLine();
- sb.AppendFormat("ofsSndEmitters: {0}", ofsSndEmitters);
- sb.AppendLine();
- sb.AppendFormat("ofsLiquid: {0}", ofsLiquid);
- sb.AppendLine();
- sb.AppendFormat("sizeLiquid: {0}", sizeLiquid);
- sb.AppendLine();
- sb.AppendFormat("Position: {0}", position);
- sb.AppendLine();
- sb.AppendFormat("ofsMCCV: {0}", ofsMCCV);
- sb.AppendLine();
- sb.AppendFormat("ofsMCLV: {0}", ofsMCLV);
- sb.AppendLine();
- sb.AppendFormat("effectId: {0}", effectId);
- sb.AppendLine();
- return sb.ToString();
- }
- }
- }