Run wiring thrice per tic; recognize some tiles have odd propagation rules
This commit is contained in:
parent
c17169f49d
commit
8671bee08b
24
js/game.js
24
js/game.js
@ -697,7 +697,9 @@ export class Level {
|
|||||||
this.toggle_green_objects = false;
|
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();
|
this.update_wiring();
|
||||||
|
|
||||||
// In the event that the player is sliding (and thus not deliberately moving) or has
|
// 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
|
// this needs to happen at all
|
||||||
// FIXME none of this is currently undoable
|
// FIXME none of this is currently undoable
|
||||||
update_wiring() {
|
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
|
// 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
|
// changed since last tic, so we can skip this work entirely if none did
|
||||||
let neighbors = [];
|
let neighbors = [];
|
||||||
@ -1236,9 +1244,17 @@ export class Level {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Common case: power entering a wired edge and propagating outwards. The only
|
// Common case: power entering a wired edge and propagating outwards. There are a
|
||||||
// special case is that four-way wiring is two separate wires, N/S and E/W
|
// couple special cases:
|
||||||
if (wire.wire_directions === 0x0f) {
|
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 |= bit;
|
||||||
cell.powered_edges |= DIRECTIONS[DIRECTIONS[source_direction].opposite].bit;
|
cell.powered_edges |= DIRECTIONS[DIRECTIONS[source_direction].opposite].bit;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1126,6 +1126,7 @@ export class Tileset {
|
|||||||
// Draw the base tile
|
// Draw the base tile
|
||||||
blit(drawspec.base[0], drawspec.base[1]);
|
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
|
// 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
|
// center, but extending out to any edge that has a wire present
|
||||||
let x0 = 0.5 - wire_radius;
|
let x0 = 0.5 - wire_radius;
|
||||||
|
|||||||
@ -1118,6 +1118,7 @@ const TILE_TYPES = {
|
|||||||
// FIXME blue teleporters transmit current 4 ways. red don't transmit it at all
|
// FIXME blue teleporters transmit current 4 ways. red don't transmit it at all
|
||||||
teleport_blue: {
|
teleport_blue: {
|
||||||
draw_layer: DRAW_LAYERS.terrain,
|
draw_layer: DRAW_LAYERS.terrain,
|
||||||
|
wire_propagation_mode: 'all',
|
||||||
teleport_dest_order(me, level, other) {
|
teleport_dest_order(me, level, other) {
|
||||||
if (! me.wire_directions) {
|
if (! me.wire_directions) {
|
||||||
// TODO cc2 has a bug where, once it wraps around to the bottom right, it seems to
|
// 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: {
|
teleport_red: {
|
||||||
draw_layer: DRAW_LAYERS.terrain,
|
draw_layer: DRAW_LAYERS.terrain,
|
||||||
|
wire_propagation_mode: 'none',
|
||||||
teleport_try_all_directions: true,
|
teleport_try_all_directions: true,
|
||||||
teleport_allow_override: true,
|
teleport_allow_override: true,
|
||||||
_is_active(me) {
|
_is_active(me) {
|
||||||
@ -1451,6 +1453,7 @@ const TILE_TYPES = {
|
|||||||
button_pink: {
|
button_pink: {
|
||||||
draw_layer: DRAW_LAYERS.terrain,
|
draw_layer: DRAW_LAYERS.terrain,
|
||||||
is_power_source: true,
|
is_power_source: true,
|
||||||
|
wire_propagation_mode: 'none',
|
||||||
get_emitting_edges(me, level) {
|
get_emitting_edges(me, level) {
|
||||||
// We emit current as long as there's an actor fully on us
|
// 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)) {
|
if (me.cell.some(tile => tile.type.is_actor && tile.movement_cooldown === 0)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user