summaryrefslogtreecommitdiff
path: root/src/storage.h
diff options
context:
space:
mode:
authorAndrew Guschin <saintruler@gmail.com>2021-09-15 00:20:47 +0400
committerAndrew Guschin <saintruler@gmail.com>2021-09-15 00:20:47 +0400
commit5be3c38211c6e236fdf39c2885da571d93ad32ae (patch)
treee1199b932626c1830ad41eb60269825dcf9b477e /src/storage.h
parent11048808cbe3dc77bb2bee6d2643a33a45574509 (diff)
Added systems support
Diffstat (limited to 'src/storage.h')
-rw-r--r--src/storage.h20
1 files changed, 17 insertions, 3 deletions
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);