Flecs v4.0
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
Enabling & Disabling

Functions for enabling/disabling entities and components. More...

Collaboration diagram for Enabling & Disabling:

Functions

void ecs_enable (ecs_world_t *world, ecs_entity_t entity, bool enabled)
 Enable or disable entity.
 
void ecs_enable_id (ecs_world_t *world, ecs_entity_t entity, ecs_id_t id, bool enable)
 Enable or disable component.
 
bool ecs_is_enabled_id (const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
 Test if component is enabled.
 

Detailed Description

Functions for enabling/disabling entities and components.

Function Documentation

◆ ecs_enable()

void ecs_enable ( ecs_world_t * world,
ecs_entity_t entity,
bool enabled )

Enable or disable entity.

This operation enables or disables an entity by adding or removing the EcsDisabled tag. A disabled entity will not be matched with any systems, unless the system explicitly specifies the EcsDisabled tag.

Parameters
worldThe world.
entityThe entity to enable or disable.
enabledtrue to enable the entity, false to disable.

◆ ecs_enable_id()

void ecs_enable_id ( ecs_world_t * world,
ecs_entity_t entity,
ecs_id_t id,
bool enable )

Enable or disable component.

Enabling or disabling a component does not add or remove a component from an entity, but prevents it from being matched with queries. This operation can be useful when a component must be temporarily disabled without destroying its value. It is also a more performant operation for when an application needs to add/remove components at high frequency, as enabling/disabling is cheaper than a regular add or remove.

Parameters
worldThe world.
entityThe entity.
idThe component.
enableTrue to enable the component, false to disable.

◆ ecs_is_enabled_id()

bool ecs_is_enabled_id ( const ecs_world_t * world,
ecs_entity_t entity,
ecs_id_t id )

Test if component is enabled.

Test whether a component is currently enabled or disabled. This operation will return true when the entity has the component and if it has not been disabled by ecs_enable_component().

Parameters
worldThe world.
entityThe entity.
idThe component.
Returns
True if the component is enabled, otherwise false.