removed unused processesseessess
This commit is contained in:
parent
348f355eb2
commit
4fdc567e08
158 changed files with 1317 additions and 3351 deletions
|
|
@ -3,47 +3,19 @@
|
|||
// Layer: simulation/helpers
|
||||
// Shared, UI-free helpers used by the concrete simulation systems.
|
||||
(function (global) {
|
||||
const policy = () => global.TarinaiItemUpdatePolicy || {};
|
||||
const policy = global.TarinaiItemUpdatePolicy;
|
||||
|
||||
function forScheduledItems(worldRef, visitor) {
|
||||
if (policy().forScheduledItems) return policy().forScheduledItems(worldRef, visitor);
|
||||
if (!worldRef || typeof visitor !== "function") return 0;
|
||||
let count = 0;
|
||||
for (const it of worldRef.items || []) {
|
||||
if (!it || it.dead || it.type === "grass") continue;
|
||||
visitor(it);
|
||||
count += 1;
|
||||
}
|
||||
return count;
|
||||
return policy.forScheduledItems(worldRef, visitor);
|
||||
}
|
||||
|
||||
function itemUpdateInterval(item) {
|
||||
const interval = policy().itemUpdateInterval?.(item);
|
||||
const interval = policy.itemUpdateInterval(item);
|
||||
return Number.isFinite(interval) ? interval : Infinity;
|
||||
}
|
||||
|
||||
function updateItemsScheduled(worldRef, dt) {
|
||||
if (global.TarinaiItemRuntime?.updateScheduled) return global.TarinaiItemRuntime.updateScheduled(worldRef, dt);
|
||||
if (global.TarinaiItemUpdateScheduler?.run) return global.TarinaiItemUpdateScheduler.run(worldRef, dt);
|
||||
let ran = 0;
|
||||
forScheduledItems(worldRef, (it) => {
|
||||
const interval = itemUpdateInterval(it);
|
||||
if (!Number.isFinite(interval)) return;
|
||||
if (interval <= 0) {
|
||||
if (global.TarinaiItemRuntime?.updateOne) global.TarinaiItemRuntime.updateOne(it, dt, worldRef);
|
||||
else it.update?.(dt, worldRef);
|
||||
ran += 1;
|
||||
return;
|
||||
}
|
||||
it._scheduledUpdateDt = Math.min(10, (it._scheduledUpdateDt || 0) + dt);
|
||||
if (it._scheduledUpdateDt < interval) return;
|
||||
const scheduledDt = it._scheduledUpdateDt;
|
||||
it._scheduledUpdateDt = 0;
|
||||
if (global.TarinaiItemRuntime?.updateOne) global.TarinaiItemRuntime.updateOne(it, scheduledDt, worldRef);
|
||||
else it.update?.(scheduledDt, worldRef);
|
||||
ran += 1;
|
||||
});
|
||||
return ran;
|
||||
return global.TarinaiItemRuntime.updateScheduled(worldRef, dt);
|
||||
}
|
||||
|
||||
function markSpatialDirtyIfMoved(worldRef, list, reason = "moved", threshold = 0.35) {
|
||||
|
|
@ -77,7 +49,7 @@
|
|||
if (!worldRef) return false;
|
||||
const thresholdSq = threshold * threshold;
|
||||
let moved = false;
|
||||
const tracked = global.TarinaiItemRuntime?.trackedDynamicItems?.(worldRef) || global.TarinaiItemUpdateScheduler?.trackedDynamicItems?.(worldRef);
|
||||
const tracked = global.TarinaiItemRuntime.trackedDynamicItems(worldRef);
|
||||
const source = tracked && tracked.length ? tracked : null;
|
||||
const visit = (entity) => {
|
||||
const x = Number.isFinite(entity.x) ? entity.x : 0;
|
||||
|
|
@ -120,8 +92,6 @@
|
|||
}
|
||||
|
||||
const helpers = Object.freeze({
|
||||
forScheduledItems,
|
||||
itemUpdateInterval,
|
||||
updateItemsScheduled,
|
||||
markSpatialDirtyIfMoved,
|
||||
markScheduledItemsMoved,
|
||||
|
|
@ -130,11 +100,6 @@
|
|||
});
|
||||
|
||||
global.TarinaiSimulationRuntime = Object.freeze({
|
||||
helpers,
|
||||
constants: Object.freeze({
|
||||
get REALTIME_ITEM_TYPES() { return policy().REALTIME_ITEM_TYPES || new Set(); },
|
||||
get PIN_ITEM_TYPES() { return policy().PIN_ITEM_TYPES || new Set(); },
|
||||
get SCHEDULED_ITEM_TYPES() { return policy().SCHEDULED_ITEM_TYPES || Object.freeze([]); },
|
||||
}),
|
||||
helpers
|
||||
});
|
||||
})(typeof window !== "undefined" ? window : globalThis);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue