-
Notifications
You must be signed in to change notification settings - Fork 1
Engine
runtoolkit edited this page Apr 13, 2026
·
1 revision
The Engine class bundles all subsystems into a single object. It also wires Queue, EventBus, and CommandSystem flush into the tick loop automatically.
import { Engine } from './src/index.js';
const engine = new Engine({ msPerTick: 50, debug: false });| Option | Type | Default | Description |
|---|---|---|---|
msPerTick |
number |
50 |
Milliseconds per tick (50 = 20 TPS) |
debug |
boolean |
false |
Enables debug logging on events, hooks, and logger |
| Property | Type | Description |
|---|---|---|
engine.tick |
TickLoop |
Tick pipeline |
engine.events |
EventBus |
Named event bus |
engine.hooks |
HookSystem |
Lifecycle hook system |
engine.cooldown |
Cooldown |
Cooldown tracker |
engine.scheduler |
Scheduler |
Delay / repeat / debounce / throttle |
engine.queue |
Queue |
FIFO function queue |
engine.fibers |
FiberManager |
Cooperative coroutines |
engine.batch |
Batch |
Atomic side-effect groups |
engine.state |
State |
Per-entity key-value store |
engine.flags |
FlagStore |
Per-entity boolean flags |
engine.config |
Config |
Global config store |
engine.rateLimit |
RateLimit |
Sliding window rate limiter |
engine.commands |
CommandSystem |
Safe command execution |
engine.log |
Logger |
Structured logger |
engine.start(); // starts the tick loop, returns true if started
engine.stop(); // stops the tick loop, returns true if stoppedWhen Engine starts, three channels are registered automatically on the tick loop:
| Channel | Action |
|---|---|
_queue |
Calls engine.queue.flush() every tick |
_events |
Calls engine.events.flushQueue() every tick |
_commands |
Calls engine.commands.flush() every tick |