示例#1
0
        public WorldTable(byte[] data)
        {
            using (MemoryStream ms = new MemoryStream(data))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    this.Version           = br.ReadIFFChunk <TerrainVersion>();
                    this.Header            = br.ReadIFFChunk <WorldTableHeader>();
                    this.AreaInfo          = br.ReadIFFChunk <WorldTableAreaInfo>();
                    this.WorldModelObjects = br.ReadIFFChunk <TerrainWorldModelObjects>();

                    if (this.WorldModelObjects.Filenames.Count > 0)
                    {
                        this.WorldModelObjectPlacementInfo = br.ReadIFFChunk <TerrainWorldModelObjectPlacementInfo>();
                    }
                }
            }
        }
示例#2
0
        public WorldTable(byte[] data)
        {
            using (MemoryStream ms = new MemoryStream(data))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    this.Version = br.ReadIFFChunk<TerrainVersion>();
                    this.Header = br.ReadIFFChunk<WorldTableHeader>();
                    this.AreaInfo = br.ReadIFFChunk<WorldTableAreaInfo>();
                    this.WorldModelObjects = br.ReadIFFChunk<TerrainWorldModelObjects>();

                    if (this.WorldModelObjects.Filenames.Count > 0)
                    {
                        this.WorldModelObjectPlacementInfo = br.ReadIFFChunk<TerrainWorldModelObjectPlacementInfo>();
                    }
                }
            }
        }
示例#3
0
        public WorldLOD(byte[] inData)
        {
            using (MemoryStream ms = new MemoryStream(inData))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    // Set up the two area lists with default values
                    for (int i = 0; i < 4096; ++i)
                    {
                        this.MapAreas.Add(null);
                        this.MapAreaHoles.Add(null);
                    }

                    this.Version = br.ReadIFFChunk<TerrainVersion>();

                    if (br.PeekChunkSignature() == TerrainWorldModelObjects.Signature)
                    {
                        this.WorldModelObjects = br.ReadIFFChunk<TerrainWorldModelObjects>();
                    }

                    if (br.PeekChunkSignature() == TerrainWorldObjectModelIndices.Signature)
                    {
                        this.WorldModelObjectIndices = br.ReadIFFChunk<TerrainWorldObjectModelIndices>();
                    }

                    if (br.PeekChunkSignature() == TerrainWorldModelObjectPlacementInfo.Signature)
                    {
                        this.WorldModelObjectPlacementInfo = br.ReadIFFChunk<TerrainWorldModelObjectPlacementInfo>();
                    }

                    this.MapAreaOffsets = br.ReadIFFChunk<WorldLODMapAreaOffsets>();

                    // Read the map areas and their holes
                    for (int y = 0; y < 64; ++y)
                    {
                        for (int x = 0; x < 64; ++x)
                        {
                            int mapAreaOffsetIndex = (y * 64) + x;
                            uint mapAreaOffset = this.MapAreaOffsets.MapAreaOffsets[mapAreaOffsetIndex];

                            if (mapAreaOffset > 0)
                            {
                                br.BaseStream.Position = mapAreaOffset;
                                this.MapAreas[mapAreaOffsetIndex] = br.ReadIFFChunk<WorldLODMapArea>();

                                if (br.PeekChunkSignature() == WorldLODMapAreaHoles.Signature)
                                {
                                    this.MapAreaHoles[mapAreaOffsetIndex] = br.ReadIFFChunk<WorldLODMapAreaHoles>();
                                }
                                else
                                {
                                    this.MapAreaHoles[mapAreaOffsetIndex] = WorldLODMapAreaHoles.CreateEmpty();
                                }
                            }
                            else
                            {
                                this.MapAreas[mapAreaOffsetIndex] = null;
                                this.MapAreaHoles[mapAreaOffsetIndex] = null;
                            }
                        }
                    }
                }
            }
        }
示例#4
0
        public WorldLOD(byte[] inData)
        {
            using (MemoryStream ms = new MemoryStream(inData))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    // Set up the two area lists with default values
                    for (int i = 0; i < 4096; ++i)
                    {
                        MapAreas.Add(null);
                        MapAreaHoles.Add(null);
                    }

                    Version = br.ReadIFFChunk <TerrainVersion>();

                    if (br.PeekChunkSignature() == TerrainWorldModelObjects.Signature)
                    {
                        WorldModelObjects = br.ReadIFFChunk <TerrainWorldModelObjects>();
                    }

                    if (br.PeekChunkSignature() == TerrainWorldModelObjectIndices.Signature)
                    {
                        WorldModelObjectIndices = br.ReadIFFChunk <TerrainWorldModelObjectIndices>();
                    }

                    if (br.PeekChunkSignature() == TerrainWorldModelObjectPlacementInfo.Signature)
                    {
                        WorldModelObjectPlacementInfo = br.ReadIFFChunk <TerrainWorldModelObjectPlacementInfo>();
                    }

                    MapAreaOffsets = br.ReadIFFChunk <WorldLODMapAreaOffsets>();

                    // Read the map areas and their holes
                    for (int y = 0; y < 64; ++y)
                    {
                        for (int x = 0; x < 64; ++x)
                        {
                            int  mapAreaOffsetIndex = (y * 64) + x;
                            uint mapAreaOffset      = MapAreaOffsets.MapAreaOffsets[mapAreaOffsetIndex];

                            if (mapAreaOffset > 0)
                            {
                                br.BaseStream.Position       = mapAreaOffset;
                                MapAreas[mapAreaOffsetIndex] = br.ReadIFFChunk <WorldLODMapArea>();

                                if (br.PeekChunkSignature() == WorldLODMapAreaHoles.Signature)
                                {
                                    MapAreaHoles[mapAreaOffsetIndex] = br.ReadIFFChunk <WorldLODMapAreaHoles>();
                                }
                                else
                                {
                                    MapAreaHoles[mapAreaOffsetIndex] = WorldLODMapAreaHoles.CreateEmpty();
                                }
                            }
                            else
                            {
                                MapAreas[mapAreaOffsetIndex]     = null;
                                MapAreaHoles[mapAreaOffsetIndex] = null;
                            }
                        }
                    }
                }
            }
        }