"use strict"; // Layer: entity-runtime/items/dynamic-system // Owns dynamic tool behavior for rotator, reciprocator, firecracker, genkotsu, // links, and static gate-fence ticking. Item.prototype methods delegate here for // direct Item.prototype calls; lifecycle dispatch also calls this boundary directly. (function (global) { function support() { return global.TarinaiItemLifecycleRuntimeSupport || {}; } function updateFirecracker(item, dt, worldRef) { item.fuseTimer = Math.max(0, (item.fuseTimer ?? 5) - dt); if (item.fuseTimer <= 0) { if (worldRef?.explodeFirecracker) worldRef.explodeFirecracker(item); else item.amount = 0; } } function updateGenkotsu(item, dt) { item.impactFlash = Math.max(0, (item.impactFlash || 0) - dt); if (item.dropImpactDone) { item.lingerTimer = Math.max(0, (item.lingerTimer || 0) - dt); if ((item.lingerTimer || 0) <= 0) item.amount = 0; } else { item.amount = Math.max(item.amount || 0, 100); } } function updateRotator(item, dt, worldRef) { return Boolean(global.TarinaiMechanicalSystem?.updateRotator?.(item, dt, worldRef)); } function updateReciprocator(item, dt, worldRef) { return Boolean(global.TarinaiMechanicalSystem?.updateReciprocator?.(item, dt, worldRef)); } function resolveMechanicalInteractions(item, dt, worldRef) { return Boolean(global.TarinaiMechanicalSystem?.resolveInteractions?.(item, dt, worldRef)); } function updateFlexibleLink(item, dt, worldRef) { return Boolean(global.TarinaiConstraintSystem?.updateFlexibleLink?.(item, dt, worldRef)); } function updateRigidLink(item, dt, worldRef) { return Boolean(global.TarinaiConstraintSystem?.updateRigidLink?.(item, dt, worldRef)); } function updateGateFence(item) { if (item) item.amount = 999; return Boolean(item); } function update(item, dt, worldRef) { if (!item || item.dead) return false; if (item.type === "firecracker") return updateFirecracker(item, dt, worldRef); if (item.type === "genkotsu") return updateGenkotsu(item, dt, worldRef); if (item.type === "rotator") return updateRotator(item, dt, worldRef); if (item.type === "reciprocator") return updateReciprocator(item, dt, worldRef); if (item.type === "gate_fence") return updateGateFence(item, dt, worldRef); if (item.type === "rope") return updateFlexibleLink(item, dt, worldRef); if (item.type === "rod") return updateRigidLink(item, dt, worldRef); return false; } global.TarinaiItemDynamicToolSystem = Object.freeze({ update, updateFirecracker, updateGenkotsu, updateRotator, updateReciprocator, updateFlexibleLink, updateRigidLink, resolveMechanicalInteractions, updateGateFence, }); })(typeof window !== "undefined" ? window : globalThis);