Make teleporting undoable

This commit is contained in:
Eevee (Evelyn Woods) 2020-09-14 18:09:13 -06:00
parent b88d42582c
commit 13b4180ab8

View File

@ -791,18 +791,15 @@ export class Level {
// Handle teleporting, now that the dust has cleared // Handle teleporting, now that the dust has cleared
// FIXME something funny happening here, your input isn't ignore while walking out of it? // FIXME something funny happening here, your input isn't ignore while walking out of it?
let current_cell = actor.cell;
if (teleporter) { if (teleporter) {
let goal = teleporter.connection; let goal = teleporter.connection;
// TODO in pathological cases this might infinite loop // TODO in pathological cases this might infinite loop
while (true) { while (true) {
// Physically move the actor to the new teleporter // Physically move the actor to the new teleporter
// XXX is this right, compare with tile world? i overhear it's actually implemented as a slide? // XXX is this right, compare with tile world? i overhear it's actually implemented as a slide?
// XXX will probably play badly with undo lol // XXX not especially undo-efficient
let tele_cell = goal.cell; this.remove_tile(actor);
current_cell._remove(actor); this.add_tile(actor, goal.cell);
tele_cell._add(actor);
current_cell = tele_cell;
if (this.attempt_step(actor, actor.direction)) if (this.attempt_step(actor, actor.direction))
// Success, teleportation complete // Success, teleportation complete
break; break;