Description
What problem does this solve or what need does it fill?
For gameplay or performance reasons, it is common to want to temporarily disable entities.
While disabled, they should generally not be interacted with in any way.
What solution would you like?
Add a special Disabled
marker component. Entities with this component do not appear in any queries, unless the query contains With<Disabled>
(or otherwise explicitly requests that component).
I'm indifferent to either hard-coding a single type for this, or making this behavior an associated constant on the Component
type. The former is simpler, but the latter is end-user extensible and arguably more elegant.
What alternative(s) have you considered?
Respawning
We could save, despawn and then respawn the entities. However it is both simpler and faster to keep the entities alive but filter them from (most) queries.
Additionally, reading the data of despawned and stored entities is much more challenging.
Custom marker component
Users could add a Disabled
marker component of their own, and then add Without<Disabled>
to all of their systems.
However:
- This is a lot of boilerplate.
- There is no standard across the ecosystem.
- External systems will continue to operate on them.
Additional context
flecs has a Disabled
component and a Prefab
component that work in this fashion. It also has a Prefab
component which works in the same way.