예제 #1
0
파일: ZoneGrid.cs 프로젝트: pallmall/WCell
        static MCNK ProcessChunk(BinaryReader fileReader, uint mcnkOffset)
        {
            var mcnk = new MCNK();

            fileReader.BaseStream.Position = mcnkOffset;

            var ca = "MCNK".ToCharArray();
            var b0 = (uint)ca[0];
            var b1 = (uint)ca[1];
            var b2 = (uint)ca[2];
            var b3 = (uint)ca[3];
            var magic = b3 | (b2 << 8) | (b1 << 16) | (b0 << 24);

            var sig = fileReader.ReadUInt32();
            if (sig != magic)
            {
                Console.WriteLine("Invalid Chunk offset found.");
            }

            var mcnkSize = fileReader.ReadUInt32();

            mcnk.Flags = fileReader.ReadInt32();
            mcnk.IndexX = fileReader.ReadInt32();
            mcnk.IndexY = fileReader.ReadInt32();
            mcnk.nLayers = fileReader.ReadUInt32(); //0xC
            mcnk.nDoodadRefs = fileReader.ReadUInt32(); //0x10
            mcnk.ofsHeight = fileReader.ReadUInt32(); //0x14
            mcnk.ofsNormal = fileReader.ReadUInt32(); //0x18
            mcnk.ofsLayer = fileReader.ReadUInt32(); //0x1C
            mcnk.ofsRefs = fileReader.ReadUInt32(); //0x20
            mcnk.ofsAlpha = fileReader.ReadUInt32(); //0x24
            mcnk.sizeAlpha = fileReader.ReadUInt32(); //0x28
            mcnk.ofsShadow = fileReader.ReadUInt32(); //0x2C
            mcnk.sizeShadow = fileReader.ReadUInt32(); //0x30
            mcnk.AreaId = fileReader.ReadInt32(); //0x34
            mcnk.nMapObjRefs = fileReader.ReadUInt32(); //0x38

            mcnk.Holes = fileReader.ReadUInt16();
            fileReader.ReadUInt16(); // pad

            mcnk.predTex = new ushort[8];
            for (var i = 0; i < 8; i++)
            {
                mcnk.predTex[i] = fileReader.ReadUInt16();
            }

            mcnk.nEffectDoodad = new byte[8];
            for (var i = 0; i < 8; i++)
            {
                mcnk.nEffectDoodad[i] = fileReader.ReadByte();
            }
            mcnk.ofsSndEmitters = fileReader.ReadUInt32(); //0x58
            mcnk.nSndEmitters = fileReader.ReadUInt32(); //0x5C
            mcnk.ofsLiquid = fileReader.ReadUInt32(); //0x60
            mcnk.sizeLiquid = fileReader.ReadUInt32(); //0x64
            mcnk.Z = fileReader.ReadSingle();
            mcnk.X = fileReader.ReadSingle();
            mcnk.Y = fileReader.ReadSingle();
            mcnk.offsColorValues = fileReader.ReadInt32();
            mcnk.props = fileReader.ReadInt32();
            mcnk.effectId = fileReader.ReadInt32();

            return mcnk;
        }
예제 #2
0
        static MCNK ProcessChunk(BinaryReader fileReader, uint mcnkOffset)
        {
            var mcnk = new MCNK();

            fileReader.BaseStream.Position = mcnkOffset;

            var ca    = "MCNK".ToCharArray();
            var b0    = (uint)ca[0];
            var b1    = (uint)ca[1];
            var b2    = (uint)ca[2];
            var b3    = (uint)ca[3];
            var magic = b3 | (b2 << 8) | (b1 << 16) | (b0 << 24);

            var sig = fileReader.ReadUInt32();

            if (sig != magic)
            {
                Console.WriteLine("Invalid Chunk offset found.");
            }

            var mcnkSize = fileReader.ReadUInt32();

            mcnk.Flags       = fileReader.ReadInt32();
            mcnk.IndexX      = fileReader.ReadInt32();
            mcnk.IndexY      = fileReader.ReadInt32();
            mcnk.nLayers     = fileReader.ReadUInt32(); //0xC
            mcnk.nDoodadRefs = fileReader.ReadUInt32(); //0x10
            mcnk.ofsHeight   = fileReader.ReadUInt32(); //0x14
            mcnk.ofsNormal   = fileReader.ReadUInt32(); //0x18
            mcnk.ofsLayer    = fileReader.ReadUInt32(); //0x1C
            mcnk.ofsRefs     = fileReader.ReadUInt32(); //0x20
            mcnk.ofsAlpha    = fileReader.ReadUInt32(); //0x24
            mcnk.sizeAlpha   = fileReader.ReadUInt32(); //0x28
            mcnk.ofsShadow   = fileReader.ReadUInt32(); //0x2C
            mcnk.sizeShadow  = fileReader.ReadUInt32(); //0x30
            mcnk.AreaId      = fileReader.ReadInt32();  //0x34
            mcnk.nMapObjRefs = fileReader.ReadUInt32(); //0x38

            mcnk.Holes = fileReader.ReadUInt16();
            fileReader.ReadUInt16(); // pad

            mcnk.predTex = new ushort[8];
            for (var i = 0; i < 8; i++)
            {
                mcnk.predTex[i] = fileReader.ReadUInt16();
            }

            mcnk.nEffectDoodad = new byte[8];
            for (var i = 0; i < 8; i++)
            {
                mcnk.nEffectDoodad[i] = fileReader.ReadByte();
            }
            mcnk.ofsSndEmitters = fileReader.ReadUInt32(); //0x58
            mcnk.nSndEmitters   = fileReader.ReadUInt32(); //0x5C
            mcnk.ofsLiquid      = fileReader.ReadUInt32(); //0x60
            mcnk.sizeLiquid     = fileReader.ReadUInt32(); //0x64
            mcnk.Z = fileReader.ReadSingle();
            mcnk.X = fileReader.ReadSingle();
            mcnk.Y = fileReader.ReadSingle();
            mcnk.offsColorValues = fileReader.ReadInt32();
            mcnk.props           = fileReader.ReadInt32();
            mcnk.effectId        = fileReader.ReadInt32();

            return(mcnk);
        }