Flecs v4.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
Entity Ranges

Entity id range management. More...

Collaboration diagram for Entity Ranges:

Classes

struct  ecs_entity_range_t
 Type that stores an entity id range. More...
 

Typedefs

typedef struct ecs_entity_range_t ecs_entity_range_t
 Type that stores an entity id range.
 

Functions

FLECS_API const ecs_entity_range_tecs_entity_range_new (ecs_world_t *world, uint32_t min, uint32_t max)
 Create a new entity range.
 
FLECS_API void ecs_entity_range_set (ecs_world_t *world, const ecs_entity_range_t *range)
 Set the active entity range.
 
FLECS_API const ecs_entity_range_tecs_entity_range_get (const ecs_world_t *world)
 Get the currently active entity id range.
 

Detailed Description

Entity id range management.

Typedef Documentation

◆ ecs_entity_range_t

typedef struct ecs_entity_range_t ecs_entity_range_t

Type that stores an entity id range.

Returned by ecs_entity_range_new(), used with ecs_entity_range_set().

Function Documentation

◆ ecs_entity_range_get()

FLECS_API const ecs_entity_range_t * ecs_entity_range_get ( const ecs_world_t * world)

Get the currently active entity id range.

Returns the range set by ecs_entity_range_set(), or NULL if no range is active.

Parameters
worldThe world.
Returns
The active range, or NULL.

◆ ecs_entity_range_new()

FLECS_API const ecs_entity_range_t * ecs_entity_range_new ( ecs_world_t * world,
uint32_t min,
uint32_t max )

Create a new entity range.

This function creates a range that constrains new entity identifiers returned by the specified [min, max] interval. Each range maintains its own list of recycled entity ids, which ensures that recycled ids always respect the configured range. If max is set to 0, the range is unbounded.

Entity ranges cannot be deleted once created. Use ecs_entity_range_set() to activate a range.

Parameters
worldThe world.
minThe first entity id in the range (inclusive).
maxThe last entity id in the range (inclusive, 0 = unlimited).
Returns
A pointer to the new range. Does not need to be freed.

◆ ecs_entity_range_set()

FLECS_API void ecs_entity_range_set ( ecs_world_t * world,
const ecs_entity_range_t * range )

Set the active entity range.

This function activates a range created with ecs_entity_range_new(). When a range is activated, new entity identifiers will fall within the specified [min, max] interval, including recycled identifiers.

When the active range is out of available ids, operations that create new entity ids will assert.

The operation only accepts ranges that have been created by ecs_entity_range_new().

Parameters
worldThe world.
rangeThe range to activate.