Entities · class

BoundSystem

The view one system sees, reused across ticks.

Explained in Entities.

class BoundSystem implements SystemView
import { BoundSystem } from '@driftengine/entities';

In depth

One per system rather than one per run, because a system runs every tick for the life of a world and an object per tick per system is the allocation this package refuses everywhere else.

Constructor

new

constructor(world: World, definition: SystemDefinition)
ParameterTypeDescription
worldWorld
definitionSystemDefinition

Properties

NameTypeDescription
definitionreadonlySystemDefinition

Methods

run

run(): void

query

query(a: ComponentType, b?: ComponentType, c?: ComponentType, d?: ComponentType): QueryCursor
ParameterTypeDescription
aComponentType
b?ComponentType
c?ComponentType
d?ComponentType

view

view(type: ComponentType, forWriting: boolean): ComponentView

The live columns of a component, checked first.

ParameterTypeDescription
typeComponentType
forWritingboolean
More

This is the seam where one mistake disables every declaration in this file. Every other accessor here checks before it answers, and a view that went straight to the store would hand out the raw columns of a component this system never declared — after which reads and writes are reachable around rather than through, and nothing in the schedule derived from them means anything.

What this costs is that a caller must say in advance whether it will write, before it has written anything. What would make it wrong is a view narrow enough to enforce per field, which would be a second object per field and the allocation this package refuses.

read

read(entity: Entity, type: ComponentType, field: string): unknown
ParameterTypeDescription
entityEntity
typeComponentType
fieldstring

write

write(entity: Entity, type: ComponentType, field: string, value: unknown): void
ParameterTypeDescription
entityEntity
typeComponentType
fieldstring
valueunknown

has

has(entity: Entity, type: ComponentType): boolean
ParameterTypeDescription
entityEntity
typeComponentType

count

count(type: ComponentType): number
ParameterTypeDescription
typeComponentType

at

at(type: ComponentType, index: number): Entity
ParameterTypeDescription
typeComponentType
indexnumber

alive

alive(entity: Entity): boolean
ParameterTypeDescription
entityEntity

create

create(): Entity

add

add(entity: Entity, type: ComponentType, values?: Readonly<Record<string, unknown>>): void
ParameterTypeDescription
entityEntity
typeComponentType
values?Readonly<Record<string, unknown>>

destroy

destroy(entity: Entity): void
ParameterTypeDescription
entityEntity

remove

remove(entity: Entity, type: ComponentType): void
ParameterTypeDescription
entityEntity
typeComponentType