HaloMap.RawData.Model.ReadH1ModelRaw C# (CSharp) Method

ReadH1ModelRaw() public method

The read h 1 model raw.
public ReadH1ModelRaw ( int TagIndex, Map map, bool dontreadraw ) : void
TagIndex int The TagIndex.
map HaloMap.Map.Map The map.
dontreadraw bool The dontreadraw.
return void
        public void ReadH1ModelRaw(int TagIndex, Map map, bool dontreadraw)
        {
            map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 208;
            int tempc = map.BR.ReadInt32();
            int tempr = map.BR.ReadInt32() - map.PrimaryMagic;
            for (int y = 0; y < tempc; y++)
            {
                map.BR.BaseStream.Position = tempr + (y * 48) + 36;
                int tempcc = map.BR.ReadInt32();
                int temprc = map.BR.ReadInt32() - map.PrimaryMagic;
                for (int x = 0; x < tempcc; x++)
                {
                    RawDataChunk Raw = new RawDataChunk();

                    map.BR.BaseStream.Position = temprc + (x * 104) + 4;
                    Raw.shadernumber = map.BR.ReadInt16();
                    Raw.pointerMetaOffset = temprc + (x * 104) + 76 - map.MetaInfo.Offset[TagIndex];

                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + Raw.pointerMetaOffset - 4;
                    Raw.rawDataType = RawDataType.HaloCEIndices;
                    Raw.size = (map.BR.ReadInt32() + 2) * 2;
                    Raw.offset = map.BR.ReadInt32() - map.PrimaryMagic;

                    if (dontreadraw == false)
                    {
                        map.OpenMap(Raw.rawLocation);
                        map.BR.BaseStream.Position = Raw.offset;
                        Raw.MS = new MemoryStream(Raw.size);
                        Raw.MS.Write(map.BR.ReadBytes(Raw.size), 0, Raw.size);
                        map.OpenMap(MapTypes.Internal);
                    }

                    this.rawChunks.Add(Raw);

                    Raw = new RawDataChunk();
                    Raw.rawDataType = RawDataType.HaloCEVertices;
                    Raw.pointerMetaOffset = temprc + (x * 104) + 100 - map.MetaInfo.Offset[TagIndex];
                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + Raw.pointerMetaOffset - 12;
                    Raw.size = map.BR.ReadInt32();
                    Raw.size *= 32;

                    map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + Raw.pointerMetaOffset;

                    this.IntermediatePointerOffset = map.BR.ReadInt32() - map.PrimaryMagic;

                    map.BR.BaseStream.Position = this.IntermediatePointerOffset + 4;
                    Raw.offset = map.BR.ReadInt32() - map.PrimaryMagic;

                    if (dontreadraw == false)
                    {
                        map.OpenMap(Raw.rawLocation);
                        map.BR.BaseStream.Position = Raw.offset;
                        Raw.MS = new MemoryStream(Raw.size);
                        Raw.MS.Write(map.BR.ReadBytes(Raw.size), 0, Raw.size);
                        map.OpenMap(MapTypes.Internal);
                    }

                    this.rawChunks.Add(Raw);
                }
            }
        }