#include "utils.h" // Pretty much any object in the game. #ifndef ENTITY_H #define ENTITY_H #define ENTITY_COUNT 15 #define ENTITY_NAME_MAX 16 #define INTERACTION_MENU_MAX 9 #define INTERACTION_LABEL_MAX 32 #define INTERACTION_CHAT_MAX 256 #define ENTITY_BUILDING_CUBE_SIZE (Vector3){4.0, 4.0, 4.0} #define ENTITY_BUILDING_GROUND_OFFSET 0.03 typedef int8_t EntityId; typedef enum InteractionCommand InteractionCommand; typedef enum Selection Selection; typedef struct Entity Entity; typedef InteractionCommand (*InteractionCallback)(Entity* entity, Game* game, Selection selection); 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, JOHNS_STORE, RON }; enum InteractionCommand { INTERACTION_END, INTERACTION_TALK, INTERACTION_SHOW_MENU, INTERACTION_TALK_AND_SHOW_MENU, INTERACTION_DO_NOTHING }; enum Selection { SELECTION_NONE = -1, SELECTION_INTERACT, SELECTION_NEXT_MESSAGE, SELECTION_MENU_ITEM, // +x to select any given menu entry SELECTION_LEAVE = SELECTION_MENU_ITEM + INTERACTION_MENU_MAX }; struct Entity { EntityId id; Vector3 position; // Shouldnt be changed directly. BoundingBox box; void* data; }; // Cubemap based building. typedef struct { Model model; Color* pixelMap; } EntityBuilding; typedef struct { char name[ENTITY_NAME_MAX]; InitEntityCallback initCallback; UpdateEntityCallback updateCallback; CloseEntityCallback closeCallback; InteractionCallback interactionCallback; bool isPlace; bool isBuilding; bool canBeSelected; } EntityEntry; // Am I still insane if I am aware of my insanity? extern const EntityEntry entityEntries[ENTITY_COUNT]; Entity createEntity(EntityId id, Vector3 position); void updateEntity(Entity* entity, Game* game); void closeEntity(Entity* entity); const char* getEntityName(EntityId id); void setEntityPosition(Entity* entity, Vector3 position); void placeEntityOnGround(Entity* entity, const World* world); bool entityIsPlace(EntityId id); bool entityIsBuilding(EntityId id); bool entityCanBeSelected(EntityId id); float getEntityDistance(Entity entity, Vector3 position); InteractionCommand interactWithEntity(Entity* entity, Game* game, Selection selection); int getInteractionMenuIndex(Selection selection); BoundingBox entityBoxFromScale(float scale, float width, float height); EntityBuilding* createEntityBuilding(Image heightmap); void freeEntityBuilding(EntityBuilding* entityBuilding); #endif