Screw conveyors join across the corner to diagonals (t62)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -176,6 +176,20 @@ function screwIntake(i, p, dx, dy) {
|
||||
}
|
||||
}
|
||||
|
||||
// A straight mouth can feed a diagonal tail one block across the corner.
|
||||
function straightScrewNext(i, p) {
|
||||
const dx = SCREW_DX[p], dy = SCREW_DY[p], x = i % W, y = (i / W) | 0;
|
||||
const xx = x + dx, yy = y + dy, next = i + dx + dy * W;
|
||||
if (xx < 0 || yy < 0 || xx >= W || yy >= H) return -1;
|
||||
if (((xx >> 2) === (x >> 2) && (yy >> 2) === (y >> 2)) || part[next] || blockP[(yy >> 2) * BW + (xx >> 2)]) return next;
|
||||
for (let side = -1; side <= 1; side += 2) {
|
||||
const nx = xx + (dx ? 0 : side * BS), ny = yy + (dy ? 0 : side * BS);
|
||||
if (nx < 0 || ny < 0 || nx >= W || ny >= H) continue;
|
||||
const j = ny * W + nx, q = part[j];
|
||||
if (SCREW_DX[q] === (dx || side) && SCREW_DY[q] === (dy || side)) return j;
|
||||
}
|
||||
return next;
|
||||
}
|
||||
// Four lanes cross a block in four beats; the casing carries every lane across the corner.
|
||||
// Prefer the next diagonal block, then either straight join, then the open head.
|
||||
function diagonalScrewNext(i, p) {
|
||||
|
||||
@@ -90,6 +90,13 @@ function entScrewTick(e, p) {
|
||||
if ((tick & 1) || netSat(ci) <= 0 || rnd() > netSat(ci)) return;
|
||||
const dx = SCREW_DX[p], dy = SCREW_DY[p];
|
||||
if (dx && dy) { entDiagonalScrewTick(e, p); return; }
|
||||
const edge = entScrewEdge(e, dx, dy, 0), behind = edge - dx - dy * W;
|
||||
const corner = edge >= 0 ? straightScrewNext(behind, p) : -1;
|
||||
if (corner >= 0 && corner !== edge) {
|
||||
const x = (corner % W) & ~3, y = entScrewLane((corner / W) | 0, e.iy);
|
||||
if (entScrewMove(e, x, y, true)) stats.moved++;
|
||||
return;
|
||||
}
|
||||
let x = e.ix + dx, y = e.iy + dy, next = 0, ax = 0, ay = 0;
|
||||
for (let k = 0; k < (dx ? BAR_H : BAR_W); k++) {
|
||||
const i = entScrewEdge(e, dx, dy, k);
|
||||
|
||||
@@ -130,7 +130,7 @@ function machinesTick() {
|
||||
if (shifted) continue;
|
||||
}
|
||||
if (x + dx < 0 || x + dx >= W || y + dy < 0 || y + dy >= H) continue;
|
||||
const dest = dx && dy ? diagonalScrewNext(i, p) : i + dj;
|
||||
const dest = dx && dy ? diagonalScrewNext(i, p) : straightScrewNext(i, p);
|
||||
if (dest < 0) continue;
|
||||
const nx = dest % W, ny = (dest / W) | 0;
|
||||
if (nx < 0 || ny < 0 || nx >= W || ny >= H) continue;
|
||||
|
||||
Reference in New Issue
Block a user