diff options
| author | nathan <nathansmith@disroot.org> | 2025-10-27 12:58:37 +0000 |
|---|---|---|
| committer | nathan <nathansmith@disroot.org> | 2025-10-27 12:58:37 +0000 |
| commit | 95af9c76abef62466dc99cd48fe60d5c8c0677aa (patch) | |
| tree | 016e9b8ca2681603512980bb32b571db6b530e10 /src/entity.c | |
| parent | 5925230971875ba3e6e591f0655cf84b739b50fc (diff) | |
| download | FindThings-95af9c76abef62466dc99cd48fe60d5c8c0677aa.tar.gz FindThings-95af9c76abef62466dc99cd48fe60d5c8c0677aa.tar.bz2 FindThings-95af9c76abef62466dc99cd48fe60d5c8c0677aa.zip | |
Working on interaction stuff
Diffstat (limited to 'src/entity.c')
| -rw-r--r-- | src/entity.c | 69 |
1 files changed, 38 insertions, 31 deletions
diff --git a/src/entity.c b/src/entity.c index aff0295..2242878 100644 --- a/src/entity.c +++ b/src/entity.c @@ -3,20 +3,22 @@ #include "entitiesInclude.h" const EntityEntry entityEntries[ENTITY_COUNT] = { - (EntityEntry){initOldMint, updateOldMint, NULL, false, true}, - (EntityEntry){initStickyNickel, updateStickyNickel, NULL, false, true}, - (EntityEntry){initTree, updateTree, NULL, false, true}, - (EntityEntry){initBush, updateBush, NULL, false, true}, - (EntityEntry){initFlower, updateFlower, NULL, false, true}, - (EntityEntry){initPond, updatePond, NULL, true, true}, - (EntityEntry){initUtilityPole, NULL, NULL, false, false}, - (EntityEntry){initSamantha, updateSamantha, NULL, false, true}, - (EntityEntry){initSamanthasSpot, updateSamanthasSpot, NULL, true, false}, - (EntityEntry){initTrashcan, updateTrashcan, NULL, false, true}, - (EntityEntry){initTrash, updateTrash, NULL, false, true}, - (EntityEntry){initMedicalTrash, updateMedicalTrash, NULL, false, true}, - (EntityEntry){initJohn, updateJohn, NULL, false, true}, - (EntityEntry){initRon, updateRon, NULL, false, true} + (EntityEntry){initOldMint, updateOldMint, NULL, NULL, false, true}, + (EntityEntry){initStickyNickel, updateStickyNickel, NULL, NULL, false, true}, + (EntityEntry){initTree, updateTree, NULL, NULL, false, true}, + (EntityEntry){initBush, updateBush, NULL, NULL, false, true}, + (EntityEntry){initFlower, updateFlower, NULL, NULL, false, true}, + (EntityEntry){initPond, updatePond, NULL, NULL, true, true}, + (EntityEntry){initUtilityPole, NULL, NULL, NULL, false, false}, + (EntityEntry){initSamantha, updateSamantha, NULL, interactWithSamantha, + false, true}, + (EntityEntry){initSamanthasSpot, updateSamanthasSpot, NULL, NULL, true, + false}, + (EntityEntry){initTrashcan, updateTrashcan, NULL, NULL, false, true}, + (EntityEntry){initTrash, updateTrash, NULL, NULL, false, true}, + (EntityEntry){initMedicalTrash, updateMedicalTrash, NULL, NULL, false, true}, + (EntityEntry){initJohn, updateJohn, NULL, NULL, false, true}, + (EntityEntry){initRon, updateRon, NULL, NULL, false, true} }; Entity createEntity(EntityId id, Vector3 position) @@ -43,6 +45,11 @@ void updateEntity(Entity* entity, Game* game) { //DrawBoundingBox(entity->box, BLUE); + if (entity->id == ENTITY_NONE) + { + return; + } + UpdateEntityCallback updateCallback = entityEntries[entity->id].updateCallback; @@ -90,37 +97,37 @@ void placeEntityOnGround(Entity* entity, const World* world) bool entityIsPlace(EntityId id) { + if (id == ENTITY_NONE) + { + return false; + } + return entityEntries[id].isPlace; } bool entityCanBeSelected(EntityId id) { + if (id == ENTITY_NONE) + { + return false; + } + return entityEntries[id].canBeSelected; } -InteractionCommand interactWithOldMint(Entity* entity, Game* game, - Selection selection) +InteractionCommand interactWithEntity(Entity* entity, Game* game, + Selection selection) { - if (selection == SELECTION_INTERACT) - { - // Run display message code. - return INTERACTION_TALK; - } - else + if (entity->id == ENTITY_NONE) { return INTERACTION_END; } -} + + InteractionCallback callback = entityEntries[entity->id].interactionCallback; -InteractionCommand interactWithEntity(Entity* entity, Game* game, - Selection selection) -{ - switch (entity->id) + if (callback != NULL) { - case OLD_MINT: // For testing. - return interactWithOldMint(entity, game, selection); - default: - break; + return callback(entity, game, selection); } return INTERACTION_END; |
