RemoveCommand

View source

ExtendsCommand

Represents a deferred request to remove component types from an entity.

Use this command to defer component removal until a world update is applied. Constructing it stores the entity handle and component constructors without changing the world. Calling RemoveCommand#execute later delegates to World#remove. A stale entity handle has no effect. If a requested component type is not present, storage is unchanged but its registered remove hook still runs.

Examples

const command = new RemoveCommand(entity, [Position2D, Velocity2D])
queue.add(command) // The queue applies the command later.

Constructor


constructor<T extends unknown[]>(entity: EntityHandle, components: TupleConstructor<T>)

View source

Creates a deferred command that removes component types from an entity.

The constructor stores its arguments; it does not call World#remove or change the world until RemoveCommand#execute runs.

Type Parameters

T extends unknown[]

Parameters

NameDescriptionDefault
entity

Entity whose components will be removed.

—
components

Component constructors to remove.

—

Properties


Methods