#include "utils.h" // Pretty much any object in the game. #ifndef ENTITY_H #define ENTITY_H #define ENTITY_COUNT 14 #define INTERACTION_MENU_MAX 9 #define INTERACTION_LABEL_MAX 64 #define ENTITY_DEFAULT_STATE -1 typedef int8_t EntityId; 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, OLD_MINT, STICKY_NICKEL, TREE, BUSH, FLOWER, POND, UTILITY_POLE, SAMANTHA, SAMANTHAS_SPOT, TRASHCAN, TRASH, MEDICAL_TRASH, JOHN, 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; struct Entity { EntityId id; Vector3 position; // Shouldnt be changed directly. BoundingBox box; EntityState state; void* data; }; 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 closeEntity(Entity* entity); void setEntityPosition(Entity* entity, Vector3 position); void placeEntityOnGround(Entity* entity, const World* world); bool entityIsPlace(EntityId id); bool entityCanBeSelected(EntityId id); InteractionCommand interactWithEntity(Entity* entity, Game* game, Selection selection); BoundingBox entityBoxFromScale(float scale, float width, float height); #endif