This commit is contained in:
33333-33333 2026-07-18 22:15:26 +09:00
commit d163ceb291
76 changed files with 1385 additions and 524 deletions

View file

@ -398,10 +398,7 @@
nestBoxCapacity(box = null) {
if (box?.type === "pipe") {
const count = (this.items || []).reduce((n, it) => n + (it && !it.dead && it.type === "pipe" ? 1 : 0), 0);
return Math.max(3, count * 3);
}
if (box?.type === "pipe") return 3;
return 5;
},
@ -839,7 +836,7 @@
}
if (now >= (t.lastBounceFenceEffectAt || -999) + 0.08) {
t.lastBounceFenceEffectAt = now;
this.effects?.push(new Effect("ring", t.x, t.y, { size: Math.max(18, rr * 1.15), life: 0.18, color: "rgba(82,153,230,0.46)" }));
this.queueEffect?.("ring", t.x, t.y, { size: Math.max(18, rr * 1.15), life: 0.18, color: "rgba(82,153,230,0.46)" });
}
} else if (r.mechanical && opts.pressureCheap) {
const omega = r.rotator ? clamp(Number(r.angularVelocity || 0) || 0, -4.5, 4.5) : 0;
@ -1034,15 +1031,24 @@
const cy = (y1 + y2) / 2;
const maxD = Math.hypot(x2 - x1, y2 - y1) / 2 + 120;
const exclude = opts?.exclude || null;
const seenNestBoxes = new Set();
for (const rect of this.nearbySolidObstacleRects(cx, cy, maxD + padding + 170, { exclude })) {
if (exclude && rect?.item === exclude) continue;
if (!this.isFenceRoutingRect?.(rect)) continue;
if (rect?.oneWay && this.oneWayFenceAllowsPath?.(x1, y1, x2, y2, rect)) continue;
if (rect?.oriented) {
const r = { ...rect, halfW: (rect.halfW || 0) + padding, halfH: (rect.halfH || 0) + padding };
let routingRect = rect;
const routingItem = rect?.item || null;
if (routingItem?.type === "nest_box") {
const key = routingItem.id || routingItem;
if (seenNestBoxes.has(key)) continue;
seenNestBoxes.add(key);
routingRect = this.nestBoxBaseRect?.(routingItem) || rect;
}
if (routingRect?.oneWay && this.oneWayFenceAllowsPath?.(x1, y1, x2, y2, routingRect)) continue;
if (routingRect?.oriented) {
const r = { ...routingRect, halfW: (routingRect.halfW || 0) + padding, halfH: (routingRect.halfH || 0) + padding };
if (this.segmentIntersectsRect(x1, y1, x2, y2, r)) return true;
} else {
const r = { left: rect.left - padding, right: rect.right + padding, top: rect.top - padding, bottom: rect.bottom + padding };
const r = { left: routingRect.left - padding, right: routingRect.right + padding, top: routingRect.top - padding, bottom: routingRect.bottom + padding };
if (this.segmentIntersectsRect(x1, y1, x2, y2, r)) return true;
}
}
@ -1058,12 +1064,21 @@
pointBlockedByObstacle(x, y, padding = 14, opts = {}) {
const exclude = opts?.exclude || null;
const searchRadius = Math.max(48, Number(padding || 0) + 72);
const seenNestBoxes = new Set();
for (const rect of this.nearbySolidObstacleRects?.(x, y, searchRadius, { exclude, maxChecks: Math.max(10, Number(opts.maxChecks || 0) || 24) }) || []) {
if (exclude && rect?.item === exclude) continue;
// Directional pathfinding evaluates one-way fences on edges, not as
// permanently blocked grid points. Other callers retain solid occupancy.
if (rect?.oneWay && opts?.directionalOneWay === true) continue;
if (this.pointInRect?.(x, y, rect, padding)) return true;
let routingRect = rect;
const routingItem = rect?.item || null;
if (routingItem?.type === "nest_box") {
const key = routingItem.id || routingItem;
if (seenNestBoxes.has(key)) continue;
seenNestBoxes.add(key);
routingRect = this.nestBoxBaseRect?.(routingItem) || rect;
}
if (this.pointInRect?.(x, y, routingRect, padding)) return true;
}
return false;
},