This commit is contained in:
33333-33333 2026-07-01 14:41:05 +09:00
commit 4d3fc2cd47
84 changed files with 3429 additions and 3480 deletions

View file

@ -322,31 +322,15 @@ function findNearbyMaterial(world, tarinai, materialRole, maxDist = 520) {
}
function findOwnedStructure(world, tarinai, type = "", maxDist = Infinity) {
let best = null, bestD = maxDist;
for (const item of world?.items || []) {
if (!item?.isStructure || item.dead || item.ownerId !== tarinai.id) continue;
if (Number(item.unreachableUntil || 0) > Number(world?.time || 0)) continue;
if (type && item.type !== type) continue;
if (tarinaiTargetBlockedByObstacle(world, tarinai, item, "structure")) continue;
const d = dist(tarinai, item);
if (d < bestD) { best = item; bestD = d; }
}
return best;
return globalThis.TarinaiNestSleepSystem.findOwnedStructure(world, tarinai, type, maxDist, {
blocked: (worldRef, actor, item) => tarinaiTargetBlockedByObstacle(worldRef, actor, item, "structure"),
}) || null;
}
function findUnownedStructure(world, tarinai, type = "", maxDist = Infinity) {
let best = null, bestD = maxDist;
for (const item of world?.items || []) {
if (!item?.isStructure || item.dead || item.ownerId) continue;
if (item.abandonedById && item.abandonedById === tarinai?.id && Number(item.abandonedUntil || 0) > Number(world?.time || 0)) continue;
if (Number(item.unreachableUntil || 0) > Number(world?.time || 0)) continue;
if (type && item.type !== type) continue;
if (tarinai?.shouldAvoidTarget?.(item)) continue;
if (tarinaiTargetBlockedByObstacle(world, tarinai, item, "structure")) continue;
const d = dist(tarinai, item);
if (d < bestD) { best = item; bestD = d; }
}
return best;
return globalThis.TarinaiNestSleepSystem.findUnownedStructure(world, tarinai, type, maxDist, {
blocked: (worldRef, actor, item) => tarinaiTargetBlockedByObstacle(worldRef, actor, item, "structure"),
}) || null;
}
function consumeGrassMaterial(material, stages = 1) {
@ -364,4 +348,3 @@ function moveToOrUse(t, target, state = "seek_food", reason = "") {
t.setActionState?.(state, { target, reason, sleeping: false });
return true;
}