/** * Copyright (c) 2024 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #include "interact.h" #include "assert/assert.h" #include "game/game.h" #include "locale/language.h" #include "rpg/conversation/conversationsign.h" void entityInteractEntity( entity_t *source, entity_t *target ) { assertNotNull(source, "entityInteractEntity: Source is NULL!"); assertNotNull(target, "entityInteractEntity: Target is NULL!"); source->state = ENTITY_STATE_TALKING; target->state = ENTITY_STATE_TALKING; switch(target->type) { case ENTITY_TYPE_NPC: target->direction = entityDirectionLookAt( target->x, target->y, source->x, source->y ); textboxSetText(target->npc.name, target->npc.text); return; case ENTITY_TYPE_SIGN: conversationSet(conversationSignInit, conversationSignUpdate, target); return; case ENTITY_TYPE_DOOR: entityPositionSet(source, target->door.x, target->door.y); source->direction = target->door.direction; if(GAME.mapNext != target->door.map) { GAME.mapNext = target->door.map; GAME.state = GAME_STATE_MAP_CHANGE; } return; default: return; } } void entityInteractTile( entity_t *source, tile_t tile ) { assertNotNull(source, "entityInteractTile: Source is NULL!"); switch(tile) { case TILE_WATER: textboxSetText(NULL, "A refreshing pool of water."); source->state = ENTITY_STATE_TALKING; return; default: break; } }