21 lines
896 B
JavaScript
21 lines
896 B
JavaScript
"use strict";
|
|
|
|
// Layer: entity-runtime/tarinai/update-step
|
|
// Owns low-frequency local environment effects around a Tarinai.
|
|
(function (global) {
|
|
function update(t, dt, context = {}) {
|
|
if (!t || t.dead) return { done: true };
|
|
t.envTimer += dt;
|
|
const urgentAi = Boolean(context.urgentAi);
|
|
const envInterval = 3.0 + stableUnit(t.familyKey || t.id, "env-phase") * 1.4;
|
|
if (t.envTimer >= envInterval && t.world.spendScheduledWork?.("env", urgentAi || t.world.selected === t) !== false) {
|
|
const envDt = Math.min(t.envTimer, 1.2);
|
|
t.envTimer = 0;
|
|
if (global.TarinaiLocalEnvironmentSystem?.updateOne) global.TarinaiLocalEnvironmentSystem.updateOne(t, envDt);
|
|
else t.applyEnvironment?.(envDt);
|
|
}
|
|
return { done: false };
|
|
}
|
|
|
|
global.TarinaiEnvironmentUpdateStep = Object.freeze({ update });
|
|
})(typeof window !== "undefined" ? window : globalThis);
|