From 5be3c38211c6e236fdf39c2885da571d93ad32ae Mon Sep 17 00:00:00 2001 From: Andrew Guschin Date: Wed, 15 Sep 2021 00:20:47 +0400 Subject: Added systems support --- src/storage.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/storage.h') diff --git a/src/storage.h b/src/storage.h index f7f5cd9..2601ef7 100644 --- a/src/storage.h +++ b/src/storage.h @@ -19,22 +19,30 @@ #define REGISTER_COMPONENT(storage, componentType) internal_registerComponent(storage, #componentType, sizeof(componentType)) #define ADD_COMPONENT(storage, idx, componentType) internal_addComponent(storage, idx, #componentType) +typedef struct storage_t storage_t; typedef unsigned int entity_t; +typedef void (*system_t)(storage_t *storage, entity_t eid); typedef struct { + int idx; const char *name; size_t objectSize; char *objects; } component_pair_t; -typedef struct +struct storage_t { unsigned int componentsStored; - unsigned int objectsStored; + + size_t objectsStored; component_pair_t *objects; bitarena_t objectSignatures; -} storage_t; + + size_t systemsStored; + system_t *systems; + bitarena_t systemSignatures; +}; component_pair_t * // NULL if pair is not found findPair(storage_t *this, const char *name); @@ -42,6 +50,12 @@ findPair(storage_t *this, const char *name); entity_t createEntity(storage_t *this); +void +registerSystem(storage_t *storage, system_t system, bitset_t components); + +bitset_t +createSignature(storage_t *storage, char **components); + // Not intended for use outside of macros void internal_registerComponent(storage_t *storage, const char *name, size_t size); -- cgit v1.2.3