public static IReplayableOperation CreateLiftAreaOperation(IMapModel map, int x, int y, int width, int height) { // copy the target area to a new tile var tile = new MapTile(width, height); GridMethods.Copy(map.Tile.TileGrid, tile.TileGrid, x, y, 0, 0, width, height); GridMethods.Copy(map.Tile.HeightGrid, tile.HeightGrid, x * 2, y * 2, 0, 0, width * 2, height * 2); var positionedTile = new Positioned <IMapTile>(tile, new Point(x, y)); var addOp = new AddFloatingTileOperation(map, positionedTile); var clearBitmapOp = new FillAreaOperation <Bitmap>(map.Tile.TileGrid, x, y, width, height, Globals.DefaultTile); var clearHeightOp = new FillAreaOperation <int>(map.Tile.HeightGrid, x * 2, y * 2, width * 2, height * 2, 0); return(new CompositeOperation(addOp, clearBitmapOp, clearHeightOp)); }
public CopyAreaOperation(IGrid <T> source, IGrid <T> destination, int sourceX, int sourceY, int destX, int destY, int width, int height) { this.source = source; this.destination = destination; this.sourceX = sourceX; this.sourceY = sourceY; this.destX = destX; this.destY = destY; this.width = width; this.height = height; this.oldContents = new Grid <T>(width, height); GridMethods.Copy(destination, this.oldContents, destX, destY, 0, 0, width, height); }
public void Undo() { GridMethods.Copy(this.oldContents, this.destination, this.destX, this.destY); }
public void Execute() { GridMethods.Copy(this.source, this.destination, this.sourceX, this.sourceY, this.destX, this.destY, this.width, this.height); }
public void Undo() { GridMethods.Copy(this.oldContents, this.target, this.x, this.y); }
public void Execute() { this.oldContents = new Grid <T>(this.width, this.height); GridMethods.Copy(this.target, this.oldContents, this.x, this.y, 0, 0, this.width, this.height); GridMethods.Fill(this.target, this.x, this.y, this.width, this.height, this.fillValue); }