Shared drag placement; drags snap one block to join a diagonal (t67 phases 3-4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 15:08:37 -04:00
co-authored by Claude Opus 5.5
parent c3f9387b24
commit 72efe85a1b
8 changed files with 97 additions and 20 deletions
+5 -9
View File
@@ -7,24 +7,20 @@ function slopeBeltConnections(bx, by, code, planned = null) {
const join = endJoin(bx, by, end, planned);
if (join < 0) continue;
const nb = join >> 1, next = planned && planned.get(nb);
const pcode = next ? next[0] : blockP[nb];
const slope = isSlopeBelt(pcode) && ((nb / BW) | 0) - by === beltGrade(code) * (nb % BW - bx);
const slope = isSlopeBelt(next ? next[0] : blockP[nb]) &&
((nb / BW) | 0) - by === beltGrade(code) * (nb % BW - bx);
// A same-row feed into a low end drops onto its face: drawn as two capped ends, still joined.
if (!slope && beltDrop(nb, by, beltGrade(code) * (end ? 1 : -1) > 0, pcode, join & 1)) continue;
if (!slope && joinIsDrop(bx, by, end, join, planned)) continue;
joins |= (slope ? 4 : 1) << end;
}
return joins;
}
// Does a same-row join between a piece in row `by` and block nb meet a slope's low end?
function beltDrop(nb, by, ownLow, pcode, pend) {
return ((nb / BW) | 0) === by && (ownLow || beltGrade(pcode) * (pend ? 1 : -1) > 0);
}
function flatBeltCaps(b, planned = null) {
const bx = b % BW, by = (b / BW) | 0;
let caps = 0;
for (let end = 0; end < 2; end++) {
const join = endJoin(bx, by, end, planned), nb = join >> 1, next = planned && planned.get(nb);
if (join < 0 || beltDrop(nb, by, false, next ? next[0] : blockP[nb], join & 1)) caps |= 1 << end;
const join = endJoin(bx, by, end, planned);
if (join < 0 || joinIsDrop(bx, by, end, join, planned)) caps |= 1 << end;
}
return caps;
}