diff options
Diffstat (limited to 'src/world.c')
-rw-r--r-- | src/world.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/world.c b/src/world.c index 0ec3b32..3bc02cd 100644 --- a/src/world.c +++ b/src/world.c @@ -66,7 +66,7 @@ EntityId popVacantId(World * world) { // Already empty. if (world->vacantIds == NULL) - return ENTITY_ID_NONE; + return ENTITY_NONE; id = world->vacantIds[world->vacantIdsCount - 1]; @@ -120,7 +120,7 @@ EntityId addEntityToWorld(World * world, Entity entity) { if (world->entities == NULL || world->lookUp == NULL) { ALLOCATION_ERROR; - return ENTITY_ID_NONE; + return ENTITY_NONE; } // Set entity and id. @@ -141,7 +141,7 @@ EntityId addEntityToWorld(World * world, Entity entity) { if (world->entities == NULL) { ALLOCATION_ERROR; - return ENTITY_ID_NONE; + return ENTITY_NONE; } // Set entity. @@ -167,7 +167,7 @@ EntityId addEntityToWorld(World * world, Entity entity) { if (world->lookUp == NULL) { ALLOCATION_ERROR; - return ENTITY_ID_NONE; + return ENTITY_NONE; } // Set id. @@ -250,3 +250,26 @@ void drawWorld(World * world, Game * game) { entity->drawCb(game, entity); } } + +KfError addEntryToWorld(World * world, Game * game, WorldEntry entry) { + // Create entity. + Entity entity = createEntity(entry.type, game); + entity.position = entry.position; + entity.rotation = entry.rotation; + + // Add to world. + if (addEntityToWorld(world, entity) == ENTITY_NONE) + return KFERROR; + + return KFSUCCESS; +} + +KfError addEntriesToWorld(World * world, Game * game, WorldEntry * entries, size_t entriesCount) { + int i; + + for (i = 0; i < entriesCount; ++i) + if (addEntryToWorld(world, game, entries[i]) != KFSUCCESS) + return KFERROR; + + return KFSUCCESS; +} |