Function ecs_entity_init

Synopsis

#include <include/flecs.h>

FLECS_API ecs_entity_t ecs_entity_init(ecs_world_t *world, const ecs_entity_desc_t *desc)

Description

Find or create an entity. This operation creates a new entity, or modifies an existing one. When a name is set in the ecs_entity_desc_t::name field and ecs_entity_desc_t::entity is not set, the operation will first attempt to find an existing entity by that name. If no entity with that name can be found, it will be created.

If both a name and entity handle are provided, the operation will check if the entity name matches with the provided name. If the names do not match, the function will fail and return 0.

If an id to a non-existing entity is provided, that entity id become alive.

See the documentation of ecs_entity_desc_t for more details.

Parameters

world - The world.

desc - Entity init parameters.

Returns
A handle to the new or existing entity, or 0 if failed.

Mentioned in

Source

Line 1313 in include/flecs.h.