Module API addon

Functions

ecs_importImport a module
ecs_import_from_library

Defines

Defines (module.h)

ECS_MODULE(world,id)
ecs_id_t ecs_id(id) = ecs_new_module(world, 0, #id, sizeof(id), ECS_ALIGNOF(id));
ECS_VECTOR_STACK(FLECS__T##id, ecs_entity_t, &FLECS__E##id, 1);
id *handles = (id*)ecs_get_mut(world, ecs_id(id), id, NULL);
(void)ecs_id(id);
(void)ecs_type(id);
(void)handles;

Define module

Mentioned in:

Manual / Modules

ECS_IMPORT(world,id)
id ecs_module(id);
char *id##__name = ecs_module_path_from_c(#id);
ecs_id_t ecs_id(id) = ecs_import(
world, id##Import, id##__name, &ecs_module(id), sizeof(id));
ecs_os_free(id##__name);
ECS_VECTOR_STACK(FLECS__T##id, ecs_entity_t, &FLECS__E##id, 1);
id##ImportHandles(ecs_module(id));
(void)ecs_id(id);
(void)ecs_type(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. An application can retrieve the module component like this:

FlecsSystemsPhysics m = ecs_get(world, EcsSingleton, FlecsSystemsPhysics);

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

Mentioned in:

Manual / Naming conventions

Manual / Modules

ECS_DECLARE_COMPONENT(id)
ecs_id_t ecs_id(id);
ecs_type_t ecs_type(id)

Utility macro for declaring a component inside a handles type

Mentioned in:

Manual / Modules

ECS_DECLARE_ENTITY(id)
ecs_entity_t id;
ecs_type_t ecs_type(id)

Utility macro for declaring an entity inside a handles type

Mentioned in:

Manual / Modules

ECS_DECLARE_TYPE(id)
ECS_DECLARE_ENTITY(id)

Utility macro for declaring a type inside a handles type

ECS_SET_COMPONENT(id)
if (handles) handles->ecs_id(id) = ecs_id(id);
if (handles) handles->ecs_type(id) = ecs_type(id)

Utility macro for setting a component in a module function

ECS_SET_ENTITY(id)
if (handles) handles->id = id;

Utility macro for setting an entity in a module function

ECS_SET_TYPE(id)
if (handles) handles->id = id;
if (handles) handles->ecs_type(id) = ecs_type(id);

Utility macro for setting a type in a module function

ECS_EXPORT_COMPONENT(id)
ECS_SET_COMPONENT(id)

Mentioned in:

ECS_EXPORT_ENTITY(id)
ECS_SET_ENTITY(id)

Mentioned in:

ECS_EXPORT_TYPE(id)
ECS_SET_TYPE(id)

ECS_IMPORT_COMPONENT(handles,id)
ecs_id_t ecs_id(id) = (handles).ecs_id(id); (void)ecs_id(id);
ECS_VECTOR_STACK(FLECS__T##id, ecs_entity_t, &FLECS__E##id, 1);
(void)ecs_id(id);
(void)ecs_type(id)

Utility macro for importing a component

Mentioned in:

Manual / Modules

ECS_IMPORT_ENTITY(handles,id)
ecs_entity_t id = (handles).id;
ECS_VECTOR_STACK(FLECS__T##id, ecs_entity_t, &id, 1);
(void)id;
(void)ecs_type(id)

Utility macro for importing an entity

Mentioned in:

Manual / Modules

ECS_IMPORT_TYPE(handles,id)
ecs_entity_t id = (handles).id;
ecs_type_t ecs_type(id) = (handles).ecs_type(id);
(void)id;
(void)ecs_type(id)

Utility macro for importing a type