mirror of
https://github.com/zoriya/Gamacon.git
synced 2026-06-02 11:45:23 +00:00
Finishing the xml implementation
This commit is contained in:
@@ -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,
|
||||
¶llax_component,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user