Module API addon

Functions

ecs_importImport a module
ecs_import_from_library
ecs_module_initRegister a new module.

Defines

Defines (module.h)

ECS_MODULE(world,id)
ecs_entity_t ecs_id(id) = ecs_module_init(world, &(ecs_component_desc_t){
.entity = {
.name = #id,
.add = {EcsModule}
}
});
ecs_set_scope(world, ecs_id(id));
(void)ecs_id(id);

Define module

Mentioned in:

Quickstart / Module

Manual / Modules

ECS_IMPORT(world,id)
char *FLECS__##id##_name = ecs_module_path_from_c(#id);
ecs_id_t ecs_id(id) = ecs_import(world, id##Import, FLECS__##id##_name);
ecs_os_free(FLECS__##id##_name);
(void)ecs_id(id)

Wrapper around ecs_import. This macro provides a convenient way to load a module with the world. It can be used like this:

ECS_IMPORT(world, FlecsSystemsPhysics, 0);

This macro will define entity and type handles for the component associated with the module. The module component will be created as a singleton.

The contents of a module component are module specific, although they typically contain handles to the content of the module.

Mentioned in:

Quickstart / Module

Manual / Naming conventions

Manual / Modules