fCraft.BuildingCommands.RestoreCallback C# (CSharp) Method

RestoreCallback() private static method

private static RestoreCallback ( Player player, Vector3I marks, object tag ) : void
player Player
marks Vector3I
tag object
return void
        private static void RestoreCallback( Player player, Vector3I[] marks, object tag )
        {
            BoundingBox selection = new BoundingBox( marks[0], marks[1] );
            Map map = ( Map )tag;

            if ( !player.CanDraw( selection.Volume ) ) {
                player.MessageNow(
                    "You are only allowed to restore up to {0} blocks at a time. This would affect {1} blocks.",
                    player.Info.Rank.DrawLimit,
                    selection.Volume );
                return;
            }

            int blocksDrawn = 0,
                blocksSkipped = 0;
            UndoState undoState = player.DrawBegin( null );

            World playerWorld = player.World;
            if ( playerWorld == null )
                PlayerOpException.ThrowNoWorld( player );
            Map playerMap = player.WorldMap;
            for ( int x = selection.XMin; x <= selection.XMax; x++ ) {
                for ( int y = selection.YMin; y <= selection.YMax; y++ ) {
                    for ( int z = selection.ZMin; z <= selection.ZMax; z++ ) {
                        DrawOneBlock( player, playerMap, map.GetBlock( x, y, z ), new Vector3I( x, y, z ),
                                      RestoreContext,
                                      ref blocksDrawn, ref blocksSkipped, undoState );
                    }
                }
            }

            Logger.Log( LogType.UserActivity,
                        "{0} restored {1} blocks on world {2} (@{3},{4},{5} - {6},{7},{8}) from file {9}.",
                        player.Name, blocksDrawn,
                        playerWorld.Name,
                        selection.XMin, selection.YMin, selection.ZMin,
                        selection.XMax, selection.YMax, selection.ZMax,
                        map.Metadata["fCraft.Temp", "FileName"] );

            DrawingFinished( player, "Restored", blocksDrawn, blocksSkipped );
        }