37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
"use strict";
|
|
|
|
// Layer: entity-runtime/items
|
|
// Owns the public item update boundary. Item.prototype.update routes directly
|
|
// through the explicit lifecycle pipeline.
|
|
(function (global) {
|
|
function installPrototypeBoundary() {
|
|
const proto = global.Item.prototype;
|
|
if (proto._tarinaiItemRuntimeInstalled) return false;
|
|
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) {
|
|
if (!item || item.dead) return false;
|
|
return global.TarinaiItemLifecyclePipeline.updateOne(item, dt, worldRef) !== false;
|
|
}
|
|
|
|
function updateScheduled(worldRef, dt) {
|
|
return global.TarinaiItemUpdateScheduler.run(worldRef, dt);
|
|
}
|
|
|
|
function trackedDynamicItems(worldRef) {
|
|
return global.TarinaiItemUpdateScheduler.trackedDynamicItems(worldRef);
|
|
}
|
|
|
|
const api = Object.freeze({ updateOne, updateScheduled, trackedDynamicItems });
|
|
global.TarinaiItemRuntime = api;
|
|
installPrototypeBoundary();
|
|
})(typeof window !== "undefined" ? window : globalThis);
|