Fix bumping to only happen on departure; add a CC2 input tiebreaker

This commit is contained in:
Eevee (Evelyn Woods) 2020-09-14 21:45:27 -06:00
parent 045bcb5789
commit 67228d89d1
2 changed files with 30 additions and 19 deletions

View File

@ -538,11 +538,31 @@ export class Level {
continue; continue;
this.set_actor_direction(actor, actor.decision); this.set_actor_direction(actor, actor.decision);
let old_cell = actor.cell;
this.attempt_step(actor, actor.decision); this.attempt_step(actor, actor.decision);
// TODO do i need to do this more aggressively? // TODO do i need to do this more aggressively?
if (this.state === 'success' || this.state === 'failure') if (this.state === 'success' || this.state === 'failure')
break; break;
// Players can also bump the tiles in the cell next to the one they're leaving
if (actor.type.is_player && actor.secondary_direction) {
let neighbor = this.cell_with_offset(old_cell, actor.secondary_direction);
if (neighbor) {
for (let tile of neighbor) {
// TODO only works if tile can be entered!
// TODO repeating myself with tile.stuck (also should technically check for actor)
if (actor.type.pushes && actor.type.pushes[tile.type.name] && tile.movement_cooldown === 0 && ! tile.stuck) {
// Block slapping: you can shove a block by walking past it sideways
this.set_actor_direction(tile, actor.secondary_direction);
this.attempt_step(tile, actor.secondary_direction);
}
else if (tile.type.on_bump) {
tile.type.on_bump(tile, this, actor);
}
}
}
}
} }
// Strip out any destroyed actors from the acting order // Strip out any destroyed actors from the acting order
@ -766,24 +786,6 @@ export class Level {
} }
} }
// Players can also bump the tiles next to where they landed
if (actor.type.is_player && actor.secondary_direction) {
let neighbor = this.cell_with_offset(actor.cell, actor.secondary_direction);
if (neighbor) {
for (let tile of neighbor) {
// TODO repeating myself with tile.stuck (also should technically check for actor)
if (actor.type.pushes && actor.type.pushes[tile.type.name] && tile.movement_cooldown === 0 && ! tile.stuck) {
// Block slapping: you can shove a block by walking past it sideways
this.set_actor_direction(tile, actor.secondary_direction);
this.attempt_step(tile, actor.secondary_direction);
}
else if (tile.type.on_bump) {
tile.type.on_bump(tile, this, actor);
}
}
}
}
// 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?
if (teleporter) { if (teleporter) {

View File

@ -444,6 +444,14 @@ class Player extends PrimaryView {
// way, act like we're starting from scratch and check keys in priority order // way, act like we're starting from scratch and check keys in priority order
this.primary_action = null; this.primary_action = null;
this.secondary_action = null; this.secondary_action = null;
// As a tiebreaker, first check if we're holding the key corresponding to the
// player's facing direction
let player_facing_action = DIRECTIONS[this.level.player.direction].action;
if (input.has(player_facing_action)) {
this.primary_action = player_facing_action;
}
for (let action of ['down', 'left', 'right', 'up']) { for (let action of ['down', 'left', 'right', 'up']) {
if (! input.has(action)) if (! input.has(action))
continue; continue;
@ -451,10 +459,11 @@ class Player extends PrimaryView {
if (! this.primary_action) { if (! this.primary_action) {
this.primary_action = action; this.primary_action = action;
} }
else { else if (action !== this.primary_action) {
// Note that because of the opposing keys check, there can never be more // Note that because of the opposing keys check, there can never be more
// than two keys held down here // than two keys held down here
this.secondary_action = action; this.secondary_action = action;
break;
} }
} }
} }