예제 #1
0
        public bool Save( Map MapToSave, Stream MapStream )
        {
            BinaryWriter bs = new BinaryWriter( MapStream );

            // Write the magic number
            bs.Write( Identifier );

            // Write the map dimensions
            bs.Write( MapToSave.widthX );
            bs.Write( MapToSave.widthY );
            bs.Write( MapToSave.height );

            // Write the spawn location
            bs.Write( MapToSave.spawn.x );
            bs.Write( MapToSave.spawn.y );
            bs.Write( MapToSave.spawn.h );

            // Write the spawn orientation
            bs.Write( MapToSave.spawn.r );
            bs.Write( MapToSave.spawn.l );

            // Skip metadata pair count
            MapToSave.WriteMetadata( bs );

            // Write the map data
            using ( GZipStream gs = new GZipStream( MapStream, CompressionMode.Compress, true ) ) {
                gs.Write( MapToSave.blocks, 0, MapToSave.blocks.Length );
            }

            bs.Close();

            return true;
        }