stable
This commit is contained in:
parent
fbdac9ebf1
commit
86226ccc94
97 changed files with 5790 additions and 2307 deletions
61
js/tarinai_runtime.js
Normal file
61
js/tarinai_runtime.js
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
"use strict";
|
||||
|
||||
// Layer: entity-runtime/tarinai
|
||||
// Owns the public Tarinai update boundary. Tarinai.prototype.update remains a
|
||||
// compatibility facade; concrete behavior now routes through TarinaiUpdatePipeline
|
||||
// when available, with the captured legacy update kept as a fallback.
|
||||
(function (global) {
|
||||
let legacyUpdate = null;
|
||||
|
||||
function preferredLegacyUpdate(proto) {
|
||||
const systemLegacy = global.TarinaiLegacyUpdateSystem?.updateWithThis;
|
||||
if (typeof systemLegacy === "function") return systemLegacy;
|
||||
return proto?.update || legacyUpdate;
|
||||
}
|
||||
|
||||
function installPrototypeBoundary() {
|
||||
const proto = global.Tarinai?.prototype;
|
||||
if (!proto || proto._tarinaiCreatureRuntimeInstalled) return false;
|
||||
legacyUpdate = preferredLegacyUpdate(proto);
|
||||
if (typeof legacyUpdate === "function" && !proto._tarinaiLegacyUpdate) {
|
||||
Object.defineProperty(proto, "_tarinaiLegacyUpdate", {
|
||||
value: legacyUpdate,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
proto.update = function update(dt) {
|
||||
return global.TarinaiCreatureRuntime.updateOne(this, dt);
|
||||
};
|
||||
Object.defineProperty(proto, "_tarinaiCreatureRuntimeInstalled", {
|
||||
value: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
function updateOne(tarinai, dt) {
|
||||
const fn = tarinai?._tarinaiLegacyUpdate || legacyUpdate || global.TarinaiLegacyUpdateSystem?.updateWithThis;
|
||||
if (!tarinai || tarinai.dead || typeof fn !== "function") return false;
|
||||
if (global.TarinaiUpdatePipeline?.updateOne) {
|
||||
return global.TarinaiUpdatePipeline.updateOne(tarinai, dt, { legacyUpdate: fn }) !== false;
|
||||
}
|
||||
fn.call(tarinai, dt);
|
||||
return true;
|
||||
}
|
||||
|
||||
function updateBatch(tarinaiList, dt) {
|
||||
if (!Array.isArray(tarinaiList)) return 0;
|
||||
let ran = 0;
|
||||
for (const t of tarinaiList) if (updateOne(t, dt)) ran += 1;
|
||||
return ran;
|
||||
}
|
||||
|
||||
global.TarinaiCreatureRuntime = Object.freeze({
|
||||
installPrototypeBoundary,
|
||||
updateOne,
|
||||
updateBatch,
|
||||
});
|
||||
installPrototypeBoundary();
|
||||
})(typeof window !== "undefined" ? window : globalThis);
|
||||
Loading…
Add table
Add a link
Reference in a new issue