2026-06-26 12:46:32 +09:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
// Layer: entity-runtime/items/pipeline
|
2026-06-26 19:04:32 +09:00
|
|
|
// Owns the ordered item lifecycle pipeline. There is no monolithic fallback path:
|
|
|
|
|
// every item update must be handled by the explicit lifecycle steps below.
|
2026-06-26 12:46:32 +09:00
|
|
|
(function (global) {
|
|
|
|
|
const CONCRETE_STEP_NAMES = Object.freeze([
|
|
|
|
|
"TarinaiItemFrameLifecycleStep",
|
|
|
|
|
"TarinaiItemDecayLifecycleStep",
|
|
|
|
|
"TarinaiItemDynamicLifecycleStep",
|
|
|
|
|
"TarinaiItemGrowthLifecycleStep",
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
function concreteSteps() {
|
|
|
|
|
return CONCRETE_STEP_NAMES.map(name => global[name]).filter(step => step && typeof step.update === "function");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function canRunConcretePipeline() {
|
|
|
|
|
return concreteSteps().length === CONCRETE_STEP_NAMES.length;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-26 19:04:32 +09:00
|
|
|
function updateOne(item, dt, worldRef, options = {}) {
|
|
|
|
|
if (!item || item.dead || !canRunConcretePipeline()) return false;
|
|
|
|
|
const context = options.context || {};
|
2026-06-26 12:46:32 +09:00
|
|
|
for (const step of concreteSteps()) {
|
|
|
|
|
const result = step.update(item, dt, worldRef, context) || {};
|
|
|
|
|
if (result.done) return result.ok !== false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
global.TarinaiItemLifecyclePipeline = Object.freeze({
|
|
|
|
|
stepNames: CONCRETE_STEP_NAMES,
|
|
|
|
|
canRunConcretePipeline,
|
|
|
|
|
updateOne,
|
|
|
|
|
});
|
|
|
|
|
})(typeof window !== "undefined" ? window : globalThis);
|