Implement wire tunnel nesting
This commit is contained in:
parent
7c82a4cdf9
commit
03553a5c27
12
js/game.js
12
js/game.js
@ -1514,7 +1514,7 @@ export class Level {
|
|||||||
let opposite_bit = DIRECTIONS[dirinfo.opposite].bit;
|
let opposite_bit = DIRECTIONS[dirinfo.opposite].bit;
|
||||||
if (wire && (wire.wire_tunnel_directions & dirinfo.bit)) {
|
if (wire && (wire.wire_tunnel_directions & dirinfo.bit)) {
|
||||||
// Search in the given direction until we find a matching tunnel
|
// Search in the given direction until we find a matching tunnel
|
||||||
// FIXME these act like nested parens!
|
// These act like nested parens!
|
||||||
let x = cell.x;
|
let x = cell.x;
|
||||||
let y = cell.y;
|
let y = cell.y;
|
||||||
let nesting = 0;
|
let nesting = 0;
|
||||||
@ -1526,10 +1526,18 @@ export class Level {
|
|||||||
|
|
||||||
let candidate = this.cells[y][x];
|
let candidate = this.cells[y][x];
|
||||||
neighbor_wire = candidate.get_wired_tile();
|
neighbor_wire = candidate.get_wired_tile();
|
||||||
if (neighbor_wire && ((neighbor_wire.wire_tunnel_directions ?? 0) & opposite_bit)) {
|
if (neighbor_wire && neighbor_wire.wire_tunnel_directions) {
|
||||||
|
if (neighbor_wire.wire_tunnel_directions & opposite_bit) {
|
||||||
|
if (nesting <= 0) {
|
||||||
neighbor = candidate;
|
neighbor = candidate;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
nesting --;
|
||||||
|
}
|
||||||
|
if (neighbor_wire.wire_tunnel_directions & dirinfo.bit) {
|
||||||
|
nesting ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user