Flecs: include/flecs/addons/module.h Source File
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.1 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
module.h
Go to the documentation of this file.
1
9
10#ifdef FLECS_MODULE
11
19
20#ifndef FLECS_MODULE_H
21#define FLECS_MODULE_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
45FLECS_API
46 ecs_entity_t ecs_import(
47 ecs_world_t *world,
48 ecs_module_action_t module,
49 const char *module_name);
50
59FLECS_API
60 ecs_entity_t ecs_import_c(
61 ecs_world_t *world,
62 ecs_module_action_t module,
63 const char *module_name_c);
64
84FLECS_API
85 ecs_entity_t ecs_import_from_library(
86 ecs_world_t *world,
87 const char *library_name,
88 const char *module_name);
89
97FLECS_API
98 ecs_entity_t ecs_module_init(
99 ecs_world_t *world,
100 const char *c_name,
101 const ecs_component_desc_t *desc);
102
104#define ECS_MODULE_DEFINE(world, id)\
105 {\
106 ecs_component_desc_t desc = {0};\
107 desc.entity = ecs_id(id);\
108 ecs_id(id) = ecs_module_init(world, #id, &desc);\
109 ecs_set_scope(world, ecs_id(id));\
110 }
111
113#define ECS_MODULE(world, id)\
114 ecs_entity_t ecs_id(id) = 0; ECS_MODULE_DEFINE(world, id)\
115 (void)ecs_id(id)
116
125#define ECS_IMPORT(world, id) ecs_import_c(world, id##Import, #id)
126
127#ifdef __cplusplus
128}
129#endif
130
131#endif
132
134
135#endif
ecs_import_from_library
FLECS_API ecs_entity_t ecs_import_from_library(ecs_world_t *world, const char *library_name, const char *module_name)
Import a module from a library.
ecs_module_init
FLECS_API ecs_entity_t ecs_module_init(ecs_world_t *world, const char *c_name, const ecs_component_desc_t *desc)
Register a new module.
ecs_import
FLECS_API ecs_entity_t ecs_import(ecs_world_t *world, ecs_module_action_t module, const char *module_name)
Import a module.
ecs_import_c
FLECS_API ecs_entity_t ecs_import_c(ecs_world_t *world, ecs_module_action_t module, const char *module_name_c)
Same as ecs_import(), but with name to scope conversion.
ecs_entity_t
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:385
ecs_world_t
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:429
ecs_module_action_t
void(* ecs_module_action_t)(ecs_world_t *world)
Initialization action for modules.
Definition flecs.h:641
ecs_component_desc_t
Used with ecs_component_init().
Definition flecs.h:1122