diff --git a/js/game.js b/js/game.js index 0d7ddfa..7aa515c 100644 --- a/js/game.js +++ b/js/game.js @@ -697,7 +697,9 @@ export class Level { this.toggle_green_objects = false; } - // Now we handle wiring + // Now we handle wiring -- three times, because CC2 runs it once per frame, not once per tic + this.update_wiring(); + this.update_wiring(); this.update_wiring(); // In the event that the player is sliding (and thus not deliberately moving) or has @@ -1167,6 +1169,12 @@ export class Level { // this needs to happen at all // FIXME none of this is currently undoable update_wiring() { + // FIXME: + // - make this undoable :( + // - blue tele, red tele, and pink button have different connections + // - would like to reuse the walk for blue teles + // - currently doesn't notice when circuit block moves sometimes + // Gather every tile that's emitting power. Along the way, check whether any of them have // changed since last tic, so we can skip this work entirely if none did let neighbors = []; @@ -1236,9 +1244,17 @@ export class Level { continue; } - // Common case: power entering a wired edge and propagating outwards. The only - // special case is that four-way wiring is two separate wires, N/S and E/W - if (wire.wire_directions === 0x0f) { + // Common case: power entering a wired edge and propagating outwards. There are a + // couple special cases: + if (wire.type.wire_propagation_mode === 'none') { + // This tile type has wires, but none of them connect to each other + cell.powered_edges |= bit; + continue; + } + else if (wire.wire_directions === 0x0f && wire.type.wire_propagation_mode !== 'all') { + // If all four wires are present, they don't actually make a four-way + // connection, but two straight wires that don't connect to each other (with the + // exception of blue teleporters) cell.powered_edges |= bit; cell.powered_edges |= DIRECTIONS[DIRECTIONS[source_direction].opposite].bit; } diff --git a/js/tileset.js b/js/tileset.js index 4b215d4..1628e47 100644 --- a/js/tileset.js +++ b/js/tileset.js @@ -1126,6 +1126,7 @@ export class Tileset { // Draw the base tile blit(drawspec.base[0], drawspec.base[1]); + // FIXME some tiles don't have active wiring on all sides... // Draw the wire part as a single rectangle, initially just a small dot in the // center, but extending out to any edge that has a wire present let x0 = 0.5 - wire_radius; diff --git a/js/tiletypes.js b/js/tiletypes.js index ac540dd..00298ec 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -1118,6 +1118,7 @@ const TILE_TYPES = { // FIXME blue teleporters transmit current 4 ways. red don't transmit it at all teleport_blue: { draw_layer: DRAW_LAYERS.terrain, + wire_propagation_mode: 'all', teleport_dest_order(me, level, other) { if (! me.wire_directions) { // TODO cc2 has a bug where, once it wraps around to the bottom right, it seems to @@ -1208,6 +1209,7 @@ const TILE_TYPES = { }, teleport_red: { draw_layer: DRAW_LAYERS.terrain, + wire_propagation_mode: 'none', teleport_try_all_directions: true, teleport_allow_override: true, _is_active(me) { @@ -1451,6 +1453,7 @@ const TILE_TYPES = { button_pink: { draw_layer: DRAW_LAYERS.terrain, is_power_source: true, + wire_propagation_mode: 'none', get_emitting_edges(me, level) { // We emit current as long as there's an actor fully on us if (me.cell.some(tile => tile.type.is_actor && tile.movement_cooldown === 0)) {