diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/entity.c | 30 | ||||
| -rw-r--r-- | src/entity.h | 29 |
2 files changed, 59 insertions, 0 deletions
diff --git a/src/entity.c b/src/entity.c index 919da95..70a7db5 100644 --- a/src/entity.c +++ b/src/entity.c @@ -16,6 +16,7 @@ Entity createEntity(EntityId id, Vector3 position) { Entity entity; entity.id = id; + entity.state = ENTITY_DEFAULT_STATE; // Bounding boxes. switch (id) @@ -213,3 +214,32 @@ void placeEntityOnGround(Entity* entity, const World* world) setEntityPosition(entity, position); } + + +InteractionCommand interactWithOldMint(Entity* entity, Game* game, + Selection selection) +{ + if (selection == SELECTION_INTERACT) + { + // Run display message code. + return INTERACTION_TALK; + } + else + { + return INTERACTION_END; + } +} + +InteractionCommand interactWithEntity(Entity* entity, Game* game, + Selection selection) +{ + switch (entity->id) + { + case OLD_MINT: // For testing. + return interactWithOldMint(entity, game, selection); + default: + break; + } + + return INTERACTION_END; +} diff --git a/src/entity.h b/src/entity.h index 9c842d3..72fadb4 100644 --- a/src/entity.h +++ b/src/entity.h @@ -40,7 +40,12 @@ #define SHOPKEEPER_HEIGHT (2.59521 / 2.0) #define SHOPKEEPER_THICKNESS (0.493349 / 2.0) +#define INTERACTION_MENU_MAX 9 +#define INTERACTION_LABEL_MAX 64 +#define ENTITY_DEFAULT_STATE -1 + typedef int8_t EntityId; +typedef int8_t EntityState; enum { ENTITY_NONE = -1, @@ -60,15 +65,39 @@ enum { RON }; +typedef enum { + INTERACTION_TALK, + INTERACTION_SHOW_MENU, + INTERACTION_END +} InteractionCommand; + +typedef enum { + SELECTION_INTERACT, + SELECTION_NEXT_MESSAGE, + SELECTION_MENU_ITEM, // +x to select any given menu entry + SELECTION_LEAVE +} Selection; + typedef struct { EntityId id; Vector3 position; // Shouldnt be changed directly. BoundingBox box; + EntityState state; } Entity; +typedef void (*InteractionCallback)(Entity* entity, Game* game); + +typedef struct { + char label[INTERACTION_LABEL_MAX]; + InteractionCallback callback; +} InteractionMenuEntry; + Entity createEntity(EntityId id, Vector3 position); void updateEntity(Entity* entity, Game* game); void setEntityPosition(Entity* entity, Vector3 position); void placeEntityOnGround(Entity* entity, const World* world); +InteractionCommand interactWithEntity(Entity* entity, Game* game, + Selection selection); + #endif |
