fCraft.Drawing.DrawOperation.DrawOneBlock C# (CSharp) Method

DrawOneBlock() protected method

protected DrawOneBlock ( ) : bool
return bool
        protected bool DrawOneBlock()
        {
            BlocksProcessed++;

            if ( !Map.InBounds( Coords ) ) {
                BlocksSkipped++;
                return false;
            }

            #if DEBUG_CHECK_DUPLICATE_COORDS
            TestForDuplicateModification();
            #endif

            Block newBlock = Brush.NextBlock( this );
            if ( newBlock == Block.Undefined )
                return false;

            int blockIndex = Map.Index( Coords );

            Block oldBlock = ( Block )Map.Blocks[blockIndex];
            if ( oldBlock == newBlock ) {
                BlocksSkipped++;
                return false;
            }

            if ( Player.CanPlace( Map, Coords, newBlock, Context ) != CanPlaceResult.Allowed ) {
                BlocksDenied++;
                return false;
            }

            Map.Blocks[blockIndex] = ( byte )newBlock;

            World world = Map.World;
            if ( world != null && !world.IsFlushing ) {
                world.Players.SendLowPriority( PacketWriter.MakeSetBlock( Coords, newBlock ) );
            }

            Player.RaisePlayerPlacedBlockEvent( Player, Map, Coords,
                                                oldBlock, newBlock, Context );

            if ( !UndoState.IsTooLargeToUndo ) {
                if ( !UndoState.Add( Coords, oldBlock ) ) {
                    Player.LastDrawOp = null;
                    Player.Message( "{0}: Too many blocks to undo.", Description );
                }
            }

            BlocksUpdated++;
            return true;
        }