Flecs v4.0
A fast entity component system (ECS) for C & C++
|
Systems are a query + function that can be ran manually or by a pipeline. More...
Classes | |
struct | EcsTickSource |
Component used to provide a tick source to systems. More... | |
struct | ecs_system_desc_t |
Use with ecs_system_init() to create or update a system. More... | |
struct | ecs_system_t |
System type, get with ecs_system_get() More... | |
Macros | |
#define | FLECS_SYSTEM_H |
#define | ECS_SYSTEM_DECLARE(id) ecs_entity_t ecs_id(id) |
Forward declare a system. | |
#define | ECS_SYSTEM_DEFINE(world, id_, phase, ...) |
Define a forward declared system. | |
#define | ECS_SYSTEM(world, id, phase, ...) |
Declare & define a system. | |
#define | ecs_system(world, ...) ecs_system_init(world, &(ecs_system_desc_t) __VA_ARGS__ ) |
Shorthand for creating a system with ecs_system_init(). | |
Typedefs | |
typedef struct EcsTickSource | EcsTickSource |
Component used to provide a tick source to systems. | |
typedef struct ecs_system_desc_t | ecs_system_desc_t |
Use with ecs_system_init() to create or update a system. | |
typedef struct ecs_system_t | ecs_system_t |
System type, get with ecs_system_get() | |
Functions | |
FLECS_API ecs_entity_t | ecs_system_init (ecs_world_t *world, const ecs_system_desc_t *desc) |
Create a system. | |
FLECS_API const ecs_system_t * | ecs_system_get (const ecs_world_t *world, ecs_entity_t system) |
Get system object. | |
FLECS_API ecs_entity_t | ecs_run (ecs_world_t *world, ecs_entity_t system, ecs_ftime_t delta_time, void *param) |
Run a specific system manually. | |
FLECS_API ecs_entity_t | ecs_run_worker (ecs_world_t *world, ecs_entity_t system, int32_t stage_current, int32_t stage_count, ecs_ftime_t delta_time, void *param) |
Same as ecs_run(), but subdivides entities across number of provided stages. | |
FLECS_API void | FlecsSystemImport (ecs_world_t *world) |
System module import function. | |
Systems are a query + function that can be ran manually or by a pipeline.
#define ECS_SYSTEM | ( | world, | |
id, | |||
phase, | |||
... ) |
Declare & define a system.
Example:
#define ecs_system | ( | world, | |
... ) ecs_system_init(world, &(ecs_system_desc_t) __VA_ARGS__ ) |
Shorthand for creating a system with ecs_system_init().
Example:
#define ECS_SYSTEM_DECLARE | ( | id | ) | ecs_entity_t ecs_id(id) |
#define ECS_SYSTEM_DEFINE | ( | world, | |
id_, | |||
phase, | |||
... ) |
Define a forward declared system.
Example:
FLECS_API ecs_entity_t ecs_run | ( | ecs_world_t * | world, |
ecs_entity_t | system, | ||
ecs_ftime_t | delta_time, | ||
void * | param ) |
Run a specific system manually.
This operation runs a single system manually. It is an efficient way to invoke logic on a set of entities, as manual systems are only matched to tables at creation time or after creation time, when a new table is created.
Manual systems are useful to evaluate lists of pre-matched entities at application defined times. Because none of the matching logic is evaluated before the system is invoked, manual systems are much more efficient than manually obtaining a list of entities and retrieving their components.
An application may pass custom data to a system through the param parameter. This data can be accessed by the system through the param member in the ecs_iter_t value that is passed to the system callback.
Any system may interrupt execution by setting the interrupted_by member in the ecs_iter_t value. This is particularly useful for manual systems, where the value of interrupted_by is returned by this operation. This, in combination with the param argument lets applications use manual systems to lookup entities: once the entity has been found its handle is passed to interrupted_by, which is then subsequently returned.
world | The world. |
system | The system to run. |
delta_time | The time passed since the last system invocation. |
param | A user-defined parameter to pass to the system. |
FLECS_API ecs_entity_t ecs_run_worker | ( | ecs_world_t * | world, |
ecs_entity_t | system, | ||
int32_t | stage_current, | ||
int32_t | stage_count, | ||
ecs_ftime_t | delta_time, | ||
void * | param ) |
Same as ecs_run(), but subdivides entities across number of provided stages.
world | The world. |
system | The system to run. |
stage_current | The id of the current stage. |
stage_count | The total number of stages. |
delta_time | The time passed since the last system invocation. |
param | A user-defined parameter to pass to the system. |
FLECS_API const ecs_system_t * ecs_system_get | ( | const ecs_world_t * | world, |
ecs_entity_t | system ) |
Get system object.
Returns the system object. Can be used to access various information about the system, like the query and context.
world | The world. |
system | The system. |
FLECS_API void FlecsSystemImport | ( | ecs_world_t * | world | ) |