diff options
author | quou <quou@disroot.org> | 2025-05-01 20:45:12 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2025-05-01 21:09:54 +1000 |
commit | 26aebfdb92eb6780b1eb7195670b042b97948b0f (patch) | |
tree | 0b5eeb5f123fbf8b93c21c7d55add8a7e77bca34 /world.hpp | |
parent | df03ffea8d23b319c29c0c937e70d5afb15e76e2 (diff) |
Diffstat (limited to 'world.hpp')
-rw-r--r-- | world.hpp | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -3,16 +3,20 @@ struct Arena; +#include "entity.hpp" + #include <stdint.h> #include <new> +#include <tuple> #include <utility> - +extern "C" { +#include "plat.h" +} using Component_Mask = uint64_t; -using Entity_Id = uint32_t; #define max_entities 1024 -#define slinky_size 128 +#define slinky_size 1 #define max_components 64 #define max_slinkies (max_entities / slinky_size) @@ -36,7 +40,6 @@ struct Slinky { void init(Arena* a, int size); void* add(Entity_Id eid, int size, int& mapping); void* get(Entity_Id eid, int mapping, int size); - void remove(Entity_Id eid, int mapping, int size); }; struct Pool { @@ -71,8 +74,9 @@ struct World { uint8_t versions[max_entities]; Entity_Id entities[max_entities]; Entity_Id freelist[max_entities]; + Entity_Id dq[max_entities]; Arena* arena; - int count, free_count; + int count, dq_count, free_count; void init(Arena* a); uint64_t hash_mask(Component_Mask m); @@ -122,6 +126,8 @@ struct World { void* get(Entity_Id eid, int cid); void remove(Entity_Id eid, int cid); void destroy(Entity_Id e); + void qdestroy(Entity_Id e); + void update(); struct View { World* w; @@ -172,6 +178,7 @@ struct World { Slinky& s = p->slinkies[ptr >> slinky_size_bit]; int si = &s - p->slinkies; int off = ptr - (si << slinky_size_bit); + assert(s.entities[off]); return s.entities[off]; } }; |