Finishing the xml implementation

This commit is contained in:
AnonymusRaccoon
2019-12-09 16:59:25 +01:00
parent ee89f69e7a
commit 9a7aee4587
4 changed files with 6 additions and 3 deletions
+2
View File
@@ -9,6 +9,7 @@
#include "components/transform_component.h"
#include "components/movable_component.h"
#include "components/texture_renderer.h"
#include "components/parallax_component.h"
#include "utility.h"
#include <stdlib.h>
@@ -18,6 +19,7 @@ const void *get_component(char *name)
&transform_component,
&movable_component,
&texture_renderer,
&parallax_component,
NULL
};
+1 -1
View File
@@ -38,7 +38,7 @@ gc_entity *deserialize_entity(gc_engine *engine, node *n)
entity = entity_create();
if (!entity)
return (NULL);
for (node *cmp_n = n->child; n; n = n->next) {
for (node *cmp_n = n->child; cmp_n; cmp_n = cmp_n->next) {
cmp = deserialize_component(engine, cmp_n);
entity->add_component(entity, cmp);
}
+1 -2
View File
@@ -21,8 +21,7 @@ gc_entity *prefab_load(gc_engine *engine, const char *path)
if (!n)
return (NULL);
n = xml_getnode(n, "gc_scene");
for (node *ent_n = n->child; n; n = n->next)
for (node *ent_n = n->child; ent_n; ent_n = ent_n->next)
entity = entity_add(entity, deserialize_entity(engine, ent_n));
xml_destroy(n);
return (entity);
+2
View File
@@ -54,6 +54,8 @@ gc_entity *entity_add_component(gc_entity *entity, void *component)
{
gc_component *components = entity->components;
if (!component)
return (NULL);
if (!components)
entity->components = component;
else {