Adding helper function for the prefab

This commit is contained in:
Anonymus Raccoon
2020-04-16 16:37:50 +02:00
parent 67386416c6
commit c7deb5a957
4 changed files with 15 additions and 0 deletions
+1
View File
@@ -44,6 +44,7 @@ void rend_set_anim(struct renderer *rend, const char *name);
void text_ctr(struct renderer *cmp, va_list args);
void text_fdctr(gc_scene *scene, struct renderer *cmp, node *n);
void text_safe_destroy(struct renderer *rend);
void map_ctr(struct renderer *cmp, va_list args);
void map_fdctr(gc_scene *scene, struct renderer *cmp, gc_entity *entity);
+1
View File
@@ -14,3 +14,4 @@ int prefab_loadentities(node *n, gc_engine *engine, gc_scene *scene);
gc_entity *deserialize_entity(gc_engine *engine, gc_scene *scene, node *n);
gc_component *deserialize_component(gc_engine *engine, gc_entity *entity, \
gc_scene *scene, node *n);
void prefab_destroy(gc_scene *scene, int prefab_id);
+5
View File
@@ -20,6 +20,11 @@ void destroy_text_renderer(struct renderer *cmp)
free(cmp->data);
}
void text_safe_destroy(struct renderer *rend)
{
free(rend->data);
}
int color_from_text(char *txt)
{
if (txt == NULL)
+8
View File
@@ -49,4 +49,12 @@ int prefab_loadentities(node *n, gc_engine *engine, gc_scene *scene)
if (engine->on_resize && engine->get_screen_size && engine->scene)
engine->on_resize(engine, engine->get_screen_size(engine));
return (prefab_id - 1);
}
void prefab_destroy(gc_scene *scene, int prefab_id)
{
for (gc_list *li = scene->entities; li; li = li->next) {
if (((gc_entity *)li->data)->prefab_id == prefab_id)
((gc_entity *)li->data)->destroy(li->data, scene);
}
}