aboutsummaryrefslogtreecommitdiffstats
path: root/src/entity.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/entity.h')
-rw-r--r--src/entity.h25
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