stable
This commit is contained in:
parent
fbdac9ebf1
commit
86226ccc94
97 changed files with 5790 additions and 2307 deletions
29
js/tarinai_update_policy.js
Normal file
29
js/tarinai_update_policy.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"use strict";
|
||||
|
||||
// Layer: entity-runtime/tarinai/policy
|
||||
// Owns Tarinai update cadence decisions. The simulation creature system asks
|
||||
// this policy when an individual should run at realtime vs low-frequency cadence.
|
||||
(function (global) {
|
||||
const helpers = () => global.TarinaiSimulationRuntime?.helpers || {};
|
||||
|
||||
function updateInterval(worldRef, tarinai, visibleRect) {
|
||||
if (!tarinai || tarinai.dead) return Infinity;
|
||||
if (worldRef.selected === tarinai) return 0;
|
||||
if ((tarinai.hurtTimer || 0) > 0.04 || (tarinai.pokeFlashTimer || 0) > 0.03 || (tarinai.entryTimer || 0) > 0.01) return 0;
|
||||
if (helpers().pointInRect?.(tarinai.x || 0, tarinai.y || 0, visibleRect)) return 0;
|
||||
const count = (worldRef.tarinai || []).length;
|
||||
const tier = global.TarinaiPerf?.renderQualityTier?.() || "high";
|
||||
if (tier === "high" && count <= 36) return 0;
|
||||
const farRect = helpers().updateVisibleWorldRect?.(worldRef, 520) || visibleRect;
|
||||
return helpers().pointInRect?.(tarinai.x || 0, tarinai.y || 0, farRect) ? 0.22 : 0.70;
|
||||
}
|
||||
|
||||
function shouldRunRealtime(worldRef, tarinai, visibleRect) {
|
||||
return updateInterval(worldRef, tarinai, visibleRect) <= 0;
|
||||
}
|
||||
|
||||
global.TarinaiCreatureUpdatePolicy = Object.freeze({
|
||||
updateInterval,
|
||||
shouldRunRealtime,
|
||||
});
|
||||
})(typeof window !== "undefined" ? window : globalThis);
|
||||
Loading…
Add table
Add a link
Reference in a new issue