Entities · function

runSchedule

Run one fixed step of a schedule.

Explained in Entities.

function runSchedule(world: World, schedule: Schedule, tick: number, report?: SystemFailureReporter): void
import { runSchedule } from '@driftengine/entities';

Parameters

ParameterTypeDescription
worldWorld
scheduleSchedule
ticknumber
report?SystemFailureReporter

In depth

tick is the simulation's step count and is what everyTicks strides over — so a system at stride 60 runs on tick 0, 60, 120, in every replay of the same input.

A system that throws does not take the rest of the tick with it, since 2026-08-28. It used to: the throw left this function, so every system scheduled after the failing one never ran — once per tick, for as long as the game was up. Reported from outside, and the way it was found is the argument for containing it. A system queried a component it had not declared, which throws by design; the system that stopped was three places later and was the one stepping a vehicle; the symptom was a car moving in jerks, and the only evidence was a console line no headless check reads. A broken system must not be able to silently starve its neighbours.

So each system's failure is caught, reported once naming the system and the reason, and the schedule carries on. Nothing is disabled: a declaration error will throw again next tick and be caught again, which costs a throw per tick and keeps a transient failure recoverable — and this function no longer throws, which is what AGENTS.md requires of anything the frame loop calls.

What it gives up is the stack reaching a debugger's uncaught-exception break, which is how somebody working on a system would rather meet it. So report takes the decision back: given one, every failure goes to it, every tick it happens, with the system's name, the tick and the error as thrown, and nothing is logged. A game can count failures, show them in a debug overlay, send them to its own telemetry, or throw from it to make a failure fatal in development, which stops the schedule there. Without one, the failure is said once per system per world, as above.