Switch to Lynx's delayed green button effect

This commit is contained in:
Eevee (Evelyn Woods) 2021-05-07 22:39:31 -06:00
parent 87d7952960
commit b7e352a4a3
2 changed files with 46 additions and 20 deletions

View File

@ -792,6 +792,7 @@ export class Level extends LevelInterface {
} }
this._swap_players(); this._swap_players();
this._do_post_actor_phase();
// Wire updates every frame, which means thrice per tic // Wire updates every frame, which means thrice per tic
this._do_wire_phase(); this._do_wire_phase();
@ -805,6 +806,7 @@ export class Level extends LevelInterface {
_advance_tic_lynx() { _advance_tic_lynx() {
this._do_decision_phase(); this._do_decision_phase();
this._do_combined_action_phase(3); this._do_combined_action_phase(3);
this._do_post_actor_phase();
this._do_wire_phase(); this._do_wire_phase();
this._do_wire_phase(); this._do_wire_phase();
this._do_wire_phase(); this._do_wire_phase();
@ -817,16 +819,19 @@ export class Level extends LevelInterface {
_advance_tic_lynx60() { _advance_tic_lynx60() {
this._do_decision_phase(true); this._do_decision_phase(true);
this._do_combined_action_phase(1, true); this._do_combined_action_phase(1, true);
this._do_post_actor_phase();
this._do_wire_phase(); this._do_wire_phase();
this.frame_offset = 1; this.frame_offset = 1;
this._do_decision_phase(true); this._do_decision_phase(true);
this._do_combined_action_phase(1, true); this._do_combined_action_phase(1, true);
this._do_post_actor_phase();
this._do_wire_phase(); this._do_wire_phase();
this.frame_offset = 2; this.frame_offset = 2;
this._do_decision_phase(); this._do_decision_phase();
this._do_combined_action_phase(1); this._do_combined_action_phase(1);
this._do_post_actor_phase();
this._do_wire_phase(); this._do_wire_phase();
this.frame_offset = 0; this.frame_offset = 0;
@ -846,6 +851,7 @@ export class Level extends LevelInterface {
this._do_decision_phase(! is_decision_frame); this._do_decision_phase(! is_decision_frame);
this._do_combined_action_phase(1, ! is_decision_frame); this._do_combined_action_phase(1, ! is_decision_frame);
this._do_post_actor_phase();
this._do_wire_phase(); this._do_wire_phase();
if (this.frame_offset === 2) { if (this.frame_offset === 2) {
@ -903,6 +909,7 @@ export class Level extends LevelInterface {
} }
this.sfx.set_player_position(this.player.cell); this.sfx.set_player_position(this.player.cell);
this.pending_green_toggle = false;
} }
// Decision phase: all actors decide on their movement "simultaneously" // Decision phase: all actors decide on their movement "simultaneously"
@ -1153,6 +1160,31 @@ export class Level extends LevelInterface {
} }
} }
_do_post_actor_phase() {
if (this.pending_green_toggle) {
// Swap green floors and walls
// TODO could probably make this more compact for undo purposes
for (let cell of this.linear_cells) {
let terrain = cell.get_terrain();
if (terrain.type.name === 'green_floor') {
this.transmute_tile(terrain, 'green_wall');
}
else if (terrain.type.name === 'green_wall') {
this.transmute_tile(terrain, 'green_floor');
}
let item = cell.get_item();
if (item && item.type.name === 'green_chip') {
this.transmute_tile(item, 'green_bomb');
}
else if (item && item.type.name === 'green_bomb') {
this.transmute_tile(item, 'green_chip');
}
}
this.pending_green_toggle = false;
}
}
_do_cleanup_phase() { _do_cleanup_phase() {
// Lynx compat: Any blue tank that still has the reversal flag set here, but is in motion, // Lynx compat: Any blue tank that still has the reversal flag set here, but is in motion,
// should ignore it. Unfortunately this has to be done as its own pass (as it is in Lynx!) // should ignore it. Unfortunately this has to be done as its own pass (as it is in Lynx!)

View File

@ -1335,6 +1335,13 @@ const TILE_TYPES = {
}, },
green_floor: { green_floor: {
layer: LAYERS.terrain, layer: LAYERS.terrain,
blocks(me, level, other) {
// Toggle walls don't toggle until the end of the frame, but the collision takes into
// account whether a toggle is coming
return (
level.pending_green_toggle &&
(other.type.collision_mask & COLLISION.all_but_ghost));
},
on_gray_button(me, level) { on_gray_button(me, level) {
level.transmute_tile(me, 'green_wall'); level.transmute_tile(me, 'green_wall');
}, },
@ -1344,7 +1351,12 @@ const TILE_TYPES = {
}, },
green_wall: { green_wall: {
layer: LAYERS.terrain, layer: LAYERS.terrain,
blocks_collision: COLLISION.all_but_ghost, blocks(me, level, other) {
// Same as above
return (
! level.pending_green_toggle &&
(other.type.collision_mask & COLLISION.all_but_ghost));
},
on_gray_button(me, level) { on_gray_button(me, level) {
level.transmute_tile(me, 'green_floor'); level.transmute_tile(me, 'green_floor');
}, },
@ -2034,25 +2046,7 @@ const TILE_TYPES = {
button_green: { button_green: {
layer: LAYERS.terrain, layer: LAYERS.terrain,
do_button(level) { do_button(level) {
// Swap green floors and walls level.pending_green_toggle = ! level.pending_green_toggle;
// TODO could probably make this more compact for undo purposes
for (let cell of level.linear_cells) {
let terrain = cell.get_terrain();
if (terrain.type.name === 'green_floor') {
level.transmute_tile(terrain, 'green_wall');
}
else if (terrain.type.name === 'green_wall') {
level.transmute_tile(terrain, 'green_floor');
}
let item = cell.get_item();
if (item && item.type.name === 'green_chip') {
level.transmute_tile(item, 'green_bomb');
}
else if (item && item.type.name === 'green_bomb') {
level.transmute_tile(item, 'green_chip');
}
}
}, },
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);