This function is used to free a component from an entity.
void dg_entity_free_component(dg_entity_t *entity, char *name);
dg_entity_free_component(entity, "score");
void dg_entity_free_component(dg_entity_t *entity, char *name)
{
int comp = -1;
dg_component_t *component = 0;
if (!entity || !name)
return;
comp = dg_entity_has_component(entity, name);
if (comp == -1)
return;
component = dg_arr_remove_at(&(entity->components), comp);
dg_component_destroy(component);
}