diff options
| author | nathan <nathansmith@disroot.org> | 2025-10-25 23:18:08 +0000 |
|---|---|---|
| committer | nathan <nathansmith@disroot.org> | 2025-10-25 23:18:08 +0000 |
| commit | 32e795acb0c60a320b8449a3b7b6ee5fb5779c12 (patch) | |
| tree | 62ea2eb3ccac8adba7fcdada36a63f25541913f5 /src/entity.h | |
| parent | 233d6994bea031c0d22a77f5a8b7427a2b566e12 (diff) | |
| download | FindThings-32e795acb0c60a320b8449a3b7b6ee5fb5779c12.tar.gz FindThings-32e795acb0c60a320b8449a3b7b6ee5fb5779c12.tar.bz2 FindThings-32e795acb0c60a320b8449a3b7b6ee5fb5779c12.zip | |
Switching to better entity system
Diffstat (limited to 'src/entity.h')
| -rw-r--r-- | src/entity.h | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/entity.h b/src/entity.h index 9727e51..3170059 100644 --- a/src/entity.h +++ b/src/entity.h @@ -45,7 +45,13 @@ #define ENTITY_DEFAULT_STATE -1 typedef int8_t EntityId; -typedef int8_t EntityState; +typedef int16_t EntityState; + +typedef struct Entity Entity; +typedef void (*InteractionCallback)(Entity* entity, Game* game); +typedef void (*InitEntityCallback)(Entity* entity); +typedef void (*UpdateEntityCallback)(Entity* entity, Game* game); +typedef void (*CloseEntityCallback)(Entity* entity); enum { ENTITY_NONE = -1, @@ -78,20 +84,29 @@ typedef enum { SELECTION_LEAVE } Selection; -typedef struct { +struct Entity { EntityId id; Vector3 position; // Shouldnt be changed directly. BoundingBox box; EntityState state; -} Entity; + void* data; +}; -typedef void (*InteractionCallback)(Entity* entity, Game* game); +typedef struct { + InitEntityCallback initCallback; + UpdateEntityCallback updateCallback; + CloseEntityCallback closeCallback; + bool isPlace; + bool canBeSelected; +} EntityEntry; typedef struct { char label[INTERACTION_LABEL_MAX]; InteractionCallback callback; } InteractionMenuEntry; +extern const EntityEntry entityEntries[ENTITY_COUNT]; + Entity createEntity(EntityId id, Vector3 position); void updateEntity(Entity* entity, Game* game); void setEntityPosition(Entity* entity, Vector3 position); @@ -101,4 +116,6 @@ bool entityCanBeSelected(EntityId id); InteractionCommand interactWithEntity(Entity* entity, Game* game, Selection selection); +BoundingBox entityBoxFromScale(float scale, float width, float height); + #endif |
