aboutsummaryrefslogtreecommitdiff
path: root/world.c
diff options
context:
space:
mode:
Diffstat (limited to 'world.c')
-rw-r--r--world.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/world.c b/world.c
index b271c3d..3b736e6 100644
--- a/world.c
+++ b/world.c
@@ -7,11 +7,21 @@ void init_world(World* world) {
Entity new_entity(World* world) {
Entity e;
- e = world->entity_count++;
+ e =
+ world->recycle_bin_count > 0 ?
+ world->recycle_bin[--world->recycle_bin_count] :
+ world->entity_count++;
+
world->bitmask[e] = 0;
+
return e;
}
+void destroy_entity(World* world, Entity e) {
+ world->recycle_bin[world->recycle_bin_count++] = e;
+ world->bitmask[e] = 0;
+}
+
void add_components(World* world, Entity e, CType bits) {
world->bitmask[e] |= bits;
}