MegaMan.Editor.Bll.Tools.MultiTileBrush.DrawOn C# (CSharp) Method

DrawOn() public method

Draws the brush onto the given screen at the given tile location.
public DrawOn ( ScreenDocument screen, int tile_x, int tile_y ) : IEnumerable
screen ScreenDocument
tile_x int
tile_y int
return IEnumerable
        public IEnumerable<TileChange> DrawOn(ScreenDocument screen, int tile_x, int tile_y)
        {
            List<TileChange> undo = new List<TileChange>();
            bool changed = false;
            foreach (TileBrushCell[] col in _cells)
            {
                foreach (TileBrushCell cell in col)
                {
                    var old = screen.TileAt(cell.x + tile_x, cell.y + tile_y);

                    if (old == null) continue;

                    undo.Add(new TileChange(screen, cell.x, cell.y, old.Id, cell.tile.Id));
                    if (old.Id != cell.tile.Id)
                    {
                        changed = true;
                        screen.ChangeTile(cell.x + tile_x, cell.y + tile_y, cell.tile.Id);
                    }
                }
            }

            if (changed)
            {
                return undo;
            }

            return Enumerable.Empty<TileChange>();
        }