Visually indicate when a floor is in an odd wiring state
This distinguished a regular crossed floor from what you get when blowing up e.g. a blue or red teleporter. Fixes #60.
This commit is contained in:
parent
bef5550a95
commit
3802b10956
@ -1522,7 +1522,6 @@ export const LL_TILESET_LAYOUT = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
button_black: {
|
button_black: {
|
||||||
__special__: 'wires',
|
|
||||||
__special__: 'wires',
|
__special__: 'wires',
|
||||||
base: [0, 2],
|
base: [0, 2],
|
||||||
wired: {
|
wired: {
|
||||||
@ -2253,14 +2252,15 @@ export class Tileset {
|
|||||||
|
|
||||||
_draw_wires(drawspec, name, tile, packet) {
|
_draw_wires(drawspec, name, tile, packet) {
|
||||||
// This /should/ match CC2's draw order exactly, based on experimentation
|
// This /should/ match CC2's draw order exactly, based on experimentation
|
||||||
let wire_radius = this.layout['#wire-width'] / 2;
|
|
||||||
// TODO circuit block with a lightning bolt is always powered
|
// TODO circuit block with a lightning bolt is always powered
|
||||||
// TODO circuit block in motion doesn't inherit cell's power
|
// TODO circuit block in motion doesn't inherit cell's power
|
||||||
if (tile && tile.wire_directions && ! packet.hide_logic) {
|
if (tile && tile.wire_directions && ! packet.hide_logic) {
|
||||||
// Draw the base tile
|
// Draw the base tile
|
||||||
packet.blit(drawspec.base[0], drawspec.base[1]);
|
packet.blit(drawspec.base[0], drawspec.base[1]);
|
||||||
|
|
||||||
let is_crossed = (tile.wire_directions === 0x0f && drawspec.wired_cross);
|
let mode = tile.wire_propagation_mode || TILE_TYPES[name].wire_propagation_mode;
|
||||||
|
let is_crossed = (
|
||||||
|
tile.wire_directions === 0x0f && drawspec.wired_cross && mode === 'cross');
|
||||||
if (is_crossed && tile.powered_edges && tile.powered_edges !== 0x0f) {
|
if (is_crossed && tile.powered_edges && tile.powered_edges !== 0x0f) {
|
||||||
// For crossed wires with different power, order matters; horizontal is on top
|
// For crossed wires with different power, order matters; horizontal is on top
|
||||||
// TODO note that this enforces the CC2 wire order
|
// TODO note that this enforces the CC2 wire order
|
||||||
@ -2275,6 +2275,14 @@ export class Tileset {
|
|||||||
}
|
}
|
||||||
// Then draw the wired tile on top of it all
|
// Then draw the wired tile on top of it all
|
||||||
this.draw_drawspec(is_crossed ? drawspec.wired_cross : drawspec.wired, name, tile, packet);
|
this.draw_drawspec(is_crossed ? drawspec.wired_cross : drawspec.wired, name, tile, packet);
|
||||||
|
|
||||||
|
if (drawspec.wired_cross && mode === 'none') {
|
||||||
|
// Extremely weird case: this tile was /designed/ to be drawn crossed, but something
|
||||||
|
// has happened and it doesn't propagate current at all. (This is usually because
|
||||||
|
// e.g. a red teleporter was destroyed, leaving floor in a weird mode.)
|
||||||
|
// Show the wires are disconnected by drawing a chunk of the base tile in the center
|
||||||
|
packet.blit(drawspec.base[0], drawspec.base[1], 0.375, 0.375, 0.25, 0.25);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// There's no wiring here, so just draw the base and then draw the wired part on top
|
// There's no wiring here, so just draw the base and then draw the wired part on top
|
||||||
|
|||||||
@ -251,6 +251,7 @@ const TILE_TYPES = {
|
|||||||
floor: {
|
floor: {
|
||||||
layer: LAYERS.terrain,
|
layer: LAYERS.terrain,
|
||||||
contains_wire: true,
|
contains_wire: true,
|
||||||
|
wire_propagation_mode: 'cross',
|
||||||
on_approach(me, level, other) {
|
on_approach(me, level, other) {
|
||||||
if (other.type.name === 'blob' || other.type.name === 'boulder') {
|
if (other.type.name === 'blob' || other.type.name === 'boulder') {
|
||||||
// Blobs spread slime onto floor
|
// Blobs spread slime onto floor
|
||||||
@ -473,6 +474,7 @@ const TILE_TYPES = {
|
|||||||
layer: LAYERS.terrain,
|
layer: LAYERS.terrain,
|
||||||
blocks_collision: COLLISION.all,
|
blocks_collision: COLLISION.all,
|
||||||
contains_wire: true,
|
contains_wire: true,
|
||||||
|
wire_propagation_mode: 'cross',
|
||||||
},
|
},
|
||||||
canopy: {
|
canopy: {
|
||||||
layer: LAYERS.canopy,
|
layer: LAYERS.canopy,
|
||||||
@ -2406,6 +2408,7 @@ const TILE_TYPES = {
|
|||||||
is_actor: true,
|
is_actor: true,
|
||||||
is_block: true,
|
is_block: true,
|
||||||
contains_wire: true,
|
contains_wire: true,
|
||||||
|
wire_propagation_mode: 'cross',
|
||||||
can_reverse_on_railroad: true,
|
can_reverse_on_railroad: true,
|
||||||
movement_speed: 4,
|
movement_speed: 4,
|
||||||
on_clone(me, original) {
|
on_clone(me, original) {
|
||||||
@ -2831,6 +2834,16 @@ const TILE_TYPES = {
|
|||||||
removed_anything = true;
|
removed_anything = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Super duper weird special case: both CC2 and LL precompute the wiring
|
||||||
|
// layout, and as a fun side effect, a destroyed blue teleporter becomes
|
||||||
|
// a floor tile that can genuinely conduct in all four directions.
|
||||||
|
// (The red teleporter, similarly, inhibits current.)
|
||||||
|
// This doesn't require any real logic changes, but for readability,
|
||||||
|
// inform the renderer.
|
||||||
|
if (terrain.type.wire_propagation_mode) {
|
||||||
|
level._set_tile_prop(terrain, 'wire_propagation_mode',
|
||||||
|
terrain.type.wire_propagation_mode);
|
||||||
|
}
|
||||||
level.transmute_tile(terrain, 'floor');
|
level.transmute_tile(terrain, 'floor');
|
||||||
removed_anything = true;
|
removed_anything = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user