From 6063ea9fba26d457409e6ace600d0cbd0441623a Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Wed, 9 Dec 2020 21:07:14 -0700 Subject: [PATCH] Wired tracks only switch on pulse; wired red teleports only work when powered --- js/game.js | 16 ++++++++++++++++ js/tiletypes.js | 23 +++++++++++++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/js/game.js b/js/game.js index ff04b5c..510c493 100644 --- a/js/game.js +++ b/js/game.js @@ -1389,6 +1389,22 @@ export class Level { } } + is_cell_wired(cell) { + for (let direction of Object.keys(DIRECTIONS)) { + let neighbor = this.get_neighboring_cell(cell, direction); + if (! neighbor) + continue; + + let wired = neighbor.get_wired_tile(); + if (! wired) + continue; + + if (wired.wire_directions & DIRECTIONS[DIRECTIONS[direction].opposite].bit) + return true; + } + return false; + } + // ------------------------------------------------------------------------- // Undo handling diff --git a/js/tiletypes.js b/js/tiletypes.js index c05e230..2f8884a 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -479,8 +479,9 @@ const TILE_TYPES = { } } - // FIXME this only happens if we're unwired, but i don't have a way to check that atm - me.type._switch_track(me, level); + if (! level.is_cell_wired(me.cell)) { + me.type._switch_track(me, level); + } }, on_power(me, level) { me.type._switch_track(me, level); @@ -517,8 +518,6 @@ const TILE_TYPES = { // FIXME i think in this case the actor gets stuck, but, facing which way? return direction; }, - // FIXME track switches on depart or power or gray button - // FIXME rotate dir blocks }, // Locked doors @@ -1116,6 +1115,8 @@ const TILE_TYPES = { teleport_blue: { draw_layer: DRAW_LAYERS.terrain, teleport_dest_order(me, level, other) { + // FIXME wired teleports form a network, which is complicated, and logic gates + // complicate it further return level.iter_tiles_in_reading_order(me.cell, 'teleport_blue', true); }, }, @@ -1123,8 +1124,18 @@ const TILE_TYPES = { draw_layer: DRAW_LAYERS.terrain, teleport_try_all_directions: true, teleport_allow_override: true, - teleport_dest_order(me, level, other) { - return level.iter_tiles_in_reading_order(me.cell, 'teleport_red'); + *teleport_dest_order(me, level, other) { + // Wired red teleporters can be turned off, which disconnects them from every other red + // teleporter (but they still teleport to themselves) + if (level.is_cell_wired(me.cell) && me.cell.powered_edges === 0) { + yield me; + return; + } + for (let tile of level.iter_tiles_in_reading_order(me.cell, 'teleport_red')) { + if (tile !== me && level.is_cell_wired(tile.cell) && tile.cell.powered_edges === 0) + continue; + yield tile; + } }, }, teleport_green: {