Skip to content

TriggerSystemOptions

Defined in: src/modules/collision/trigger.ts:14

Options for makeTriggerSystem. The system factory accepts a broadphase (which pairs to consider), an optional narrowphase (which pairs actually overlap), and a callback that fires on each confirmed overlap. Pair ordering is whatever the broadphase yields; the system never reorders or de-duplicates.

This is intentionally minimal — most of the work lives in the broadphase closure, which consumers tailor to their world (spatial index queries, tag iteration, one-vs-many checks, …).

TCtx

readonly broadphase: (ctx) => Iterable<readonly [EntityId, EntityId]>

Defined in: src/modules/collision/trigger.ts:27

Broadphase: yields the ordered pairs [a, b] to test this tick. Typical patterns: tagA × tagB, sourceId × spatialIndex.queryNear, or an exhaustive pairwise loop for tiny tag sets.

The generator should not emit the same pair twice unless the consumer intentionally wants the callback to fire twice.

TCtx

Iterable<readonly [EntityId, EntityId]>


readonly optional name?: string

Defined in: src/modules/collision/trigger.ts:15


readonly onOverlap: (ctx, a, b) => void

Defined in: src/modules/collision/trigger.ts:29

Fires once per confirmed overlap.

TCtx

EntityId

EntityId

void


readonly optional overlaps?: (ctx, a, b) => boolean

Defined in: src/modules/collision/trigger.ts:35

Narrowphase: returns true if the pair actually overlaps. Omit when the broadphase already performs an exact test (e.g. a grid cell lookup that only returns co-located entities).

TCtx

EntityId

EntityId

boolean


readonly optional phase?: string

Defined in: src/modules/collision/trigger.ts:16


readonly optional runAfter?: readonly string[]

Defined in: src/modules/collision/trigger.ts:17


readonly optional runBefore?: readonly string[]

Defined in: src/modules/collision/trigger.ts:18