Skip to content

Scheduler

Defined in: src/scheduler.ts:167

The starting point of a game made with Toucan.

run(): this

Defined in: src/scheduler.ts:230

Synchronously builds all initially registered plugins (user-defined first), and then bootstraps the engine to run all systems on their respective phases.

Systems and plugins scheduled dynamically after the scheduler is already running will be picked up automatically on the next frame (with the exception of the STARTUP phase, which only fires once during this method call).

this


usePlugin<Args>(plugin, …args): this

Defined in: src/scheduler.ts:217

Schedules a plugin to be built, passing it the scheduler itself and the provided arguments.

Plugins are entities with the standard Plugin component, thus, they can be queried and manipulated like any other entity in Toucan.

Plugins scheduled within other plugins are automatically parented to the parent plugin.

Args extends defined[]

Plugin<Args>

Args

this

function updatePhysics(gravity: number) { ... }
function physicsPlugin(scheduler: Scheduler, gravity: number) {
scheduler.useSystem(updatePhysics, UPDATE, gravity)
}
scheduler()
.usePlugin(physicsPlugin, 196.2)
.run()

useSystem<Args>(system, phase, args?, label?): this

Defined in: src/scheduler.ts:187

Schedules a system to run in the specified phase with the provided arguments.

Systems are entities with the standard System component, thus, they can be queried and manipulated like any other entity in Toucan.

Systems scheduled within plugins are automatically parented to the plugin.

Args extends defined[]

System<Args>

Phase

Args

string

this

function fireGun(params: RaycastParams) { ... }
scheduler()
.addSystems(UPDATE, [fireGun], new RaycastParams())
.run()