Terrain liquid chunk. Contains information about water and other liquids in a map tile.
示例#1
0
        /// <inheritdoc/>
        public void LoadBinaryData(byte[] inData)
        {
            using var ms = new MemoryStream(inData);
            using var br = new BinaryReader(ms);
            for (var i = 0; i < 256; ++i)
            {
                LiquidChunks.Add(new TerrainLiquidChunk(br.ReadBytes(TerrainLiquidChunk.GetSize())));
            }

            foreach (var liquidChunk in LiquidChunks)
            {
                br.BaseStream.Position = liquidChunk.WaterInstanceOffset;
                for (var i = 0; i < liquidChunk.LayerCount; ++i)
                {
                    var instanceData = br.ReadBytes(TerrainLiquidInstance.GetSize());
                    liquidChunk.LiquidInstances.Add(new TerrainLiquidInstance(instanceData));
                }

                br.BaseStream.Position = liquidChunk.AttributesOffset;
                if (liquidChunk.LayerCount > 0)
                {
                    var attributeData = br.ReadBytes(TerrainLiquidAttributes.GetSize());
                    liquidChunk.LiquidAttributes = new TerrainLiquidAttributes(attributeData);
                }
                else
                {
                    liquidChunk.LiquidAttributes = new TerrainLiquidAttributes();
                }
            }
        }
示例#2
0
        public void LoadBinaryData(byte[] inData)
        {
            using (MemoryStream ms = new MemoryStream(inData))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    for (int i = 0; i < 256; ++i)
                    {
                        this.LiquidChunks.Add(new TerrainLiquidChunk(br.ReadBytes(TerrainLiquidChunk.GetSize())));
                    }

                    foreach (TerrainLiquidChunk LiquidChunk in this.LiquidChunks)
                    {
                        br.BaseStream.Position = LiquidChunk.WaterInstanceOffset;
                        for (int i = 0; i < LiquidChunk.LayerCount; ++i)
                        {
                            byte[] instanceData = br.ReadBytes(TerrainLiquidInstance.GetSize());
                            LiquidChunk.LiquidInstances.Add(new TerrainLiquidInstance(instanceData));
                        }

                        br.BaseStream.Position = LiquidChunk.AttributesOffset;
                        if (LiquidChunk.LayerCount > 0)
                        {
                            byte[] attributeData = br.ReadBytes(TerrainLiquidAttributes.GetSize());
                            LiquidChunk.LiquidAttributes = new TerrainLiquidAttributes(attributeData);
                        }
                        else
                        {
                            LiquidChunk.LiquidAttributes = new TerrainLiquidAttributes();
                        }
                    }
                }
            }
        }