104#define ECS_SYSTEM_DECLARE(id) ecs_entity_t ecs_id(id)
111#define ECS_SYSTEM_DEFINE(world, id_, phase, ...) \
113 ecs_system_desc_t desc = {0}; \
114 ecs_entity_desc_t edesc = {0}; \
115 edesc.id = ecs_id(id_);\
117 edesc.add[0] = ((phase) ? ecs_pair(EcsDependsOn, (phase)) : 0); \
118 edesc.add[1] = (phase); \
119 desc.entity = ecs_entity_init(world, &edesc);\
120 desc.query.filter.expr = #__VA_ARGS__; \
121 desc.callback = id_; \
122 ecs_id(id_) = ecs_system_init(world, &desc); \
124 ecs_assert(ecs_id(id_) != 0, ECS_INVALID_PARAMETER, NULL)
131#define ECS_SYSTEM(world, id, phase, ...) \
132 ecs_entity_t ecs_id(id) = 0; ECS_SYSTEM_DEFINE(world, id, phase, __VA_ARGS__);\
133 ecs_entity_t id = ecs_id(id);\
152#define ecs_system(world, ...)\
153 ecs_system_init(world, &(ecs_system_desc_t) __VA_ARGS__ )
205 int32_t stage_current,
281void FlecsSystemImport(
FLECS_API void * ecs_system_get_binding_ctx(const ecs_world_t *world, ecs_entity_t system)
Get system binding context.
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_system_init(ecs_world_t *world, const ecs_system_desc_t *desc)
Create a system.
FLECS_API ecs_query_t * ecs_system_get_query(const ecs_world_t *world, ecs_entity_t system)
Get the query object for a system.
FLECS_API void * ecs_system_get_ctx(const ecs_world_t *world, ecs_entity_t system)
Get system context.
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 ecs_entity_t ecs_run_w_filter(ecs_world_t *world, ecs_entity_t system, ecs_ftime_t delta_time, int32_t offset, int32_t limit, void *param)
Run system with offset/limit and type filter.
ecs_id_t ecs_entity_t
An entity identifier.
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
struct ecs_query_t ecs_query_t
A query that caches its results.
void(* ecs_iter_action_t)(ecs_iter_t *it)
Function prototype for iterables.
void(* ecs_run_action_t)(ecs_iter_t *it)
Function prototype for runnables (systems, observers).
void(* ecs_ctx_free_t)(void *ctx)
Function to cleanup context data.
#define ecs_ftime_t
Customizable precision for scalar time values.
Component used to provide a tick source to systems.
ecs_ftime_t time_elapsed
Time elapsed since last tick.
bool tick
True if providing tick.
Used with ecs_query_init.
Use with ecs_system_init.
int32_t rate
Rate at which the system should run.
void * ctx
Context to be passed to callback (as ecs_iter_t::param)
ecs_ctx_free_t ctx_free
Functions that are invoked during system cleanup to free context data.
bool multi_threaded
If true, system will be ran on multiple threads.
bool no_readonly
If true, system will have access to actuall world.
ecs_ftime_t interval
Interval in seconds at which the system should run.
ecs_iter_action_t callback
Callback that is ran for each result returned by the system's query.
void * binding_ctx
Binding context, for when system is implemented in other language.
ecs_entity_t entity
Existing entity to associate with system (optional)
ecs_query_desc_t query
System query parameters.
ecs_run_action_t run
Callback that is invoked when a system is ran.
ecs_entity_t tick_source
External tick soutce that determines when system ticks.
flecs::system_builder< Components... > system(Args &&... args) const
Create a new system.