コード例 #1
0
ファイル: Save.cs プロジェクト: TrueLoop/Voxelmetric
        public void Debinarize(BinaryReader br)
        {
            var positionsBytes = new byte[br.ReadInt32()];
            var blockBytes     = new byte[br.ReadInt32()];

            positions = StructSerialization.DeserializeArray <BlockPos>(br.ReadBytes(positionsBytes.Length), Chunk.pools.MarshaledPool);
            var tmp = StructSerialization.DeserializeArray <ushort>(br.ReadBytes(blockBytes.Length), Chunk.pools.MarshaledPool);

            // Convert block types global types into internal optimized version
            blocks = new BlockData[tmp.Length];
            for (int i = 0; i < blocks.Length; i++)
            {
                blocks[i] = new BlockData(Chunk.world.blockProvider.GetTypeFromTypeInConfig(tmp[i]));
            }
        }
コード例 #2
0
ファイル: Save.cs プロジェクト: TrueLoop/Voxelmetric
        public void Binarize(BinaryWriter bw)
        {
            // Convert block types from an internal optimized version into global types
            ushort[] tmp = new ushort[blocks.Length];
            for (int i = 0; i < blocks.Length; i++)
            {
                tmp[i] = Chunk.world.blockProvider.GetConfig(blocks[i].Type).typeInConfig;
            }

            var positionsBytes = StructSerialization.SerializeArray(positions, Chunk.pools.MarshaledPool);
            var blocksBytes    = StructSerialization.SerializeArray(tmp, Chunk.pools.MarshaledPool);

            bw.Write(positionsBytes.Length);
            bw.Write(blocksBytes.Length);
            bw.Write(positionsBytes);
            bw.Write(blocksBytes);
        }