p
This commit is contained in:
parent
d14550dad6
commit
63e10af865
86 changed files with 5400 additions and 1209 deletions
|
|
@ -111,8 +111,11 @@
|
|||
function runRealtime(worldRef, state, dt) {
|
||||
let ran = 0;
|
||||
const now = worldRef.time || 0;
|
||||
const nextRealtime = [];
|
||||
for (const item of state.realtime || []) {
|
||||
const realtime = state.realtime || [];
|
||||
let write = 0;
|
||||
const len = realtime.length;
|
||||
for (let i = 0; i < len; i += 1) {
|
||||
const item = realtime[i];
|
||||
if (!item || item.dead) continue;
|
||||
const interval = itemUpdateInterval(item);
|
||||
if (!Number.isFinite(interval)) {
|
||||
|
|
@ -123,13 +126,14 @@
|
|||
item._schedulerLastAt = now;
|
||||
ran += 1;
|
||||
const nextInterval = itemUpdateInterval(item);
|
||||
if (Number.isFinite(nextInterval) && nextInterval <= 0) nextRealtime.push(item);
|
||||
if (Number.isFinite(nextInterval) && nextInterval <= 0) realtime[write++] = item;
|
||||
else scheduleItem(state, item, now, nextInterval);
|
||||
} else {
|
||||
scheduleItem(state, item, now, interval);
|
||||
}
|
||||
}
|
||||
state.realtime = nextRealtime;
|
||||
realtime.length = write;
|
||||
state.realtime = realtime;
|
||||
worldRef._itemUpdateRealtime = state.realtime;
|
||||
return ran;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue