Appearance
Class: Commands
Deferred structural changes. They apply at the end of the current phase, in order.
Constructors
Constructor
ts
new Commands(queue): Commands;Parameters
| Parameter | Type |
|---|---|
queue | CommandQueue |
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
| Parameter | Type |
|---|---|
prefab | Prefab<P> |
...params | P extends void ? [] : [P] |
Returns
Call Signature
ts
spawn(...traits): PendingEntity;Queues a spawn from a trait list: commands.spawn(Transform({ x: 1 }), Velocity).
Parameters
| Parameter | Type |
|---|---|
...traits | ConfigurableTrait[] |
Returns
despawn()
ts
despawn(entity): void;Queues a despawn. Despawning twice, or an entity that is already gone, is a no-op.
Parameters
| Parameter | Type |
|---|---|
entity | EntityRef |
Returns
void
add()
ts
add(entity, ...traits): void;Queues adding traits (or relation pairs) to an entity.
Parameters
| Parameter | Type |
|---|---|
entity | EntityRef |
...traits | ConfigurableTrait[] |
Returns
void
remove()
ts
remove(entity, ...traits): void;Queues removing traits (or relation pairs) from an entity.
Parameters
| Parameter | Type |
|---|---|
entity | EntityRef |
...traits | (Trait | RelationPair)[] |
Returns
void
run()
ts
run(fn): void;Queues an arbitrary world mutation, applied in order with the others.
Parameters
| Parameter | Type |
|---|---|
fn | (world) => void |
Returns
void