Fix yellow tank behavior to be faux simultaneous

This commit is contained in:
Eevee (Evelyn Woods) 2020-12-14 23:14:31 -07:00
parent a529414e42
commit bf3c501353
2 changed files with 20 additions and 8 deletions

View File

@ -943,11 +943,7 @@ export class Level {
direction = actor.cell.redirect_exit(actor, direction); direction = actor.cell.redirect_exit(actor, direction);
let dest_cell = this.get_neighboring_cell(actor.cell, direction); if (this.is_move_allowed(actor, direction, 'trace')) {
if (dest_cell &&
! actor.cell.blocks_leaving(actor, direction) &&
! dest_cell.blocks_entering(actor, direction, this, actor === this.player ? 'move' : 'trace'))
{
// We found a good direction! Stop here // We found a good direction! Stop here
actor.decision = direction; actor.decision = direction;
all_blocked = false; all_blocked = false;
@ -988,6 +984,14 @@ export class Level {
} }
} }
// FIXME make this interact with railroads correctly and use it for players and in attempt_step
is_move_allowed(actor, direction, push_mode) {
let dest_cell = this.get_neighboring_cell(actor.cell, direction);
return (dest_cell &&
! actor.cell.blocks_leaving(actor, direction) &&
! dest_cell.blocks_entering(actor, direction, this, push_mode));
}
// Try to move the given actor one tile in the given direction and update their cooldown. // Try to move the given actor one tile in the given direction and update their cooldown.
// Return true if successful. // Return true if successful.
attempt_step(actor, direction) { attempt_step(actor, direction) {

View File

@ -1339,14 +1339,22 @@ const TILE_TYPES = {
on_arrive(me, level, other) { on_arrive(me, level, other) {
level.sfx.play_once('button-press', me.cell); level.sfx.play_once('button-press', me.cell);
// Move all yellow tanks one tile in the direction of the pressing actor // Move all yellow tanks one tile in the direction of the pressing actor. But pretend
// it's simultaneous, so one in front will block one behind as usual.
// XXX this feels really weird, i'm wondering if cc2 does some other weird thing like
// not move any actor out of its cell until its first cooldown tick??
// FIXME not sure this interacts with railroads correctly
let unblocked_tanks = [];
for (let i = level.actors.length - 1; i >= 0; i--) { for (let i = level.actors.length - 1; i >= 0; i--) {
let actor = level.actors[i]; let actor = level.actors[i];
// TODO generify somehow?? // TODO generify somehow??
if (actor.type.name === 'tank_yellow') { if (actor.type.name === 'tank_yellow' && level.is_move_allowed(actor, other.direction, 'trace')) {
level.attempt_out_of_turn_step(actor, other.direction); unblocked_tanks.push(actor);
} }
} }
for (let actor of unblocked_tanks) {
level.attempt_out_of_turn_step(actor, other.direction);
}
}, },
on_depart(me, level, other) { on_depart(me, level, other) {
level.sfx.play_once('button-release', me.cell); level.sfx.play_once('button-release', me.cell);