This commit is contained in:
33333-33333 2026-07-20 14:36:59 +09:00
commit f6d7412744
94 changed files with 3836 additions and 1226 deletions

View file

@ -107,7 +107,31 @@ const d = contact.distance;
}
function updateResidues(tarinai, dt) {
const worldRef = tarinai?.world;
if (!worldRef?.nearbyResidues) return false;
let touched = false;
for (const residue of worldRef.nearbyResidues(tarinai.x, tarinai.y, (tarinai.radius || 22) + 58) || []) {
if (!residue || residue.dead) continue;
const d = distXY(tarinai.x, tarinai.y, residue.x, residue.y);
if (residue.type === "splat") {
const touch = clamp(1 - d / ((tarinai.radius || 22) + (residue.r || 26) + 16), 0, 1);
if (touch > 0) {
applyNeedShock(tarinai, { safety: touch * dt * 5, health: touch * dt * 3 });
if (touch > 0.06) tarinai.adjustPersonality("neuroticism", -dt * touch * 0.0042, "after repeated contact with corpses");
touched = true;
}
} else if (residue.type === "trace" && d <= (tarinai.radius || 22) + (residue.r || 16) + 14) {
tarinai.loneliness -= dt * 0.25;
applyNeedShock(tarinai, { social: -dt * 1, safety: dt * 0.8 });
touched = true;
}
}
return touched;
}
global.TarinaiContactItemSystem = Object.freeze({
updateCandidate,
updateResidues,
});
})(typeof window !== "undefined" ? window : globalThis);