diff options
author | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-07-09 01:26:05 -0600 |
---|---|---|
committer | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-07-09 01:26:05 -0600 |
commit | 708072e716e7ab22a37f528311a433f195f75054 (patch) | |
tree | ee778b916531b8da3967ad5324019cbfb4e03e1c /src/world.c | |
parent | 3f0be672f9c5a07a98be0dc703b95f1bbe73f33e (diff) |
World entries added
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; +} |