From 1bd165ad35c8508d5d26ba92238f8cd0d152b718 Mon Sep 17 00:00:00 2001 From: Timothy Stiles Date: Mon, 15 Feb 2021 15:37:03 +1100 Subject: [PATCH] fix various Circuit Block cases --- js/game.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/js/game.js b/js/game.js index da6dc9d..5668258 100644 --- a/js/game.js +++ b/js/game.js @@ -529,6 +529,7 @@ export class Level extends LevelInterface { this.connect_button(connectable); } + this.force_next_wire_phase = false; this.recalculate_circuitry(true); // Finally, let all tiles do custom init behavior... but backwards, to match actor order @@ -674,7 +675,7 @@ export class Level extends LevelInterface { continue; let circuit = { - is_powered: false, + is_powered: first_time ? false : null, tiles: new Map, inputs: new Map, }; @@ -739,7 +740,13 @@ export class Level extends LevelInterface { } this.wired_outputs = Array.from(wired_outputs); this.wired_outputs.sort((a, b) => this.coords_to_scalar(a.cell.x, a.cell.y) - this.coords_to_scalar(b.cell.x, b.cell.y)); + + if (!first_time) { + this.force_next_wire_phase = true; + } } + + can_accept_input() { // We can accept input anytime the player can move, i.e. when they're not already moving and @@ -2012,8 +2019,14 @@ export class Level extends LevelInterface { } } - if (! any_changed) - return; + if (! any_changed) { + if (this.force_next_wire_phase) { + this.force_next_wire_phase = false; + } + else { + return; + } + } for (let tile of this.wired_outputs) { // This is only used within this function, no need to undo