fCraft.BuildingCommands.CenterCallback C# (CSharp) Method

CenterCallback() private static method

private static CenterCallback ( Player player, Vector3I marks, object tag ) : void
player Player
marks Vector3I
tag object
return void
        private static void CenterCallback( Player player, Vector3I[] marks, object tag )
        {
            if ( player.LastUsedBlockType != Block.Undefined ) {
                int sx = Math.Min( marks[0].X, marks[1].X ), ex = Math.Max( marks[0].X, marks[1].X ),
                sy = Math.Min( marks[0].Y, marks[1].Y ), ey = Math.Max( marks[0].Y, marks[1].Y ),
                sz = Math.Min( marks[0].Z, marks[1].Z ), ez = Math.Max( marks[0].Z, marks[1].Z );

                BoundingBox bounds = new BoundingBox( sx, sy, sz, ex, ey, ez );
                Vector3I cPos = new Vector3I( ( bounds.XMin + bounds.XMax ) / 2,
                    ( bounds.YMin + bounds.YMax ) / 2,
                    ( bounds.ZMin + bounds.ZMax ) / 2 );
                int blocksDrawn = 0,
                blocksSkipped = 0;
                UndoState undoState = player.DrawBegin( null );

                World playerWorld = player.World;
                if ( playerWorld == null )
                    PlayerOpException.ThrowNoWorld( player );
                DrawOneBlock( player, player.World.Map, player.LastUsedBlockType, cPos,
                          BlockChangeContext.Drawn,
                          ref blocksDrawn, ref blocksSkipped, undoState );
                DrawingFinished( player, "Placed", blocksDrawn, blocksSkipped );
            } else {
                player.Message( "&WCannot deduce desired block. Click a block or type out the block name." );
            }
        }