@web-engine-dev/scheduler / RunCondition
Type Alias: RunCondition()<TContext>
RunCondition<
TContext> = (context) =>boolean
A run condition predicate that determines if a system should execute.
Return true to allow the system to run, false to skip it. Multiple conditions are ANDed together.
Type Parameters
TContext
TContext = unknown
Parameters
context
TContext
Returns
boolean
Example
typescript
interface GameContext {
isPaused: boolean;
debugMode: boolean;
}
// Skip system when game is paused
const notPaused: RunCondition<GameContext> = (ctx) => !ctx.isPaused;
// Only run in debug mode
const debugOnly: RunCondition<GameContext> = (ctx) => ctx.debugMode;
// Use with defineSystem
defineSystem('physics', physicsFn)
.runIf(notPaused)
.build();