Entities · interface

SystemView

Explained in Entities.

interface SystemView
import type { SystemView } from '@driftengine/entities';

Methods

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 against this system's declarations first.

ParameterTypeDescription
typeComponentType
forWritingboolean
More

forWriting decides which check: a caller that will only read takes a readable view, and one that will write takes a writable one. A compiler that can see the body supplies it; a caller writing this by hand says what it is about to do.

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

How many entities carry a component, and the one at an index among them; both reads, so both checked. A script's ecs.count and ecs.at reach these, and a view without them made each throw the moment a system called it.

ParameterTypeDescription
typeComponentType

at

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

alive

alive(entity: Entity): boolean

Whether a handle names a live entity. It asks nothing of any component, so nothing is checked; an entity this system destroyed is still alive until the system returns.

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

Deferred to after this system runs. See the header.

ParameterTypeDescription
entityEntity

remove

remove(entity: Entity, type: ComponentType): void

Deferred to after this system runs. See the header.

ParameterTypeDescription
entityEntity
typeComponentType