tarinai/js/item_runtime.js

37 lines
1.2 KiB
JavaScript
Raw Normal View History

2026-06-26 12:46:32 +09:00
"use strict";
// Layer: entity-runtime/items
2026-06-26 19:04:32 +09:00
// Owns the public item update boundary. Item.prototype.update routes directly
// through the explicit lifecycle pipeline.
2026-06-26 12:46:32 +09:00
(function (global) {
function installPrototypeBoundary() {
2026-06-29 16:21:58 +09:00
const proto = global.Item.prototype;
if (proto._tarinaiItemRuntimeInstalled) return false;
2026-06-26 12:46:32 +09:00
proto.update = function update(dt, worldRef = global.world) {
return global.TarinaiItemRuntime.updateOne(this, dt, worldRef);
};
Object.defineProperty(proto, "_tarinaiItemRuntimeInstalled", {
value: true,
configurable: true,
writable: true,
});
return true;
}
function updateOne(item, dt, worldRef = global.world) {
2026-06-29 16:21:58 +09:00
if (!item || item.dead) return false;
2026-06-26 19:04:32 +09:00
return global.TarinaiItemLifecyclePipeline.updateOne(item, dt, worldRef) !== false;
2026-06-26 12:46:32 +09:00
}
function updateScheduled(worldRef, dt) {
2026-06-29 16:21:58 +09:00
return global.TarinaiItemUpdateScheduler.run(worldRef, dt);
2026-06-26 12:46:32 +09:00
}
function trackedDynamicItems(worldRef) {
2026-06-29 16:21:58 +09:00
return global.TarinaiItemUpdateScheduler.trackedDynamicItems(worldRef);
2026-06-26 12:46:32 +09:00
}
2026-06-29 16:21:58 +09:00
const api = Object.freeze({ updateOne, updateScheduled, trackedDynamicItems });
2026-06-26 12:46:32 +09:00
global.TarinaiItemRuntime = api;
installPrototypeBoundary();
})(typeof window !== "undefined" ? window : globalThis);