diff options
author | quou <quou@disroot.org> | 2023-05-04 14:21:23 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2023-05-04 14:21:23 +1000 |
commit | 7fa5b3c842c276859c7d4016b9660e1b16ac30c5 (patch) | |
tree | f9290a27a7385962b878be19a2647a792ec0dd68 /world.c | |
parent | d61dcdcc384249ec7ea60c9cc18aab9df1f80577 (diff) |
Add entity destruction.
Diffstat (limited to 'world.c')
-rw-r--r-- | world.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -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; } |