Esempio n. 1
0
        void LoadLiquidData(BinaryReader reader, uint offset)
        {
            reader.BaseStream.Seek(offset, SeekOrigin.Begin);
            map_LiquidHeader liquidHeader = reader.ReadStruct <map_LiquidHeader>();

            _liquidType   = liquidHeader.liquidType;
            _liquidOffX   = liquidHeader.offsetX;
            _liquidOffY   = liquidHeader.offsetY;
            _liquidWidth  = liquidHeader.width;
            _liquidHeight = liquidHeader.height;
            _liquidLevel  = liquidHeader.liquidLevel;

            if (!liquidHeader.flags.HasAnyFlag(LiquidHeaderFlags.LiquidNoType))
            {
                _liquidEntry = new ushort[16 * 16];
                for (var i = 0; i < _liquidEntry.Length; ++i)
                {
                    _liquidEntry[i] = reader.ReadUInt16();
                }

                _liquidFlags = reader.ReadBytes(16 * 16);
            }

            if (!liquidHeader.flags.HasAnyFlag(LiquidHeaderFlags.LiquidNoHeight))
            {
                _liquidMap = new float[_liquidWidth * _liquidHeight];
                for (var i = 0; i < _liquidMap.Length; ++i)
                {
                    _liquidMap[i] = reader.ReadSingle();
                }
            }
        }
Esempio n. 2
0
        bool LoadLiquidData(BinaryReader reader, uint offset)
        {
            reader.BaseStream.Seek(offset, SeekOrigin.Begin);
            map_LiquidHeader liquidHeader = reader.Read <map_LiquidHeader>();

            if (liquidHeader.fourcc != MapConst.MapLiquidMagic)
            {
                return(false);
            }

            _liquidGlobalEntry = liquidHeader.liquidType;
            _liquidGlobalFlags = liquidHeader.liquidFlags;
            _liquidOffX        = liquidHeader.offsetX;
            _liquidOffY        = liquidHeader.offsetY;
            _liquidWidth       = liquidHeader.width;
            _liquidHeight      = liquidHeader.height;
            _liquidLevel       = liquidHeader.liquidLevel;

            if (!liquidHeader.flags.HasAnyFlag(LiquidHeaderFlags.LiquidNoType))
            {
                _liquidEntry = reader.ReadArray <ushort>(16 * 16);
                _liquidFlags = reader.ReadBytes(16 * 16);
            }

            if (!liquidHeader.flags.HasAnyFlag(LiquidHeaderFlags.LiquidNoHeight))
            {
                _liquidMap = reader.ReadArray <float>((uint)(_liquidWidth * _liquidHeight));
            }

            return(true);
        }