Make cloning undoable

This commit is contained in:
Eevee (Evelyn Woods) 2020-09-12 21:00:50 -06:00
parent b26820d99b
commit f511e2ecb9
2 changed files with 6 additions and 1 deletions

View File

@ -929,6 +929,11 @@ export class Level {
this.pending_undo.push(() => cell._remove(tile)); this.pending_undo.push(() => cell._remove(tile));
} }
add_actor(actor) {
this.actors.push(actor);
this.pending_undo.push(() => this.actors.pop());
}
spawn_animation(cell, name) { spawn_animation(cell, name) {
let type = TILE_TYPES[name]; let type = TILE_TYPES[name];
let tile = new Tile(type); let tile = new Tile(type);

View File

@ -532,7 +532,7 @@ const TILE_TYPES = {
// abort the clone // abort the clone
level.set_actor_stuck(tile, false); level.set_actor_stuck(tile, false);
if (level.attempt_step(tile, direction)) { if (level.attempt_step(tile, direction)) {
level.actors.push(tile); level.add_actor(tile);
// FIXME add this underneath, just above the cloner // FIXME add this underneath, just above the cloner
let new_tile = new tile.constructor(type, direction); let new_tile = new tile.constructor(type, direction);
level.add_tile(new_tile, cell); level.add_tile(new_tile, cell);