Fix yellow tank behavior to be faux simultaneous
This commit is contained in:
parent
a529414e42
commit
bf3c501353
14
js/game.js
14
js/game.js
@ -943,11 +943,7 @@ export class Level {
|
||||
|
||||
direction = actor.cell.redirect_exit(actor, direction);
|
||||
|
||||
let dest_cell = this.get_neighboring_cell(actor.cell, direction);
|
||||
if (dest_cell &&
|
||||
! actor.cell.blocks_leaving(actor, direction) &&
|
||||
! dest_cell.blocks_entering(actor, direction, this, actor === this.player ? 'move' : 'trace'))
|
||||
{
|
||||
if (this.is_move_allowed(actor, direction, 'trace')) {
|
||||
// We found a good direction! Stop here
|
||||
actor.decision = direction;
|
||||
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.
|
||||
// Return true if successful.
|
||||
attempt_step(actor, direction) {
|
||||
|
||||
@ -1339,14 +1339,22 @@ const TILE_TYPES = {
|
||||
on_arrive(me, level, other) {
|
||||
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--) {
|
||||
let actor = level.actors[i];
|
||||
// TODO generify somehow??
|
||||
if (actor.type.name === 'tank_yellow') {
|
||||
level.attempt_out_of_turn_step(actor, other.direction);
|
||||
if (actor.type.name === 'tank_yellow' && level.is_move_allowed(actor, other.direction, 'trace')) {
|
||||
unblocked_tanks.push(actor);
|
||||
}
|
||||
}
|
||||
for (let actor of unblocked_tanks) {
|
||||
level.attempt_out_of_turn_step(actor, other.direction);
|
||||
}
|
||||
},
|
||||
on_depart(me, level, other) {
|
||||
level.sfx.play_once('button-release', me.cell);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user