![]() |
ImagoEngine
A C++ 2D game engine built on a sparse-set ECS, with scenes, scheduled systems, events, and action-based input
|
Creates, destroys, and validates Entity handles. More...
#include <Imago/ECS/EntityManager.hpp>
Public Member Functions | |
| Entity | create () |
| Creates a new Entity, reusing a freed index when one is available. | |
| void | destroy (Entity) |
| Destroys an Entity, freeing its index for future reuse. | |
| bool | is_valid (Entity) const |
| Checks whether an Entity handle is still valid. | |
| uint32_t | get_alive_count () const |
| Returns the number of currently-alive entities. | |
Creates, destroys, and validates Entity handles.
EntityManager is the single source of truth for which entities currently exist. Destroyed indices are recycled oldest-first, with a bumped generation, so a stale Entity handle from before a Destroy() call correctly reports itself as invalid via IsValid(), even after its index has been reused by a new entity.
| Entity Imago::ECS::EntityManager::create | ( | ) |
| void Imago::ECS::EntityManager::destroy | ( | Entity | e | ) |
| bool Imago::ECS::EntityManager::is_valid | ( | Entity | e | ) | const |
Checks whether an Entity handle is still valid.
An Entity is valid if its index is currently allocated AND its generation matches the generation currently stored for that index.
| entity | The Entity to check. Safe to call with any value, including NULL_ENTITY. |