Ejemplo n.º 1
0
        public override void Unpack(BinaryReader reader)
        {
            Id = reader.ReadUInt32();

            Bitfield = reader.ReadUInt32();

            reader.BaseStream.Position += 4; // Skip ahead 4 bytes, because this is the CellId. Again. Twice.

            byte   numSurfaces = reader.ReadByte();
            byte   numPortals  = reader.ReadByte();     // Note that "portal" in this context does not refer to the swirly pink/purple thing, its basically connecting cells
            ushort numStabs    = reader.ReadUInt16();   // I believe this is what cells can be seen from this one. So the engine knows what else it needs to load/draw.

            // Read what surfaces are used in this cell
            for (uint i = 0; i < numSurfaces; i++)
            {
                Shadows.Add(0x08000000u | reader.ReadUInt16()); // these are stored in the dat as short values, so we'll make them a full dword
            }
            EnvironmentId = (0x0D000000u | reader.ReadUInt16());

            CellStructure = reader.ReadUInt16();

            Position.Unpack(reader);

            CellPortals.Unpack(reader, numPortals);

            for (uint i = 0; i < numStabs; i++)
            {
                VisibleCells.Add(reader.ReadUInt16());
            }

            if ((Bitfield & 2) != 0)
            {
                StaticObjects.Unpack(reader);
            }

            if ((Bitfield & 8) != 0)
            {
                RestrictionObj = reader.ReadUInt32();
            }
        }