Build range follows the screen; out-of-range replace ghosts replace (t64)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
// Tool helpers: reach, brushes, and plain digging.
|
||||
// ---------- Tools ----------
|
||||
// Building reaches about as far as the screen shows (t64): the view box the UI sets each frame
|
||||
// (setBuildRange), at least REACH from its centre and at most BUILD_MAX; anything beyond becomes
|
||||
// a blueprint ghost. With no view (tests, headless), a REACH box around the bot.
|
||||
const BUILD_MAX = 200;
|
||||
let buildBox = null;
|
||||
function setBuildRange(cx, cy, w, h) {
|
||||
const hw = Math.max(REACH, Math.min(BUILD_MAX, w / 2)), hh = Math.max(REACH, Math.min(BUILD_MAX, h / 2));
|
||||
if (!buildBox) buildBox = { cx, cy, hw, hh }; else { buildBox.cx = cx; buildBox.cy = cy; buildBox.hw = hw; buildBox.hh = hh; }
|
||||
}
|
||||
function inBuildRange(x, y) {
|
||||
if (!buildBox) { const dx = x - (bot.x + bot.w / 2), dy = y - (bot.y + bot.h / 2); return Math.abs(dx) <= REACH && Math.abs(dy) <= REACH; }
|
||||
return Math.abs(x - buildBox.cx) <= buildBox.hw && Math.abs(y - buildBox.cy) <= buildBox.hh;
|
||||
}
|
||||
function inReach(x, y) { const dx = x - (bot.x + bot.w / 2), dy = y - (bot.y + bot.h / 2); return dx * dx + dy * dy <= REACH * REACH; }
|
||||
function forBrush(cx, cy, r, fn) {
|
||||
const r2 = (r + 0.5) * (r + 0.5);
|
||||
|
||||
Reference in New Issue
Block a user