Download Tutorial C Files H Files

dg_entity_rm_component

This function is used to remove a component from an entity.

Usage

dg_component_t *dg_entity_rm_component(dg_entity_t *entity, char *name);

Example

int score = dg_entity_rm_component(entity, "score");

Source code

dg_component_t *dg_entity_rm_component(dg_entity_t *entity, char *name)
{
    int comp = -1;

    if (!entity || name)
        return 0;
    comp = dg_entity_has_component(entity, name);
    if (comp == -1)
        return 0;
    return dg_arr_remove_at(&(entity->components), comp);
}