Split teleporting into its own pass, like Lynx
This commit is contained in:
parent
93954135d2
commit
0f5b8098f6
24
js/game.js
24
js/game.js
@ -587,6 +587,19 @@ export class Level {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mini extra pass: deal with teleporting separately. Otherwise, actors may have been in
|
||||
// the way of the teleporter but finished moving away during the above loop; this is
|
||||
// particularly bad when it happens with a block you're pushing.
|
||||
for (let i = this.actors.length - 1; i >= 0; i--) {
|
||||
let actor = this.actors[i];
|
||||
if (! actor.cell)
|
||||
continue;
|
||||
|
||||
if (actor.just_stepped_on_teleporter) {
|
||||
this.attempt_teleport(actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
finish_tic(p1_actions) {
|
||||
@ -1087,7 +1100,6 @@ export class Level {
|
||||
|
||||
// Step on every tile in a cell we just arrived in
|
||||
step_on_cell(actor, cell) {
|
||||
let teleporter;
|
||||
// Step on topmost things first -- notably, it's safe to step on water with flippers on top
|
||||
for (let tile of Array.from(cell).reverse()) {
|
||||
if (tile === actor)
|
||||
@ -1108,16 +1120,21 @@ export class Level {
|
||||
}
|
||||
}
|
||||
else if (tile.type.teleport_dest_order) {
|
||||
teleporter = tile;
|
||||
// This is used by an extra pass just after our caller, so it doesn't need to undo
|
||||
actor.just_stepped_on_teleporter = tile;
|
||||
}
|
||||
else if (tile.type.on_arrive) {
|
||||
tile.type.on_arrive(tile, this, actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
attempt_teleport(actor) {
|
||||
let teleporter = actor.just_stepped_on_teleporter;
|
||||
actor.just_stepped_on_teleporter = null;
|
||||
|
||||
// Handle teleporting, now that the dust has cleared
|
||||
// FIXME something funny happening here, your input isn't ignored while walking out of it?
|
||||
if (teleporter) {
|
||||
let original_direction = actor.direction;
|
||||
let success = false;
|
||||
for (let dest of teleporter.type.teleport_dest_order(teleporter, this, actor)) {
|
||||
@ -1180,7 +1197,6 @@ export class Level {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
remember_player_move(direction) {
|
||||
if (this.player.type.name === 'player') {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user