fCraft.ShapesLib.DrawOneBlock C# (CSharp) Method

DrawOneBlock() private static method

private static DrawOneBlock ( Player player, Map map, Block drawBlock, Vector3I coord, BlockChangeContext context, int &blocks, int &blocksDenied, fCraft undoState ) : void
player Player
map Map
drawBlock Block
coord Vector3I
context BlockChangeContext
blocks int
blocksDenied int
undoState fCraft
return void
        private static void DrawOneBlock( Player player, Map map, Block drawBlock, Vector3I coord,
                                 BlockChangeContext context, ref int blocks, ref int blocksDenied, fCraft.Drawing.UndoState undoState )
        {
            if ( map == null )
                return;
            if ( player == null )
                throw new ArgumentNullException( "player" );

            if ( !map.InBounds( coord ) )
                return;
            Block block = map.GetBlock( coord );
            if ( block == drawBlock )
                return;

            if ( player.CanPlace( map, coord, drawBlock, context ) != CanPlaceResult.Allowed ) {
                blocksDenied++;
                return;
            }

            map.QueueUpdate( new BlockUpdate( null, coord, drawBlock ) );
            Player.RaisePlayerPlacedBlockEvent( player, map, coord, block, drawBlock, context );

            if ( !undoState.IsTooLargeToUndo ) {
                if ( !undoState.Add( coord, block ) ) {
                    player.Message( "NOTE: This draw command is too massive to undo." );
                    player.LastDrawOp = null;
                }
            }
            blocks++;
        }