Пример #1
0
        private static Dictionary <int, BuildSector> ReadSectors(MapSet map, BinaryReader reader)
        {
            int count = reader.ReadInt32();

            // Create lookup table
            var link = new Dictionary <int, BuildSector>(count);

            // Go for all collections
            map.SetCapacity(0, 0, 0, map.Sectors.Count + count, 0);

            for (int i = 0; i < count; i++)
            {
                BuildSector bs = new BuildSector();

                // Read Build properteis
                bs.FirstWallIndex = reader.ReadInt32();
                bs.CeilingHeight  = reader.ReadInt32();
                bs.FloorHeight    = reader.ReadInt32();

                bs.CeilingTileIndex    = reader.ReadInt32();
                bs.CeilingSlope        = reader.ReadInt32();
                bs.CeilingShade        = reader.ReadInt32();
                bs.CeilingPaletteIndex = reader.ReadInt32();
                bs.CeilingOffsetX      = reader.ReadInt32();
                bs.CeilingOffsetY      = reader.ReadInt32();

                bs.FloorTileIndex    = reader.ReadInt32();
                bs.FloorSlope        = reader.ReadInt32();
                bs.FloorShade        = reader.ReadInt32();
                bs.FloorPaletteIndex = reader.ReadInt32();
                bs.FloorOffsetX      = reader.ReadInt32();
                bs.FloorOffsetY      = reader.ReadInt32();

                bs.Visibility = reader.ReadInt32();

                bs.HiTag = reader.ReadInt32();
                bs.LoTag = reader.ReadInt32();
                bs.Extra = reader.ReadInt32();

                // Flags
                bs.CeilingFlags = ReadFlags(reader, General.Map.Config.SectorFlags.Keys);
                bs.FloorFlags   = ReadFlags(reader, General.Map.Config.SectorFlags.Keys);

                // Create new item
                Sector s = map.CreateSector();
                if (s != null)
                {
                    // Set properties
                    s.Update(bs);
                    bs.Sector = s;

                    // Add it to the lookup table
                    link.Add(i, bs);
                }
            }

            // Return lookup table
            return(link);
        }
Пример #2
0
        private List <BuildSector> ReadSectors(BinaryReader reader)
        {
            // Read sectors count
            int num = reader.ReadUInt16();

            // Prepare collection
            var result = new List <BuildSector>(num);

            // Read sectors
            for (int i = 0; i < num; i++)
            {
                BuildSector s = new BuildSector();

                // Read properties from stream
                s.FirstWallIndex = reader.ReadInt16();
                s.WallsCount     = reader.ReadInt16();             // Number of walls in sector

                // Transform to match DB2 model/XY map units
                s.CeilingHeight = GetEditorHeight(reader.ReadInt32());                 // Z-coordinate (height) of ceiling at first point of sector
                s.FloorHeight   = GetEditorHeight(reader.ReadInt32());                 // Z-coordinate (height) of floor at first point of sector

                // Make string flags
                int ceilingstat = reader.ReadUInt16();
                int floorstat   = reader.ReadUInt16();
                foreach (int flag in manager.Config.SortedSectorFlags)
                {
                    s.CeilingFlags[flag.ToString()] = ((ceilingstat & flag) == flag);
                    s.FloorFlags[flag.ToString()]   = ((floorstat & flag) == flag);
                }

                s.CeilingTileIndex    = reader.ReadUInt16();
                s.CeilingSlope        = BuildSlopeToRadians(reader.ReadInt16());
                s.CeilingShade        = reader.ReadSByte();
                s.CeilingPaletteIndex = reader.ReadByte();
                s.CeilingOffsetX      = reader.ReadByte();
                s.CeilingOffsetY      = reader.ReadByte();

                s.FloorTileIndex    = reader.ReadUInt16();
                s.FloorSlope        = BuildSlopeToRadians(reader.ReadInt16());
                s.FloorShade        = reader.ReadSByte();
                s.FloorPaletteIndex = reader.ReadByte();
                s.FloorOffsetX      = reader.ReadByte();
                s.FloorOffsetY      = reader.ReadByte();

                s.Visibility = reader.ReadByte();

                reader.BaseStream.Position += 1;                 // Skip padding byte

                s.LoTag = reader.ReadInt16();
                s.HiTag = reader.ReadInt16();
                s.Extra = reader.ReadInt16();

                // Add to collection
                result.Add(s);
            }

            return(result);
        }