Skip to content

Kiln API / kiln / Commands

Class: Commands ​

Deferred structural changes. They apply at the end of the current phase, in order.

Constructors ​

Constructor ​

ts
new Commands(queue): Commands;

Parameters ​

ParameterType
queueCommandQueue

Returns ​

Commands

Methods ​

spawn() ​

Call Signature ​

ts
spawn<P>(prefab, ...params): PendingEntity;

Queues a spawn from a prefab: commands.spawn(Enemy, { at }).

Type Parameters ​
Type Parameter
P
Parameters ​
ParameterType
prefabPrefab<P>
...paramsP extends void ? [] : [P]
Returns ​

PendingEntity

Call Signature ​

ts
spawn(...traits): PendingEntity;

Queues a spawn from a trait list: commands.spawn(Transform({ x: 1 }), Velocity).

Parameters ​
ParameterType
...traitsConfigurableTrait[]
Returns ​

PendingEntity


despawn() ​

ts
despawn(entity): void;

Queues a despawn. Despawning twice, or an entity that is already gone, is a no-op.

Parameters ​

ParameterType
entityEntityRef

Returns ​

void


add() ​

ts
add(entity, ...traits): void;

Queues adding traits (or relation pairs) to an entity.

Parameters ​

ParameterType
entityEntityRef
...traitsConfigurableTrait[]

Returns ​

void


remove() ​

ts
remove(entity, ...traits): void;

Queues removing traits (or relation pairs) from an entity.

Parameters ​

ParameterType
entityEntityRef
...traits(Trait | RelationPair)[]

Returns ​

void


run() ​

ts
run(fn): void;

Queues an arbitrary world mutation, applied in order with the others.

Parameters ​

ParameterType
fn(world) => void

Returns ​

void