aboutsummaryrefslogtreecommitdiffstats
path: root/src/player.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/player.c b/src/player.c
index 40c60c3..27a4780 100644
--- a/src/player.c
+++ b/src/player.c
@@ -102,10 +102,22 @@ bool playerCanEntityBeSelected(Player* player, Entity entity)
<= PLAYER_MAX_SELECT_DISTANCE;
}
+void playerEndInteraction(Player* player, Game* game)
+{
+ player->selectedEntity = ENTITY_NONE;
+ player->isInteracting = false;
+
+ hideInteractionChat(&game->interactionChat);
+ hideInteractionMenu(&game->interactionMenu);
+ game->interactionChat.entityId = ENTITY_NONE;
+ game->interactionMenu.entityId = ENTITY_NONE;
+}
+
void playerInteractWithEntity(Player* player, WorldUID uid, Game* game,
Selection selection)
{
InteractionChat* chat = &game->interactionChat;
+ InteractionMenu* menu = &game->interactionMenu;
Entity* entity = &game->world.entities[uid];
@@ -114,14 +126,14 @@ void playerInteractWithEntity(Player* player, WorldUID uid, Game* game,
{
case SELECTION_INTERACT:
clearInteractionChat(chat);
+ resetInteractionMenu(menu);
chat->entityId = entity->id;
+ menu->entityId = entity->id;
player->selectedEntity = uid;
player->isInteracting = true;
break;
case SELECTION_LEAVE:
- player->selectedEntity = ENTITY_NONE;
- player->isInteracting = false;
- chat->entityId = ENTITY_NONE;
+ playerEndInteraction(player, game);
break;
default:
break;
@@ -131,13 +143,19 @@ void playerInteractWithEntity(Player* player, WorldUID uid, Game* game,
switch (interactWithEntity(entity, game, selection))
{
case INTERACTION_TALK:
+ hideInteractionMenu(menu);
showInteractionChat(chat);
break;
- case INTERACTION_END:
+ case INTERACTION_SHOW_MENU:
hideInteractionChat(chat);
- player->selectedEntity = ENTITY_NONE;
- player->isInteracting = false;
- chat->entityId = ENTITY_NONE;
+ showInteractionMenu(menu);
+ break;
+ case INTERACTION_TALK_AND_SHOW_MENU:
+ showInteractionChat(chat);
+ showInteractionMenu(menu);
+ break;
+ case INTERACTION_END:
+ playerEndInteraction(player, game);
break;
default:
break;