tarinai/js/item_lifecycle_step_frame.js
2026-07-11 21:13:39 +09:00

24 lines
996 B
JavaScript

"use strict";
// Layer: entity-runtime/items/lifecycle-step
// Owns per-item frame bookkeeping that is common across item types: age,
// zunchi spawn grace, and delayed drop impact handling.
(function (global) {
function update(item, dt, worldRef) {
if (!item || item.dead) return { done: true };
item.age += dt;
if (item.type === "zunchi") item.spawnGrace = Math.max(0, (item.spawnGrace || 0) - dt);
if (item.type === "toilet") item.toiletFlash = Math.max(0, (item.toiletFlash || 0) - dt * 1.8);
if (item.dropTimer > 0) {
const beforeDrop = item.dropTimer;
item.dropTimer = Math.max(0, item.dropTimer - dt);
if (beforeDrop > 0 && item.dropTimer <= 0 && !item.dropImpactDone) {
item.dropImpactDone = true;
if (worldRef?.itemDropImpact) worldRef.itemDropImpact(item);
}
}
return { done: false };
}
global.TarinaiItemFrameLifecycleStep = Object.freeze({ update });
})(typeof window !== "undefined" ? window : globalThis);