23 lines
896 B
JavaScript
23 lines
896 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.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);
|