2026-06-26 12:46:32 +09:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
// Layer: entity-runtime/tarinai/pipeline
|
2026-06-26 19:04:32 +09:00
|
|
|
// Owns the ordered Tarinai update pipeline. There is no monolithic fallback path:
|
|
|
|
|
// creature behavior must be handled by the explicit update steps below.
|
2026-06-26 12:46:32 +09:00
|
|
|
(function (global) {
|
|
|
|
|
const CONCRETE_STEP_NAMES = Object.freeze([
|
|
|
|
|
"TarinaiFrameUpdateStep",
|
|
|
|
|
"TarinaiAiUpdateStep",
|
|
|
|
|
"TarinaiEnvironmentUpdateStep",
|
|
|
|
|
"TarinaiMovementUpdateStep",
|
|
|
|
|
"TarinaiHealthUpdateStep",
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
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(tarinai, dt, options = {}) {
|
|
|
|
|
if (!tarinai || tarinai.dead || !canRunConcretePipeline()) return false;
|
|
|
|
|
const context = {
|
|
|
|
|
...(options.context || {}),
|
|
|
|
|
wasSleepingAtFrameStart: false,
|
|
|
|
|
};
|
2026-06-26 12:46:32 +09:00
|
|
|
for (const step of concreteSteps()) {
|
|
|
|
|
const result = step.update(tarinai, dt, context) || {};
|
|
|
|
|
if (result.done) return result.ok !== false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
global.TarinaiUpdatePipeline = Object.freeze({
|
|
|
|
|
stepNames: CONCRETE_STEP_NAMES,
|
|
|
|
|
canRunConcretePipeline,
|
|
|
|
|
updateOne,
|
|
|
|
|
});
|
|
|
|
|
})(typeof window !== "undefined" ? window : globalThis);
|