Entity:despawn
Unregisters this entity from the ECS. The implications of despawning an entity are:
- Calling its is_valid method returns return
false. - Calling its add_component, remove_component or create_event method emits an error.
- The entity no longer appears in return values of any method from its ECS.
- After the next call to ECS:update, this entity will no longer be matched by any Query.
Note that there is no safeguard preventing you from holding references to entities after despawning them.
Attempting to despawn an entity multiple times will emit an error.
Usage
entity:despawn()
Examples
local ecs = crystal.ECS:new();
local entity = ecs:spawn(crystal.Entity);
entity:despawn();