stable
This commit is contained in:
parent
fbdac9ebf1
commit
86226ccc94
97 changed files with 5790 additions and 2307 deletions
39
js/tarinai_item_interaction_system.js
Normal file
39
js/tarinai_item_interaction_system.js
Normal 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);
|
||||
Loading…
Add table
Add a link
Reference in a new issue