DespawnCommand

View source

ExtendsCommand

Builds a deferred request to remove one entity from a world.

The command stores the target handle without looking it up or changing the world. DespawnCommand#execute delegates to World#despawn, which removes the target entity and all of its components. A stale handle has no effect. When hierarchy hooks are installed, removing an entity with a Children component also recursively removes its descendants.

Examples

const command = new DespawnCommand(entity)
command.execute(world)

Constructor


constructor(entity: EntityHandle)

View source

Creates a deferred entity-removal command.

The constructor stores the handle only. It does not look up or remove the entity until DespawnCommand#execute runs.

Parameters

NameDescriptionDefault
entity

Entity to remove from the world.

—

Properties


Methods


execute(world: World): void

View source

Applies the queued removal to a world.

Delegates to World#despawn with this command’s DespawnCommand#entity payload. A stale handle is ignored by the world.

Parameters

NameDescriptionDefault
world

World to mutate.

—