| Top |
| LeecsEntity | leecs_entity_new () |
| LeecsEntity | leecs_entity_new_from_template () |
| void | leecs_entity_delete () |
| #define | leecs_entity_add_component() |
| #define | leecs_entity_add_tag() |
| #define | leecs_entity_remove_component() |
| #define | leecs_entity_get_component() |
| #define | leecs_entity_has_component() |
An entity can be any object or thing in a game which is constructed through composition from any number of defined components. Entities are stored in a LeecsWorld and they are identified by a numeric ID LeecsEntity.
Components can be added and removed from entities at any time using
leecs_entity_add_component(), leecs_entity_add_tag(), and
leecs_entity_remove_component(). The values of a component can be accessed
with leecs_entity_get_component().
The LeecsEntity IDs are not stable, and they may change when an entity is
deleted using leecs_entity_delete(). To modify an entity, it is best to
always query it using its components and use the LeecsEntity ID from the
query.
LeecsEntity
leecs_entity_new (LeecsWorld *world);
Creates a new empty entity in world
.
LeecsEntity leecs_entity_new_from_template (LeecsWorld *world,const char *template);
Creates a new entity from the given template in world
.
void leecs_entity_delete (LeecsWorld *world,LeecsEntity entity);
Deletes entity
from world
.
#define leecs_entity_add_component(world, entity, component_t, ...)
Adds component_t
to entity
and initializes it with the given initializer
list.
world |
LeecsWorld |
|
entity |
LeecsEntity to add |
|
component_t |
The type of the component. |
|
... |
Initializer list for |
#define leecs_entity_add_tag(world, entity, tag)
Adds tag
to entity
.
world |
LeecsWorld |
|
entity |
LeecsEntity to add |
|
tag |
The symbol of the tag. |
#define leecs_entity_remove_component(world, entity, component)
Removed component
from entity
.
world |
LeecsWorld |
|
entity |
LeecsEntity to remove |
|
component |
The symbol of the component. |
#define leecs_entity_get_component(world, entity, component_t)
Gets a pointer to component_t
belonging to entity
.
world |
LeecsWorld |
|
entity |
LeecsEntity to get |
|
component_t |
The type of the component. |
#define leecs_entity_has_component(world, entity, component)
world |
LeecsWorld |
|
entity |
LeecsEntity to check for |
|
component |
The symbol of the component. |