fCraft.DrawCommands.DrawOneBlock C# (CSharp) Method

DrawOneBlock() static private method

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

            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.MessageNow("NOTE: This draw command is too massive to undo.");
                    player.LastDrawOp = null;
                }
            }
            blocks++;
        }