Function ecs_ensure


#include <include/flecs.h>

FLECS_API void ecs_ensure(ecs_world_t *world, ecs_entity_t e)


Ensure id is alive. This operation ensures that the provided id is alive. This is useful in scenarios where an application has an existing id that has not been created with ecs_new (such as a global constant or an id from a remote application).

Before this operation the id must either not yet exist, or must exist with the same generation as the provided id. If the id has been recycled and the provided id does not have the same generation count, the function will fail.

If the provided entity is not alive, and the provided generation count is equal to the current generation (which is the future generation when the id will be recycled) the id will become alive again.

If the provided id has a non-zero generation count and the id does not exist in the world, the id will be created with the specified generation.

This behavior ensures that an application can use ecs_ensure to track the lifecycle of an id without explicitly having to create it. It also protects against reviving an id with a generation count that was not yet due.


world - The world.

entity - The entity id to make alive.


Line 1628 in include/flecs.h.