Download Tutorial C Files H Files

dg_entity_destroy

This function is used to destroy an entity.

Usage

void dg_entity_destroy(dg_entity_t *entity);

Example

dg_entity_destroy(entity);

Source code

void dg_entity_destroy(dg_entity_t *entity)
{
    dg_array_t *tmp = 0;

    if (!entity)
        return;
    tmp = entity->components;
    while (tmp) {
        dg_component_destroy(tmp->data);
        tmp = tmp->next;
    }
    dg_arr_free_all(&(entity->components));
    free(entity);
}