This commit is contained in:
33333-33333 2026-06-26 12:46:32 +09:00
commit 86226ccc94
97 changed files with 5790 additions and 2307 deletions

View file

@ -0,0 +1,39 @@
"use strict";
// Tarinai item interaction system.
// Orchestrates food/medicine consumption and non-eating item contact effects.
// The candidate loop intentionally preserves the legacy order: for each nearby
// candidate, try eating first; if nothing was consumed, apply contact effects
// for that same candidate before advancing to the next one.
(function (global) {
function interactWithItems(dt = 0) {
const ctx = global.TarinaiItemInteractionContext?.create?.(this, dt);
if (!ctx) return false;
for (const item of ctx.foodCandidates || []) {
const consumed = Boolean(global.TarinaiFoodInteractionSystem?.updateCandidate?.(this, ctx, item, dt));
if (consumed) {
global.TarinaiItemInteractionContext?.finalize?.(this);
return true;
}
global.TarinaiContactItemSystem?.updateCandidate?.(this, ctx, item, dt);
}
global.TarinaiItemInteractionContext?.finalize?.(this);
return true;
}
function updateOne(tarinai, dt = 0) {
if (!tarinai || tarinai.dead) return false;
return interactWithItems.call(tarinai, dt);
}
function updateWithThis(dt = 0) {
return updateOne(this, dt);
}
global.TarinaiItemInteractionSystem = Object.freeze({
interactWithItems,
updateOne,
updateWithThis,
});
})(typeof window !== "undefined" ? window : globalThis);