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