183#define ECS_SYSTEM_DECLARE(id) ecs_entity_t ecs_id(id)
193#define ECS_SYSTEM_DEFINE(world, id_, phase, ...) \
195 ecs_system_desc_t desc = {0}; \
196 ecs_entity_desc_t edesc = {0}; \
197 ecs_id_t add_ids[3] = {\
198 ((phase) ? ecs_pair(EcsDependsOn, (phase)) : 0), \
202 edesc.id = ecs_id(id_);\
204 edesc.add = add_ids;\
205 desc.entity = ecs_entity_init(world, &edesc);\
206 desc.query.expr = #__VA_ARGS__; \
207 desc.callback = id_; \
208 ecs_id(id_) = ecs_system_init(world, &desc); \
210 ecs_assert(ecs_id(id_) != 0, ECS_INVALID_PARAMETER, "failed to create system %s", #id_)
220#define ECS_SYSTEM(world, id, phase, ...) \
221 ecs_entity_t ecs_id(id) = 0; ECS_SYSTEM_DEFINE(world, id, phase, __VA_ARGS__);\
222 ecs_entity_t id = ecs_id(id);\
244#define ecs_system(world, ...)\
245 ecs_system_init(world, &(ecs_system_desc_t) __VA_ARGS__ )
297 int32_t stage_current,
struct EcsTickSource EcsTickSource
Component used to provide a tick source to systems.
FLECS_API const ecs_system_t * ecs_system_get(const ecs_world_t *world, ecs_entity_t system)
Get system object.
FLECS_API void FlecsSystemImport(ecs_world_t *world)
System module import function.
struct ecs_system_desc_t ecs_system_desc_t
Use with ecs_system_init() to create or update a system.
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.
struct ecs_system_t ecs_system_t
System type, get with ecs_system_get()
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.
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.
void(* ecs_iter_action_t)(ecs_iter_t *it)
Function prototype for iterables.
void(* flecs_poly_dtor_t)(ecs_poly_t *poly)
Destructor function for poly objects.
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().
Queries are lists of constraints (terms) that match entities.
Use with ecs_system_init() to create or update a system.
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 run_ctx_free
Callback to free run ctx.
ecs_ctx_free_t ctx_free
Callback to free ctx.
bool multi_threaded
If true, system will be ran on multiple threads.
bool immediate
If true, system will have access to the actual world.
void * callback_ctx
Context associated with callback (for language bindings).
void * run_ctx
Context associated with run (for language bindings).
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.
ecs_entity_t entity
Existing entity to associate with system (optional)
ecs_query_desc_t query
System query parameters.
ecs_ctx_free_t callback_ctx_free
Callback to free callback ctx.
ecs_run_action_t run
Callback that is invoked when a system is ran.
ecs_entity_t tick_source
External tick source that determines when system ticks.
System type, get with ecs_system_get()
ecs_iter_action_t action
See ecs_system_desc_t.
ecs_query_t * query
System query.
ecs_ctx_free_t ctx_free
Callback to free ctx.
void * run_ctx
Run language binding context.
ecs_run_action_t run
See ecs_system_desc_t.
ecs_ftime_t time_passed
Time passed since last invocation.
int64_t last_frame
Last frame for which the system was considered.
ecs_ftime_t time_spent
Time spent on running system.
const char * name
Cached system name (for perf tracing)
ecs_ctx_free_t run_ctx_free
Callback to free run ctx.
bool immediate
Is system ran in immediate mode.
bool multi_threaded
Is system multithreaded.
void * ctx
Userdata for system.
ecs_ctx_free_t callback_ctx_free
Callback to free callback ctx.
ecs_entity_t query_entity
Entity associated with query.
ecs_entity_t tick_source
Tick source associated with system.
void * callback_ctx
Callback language binding context.