/** * 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/conversationinteractentity.h" #include "rpg/conversation/conversationinteracttile.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 ); conversationSet( conversationInteractEntityInit, conversationInteractEntityUpdate, (conversationdata_t){ .entityInteract = { .entity = target } } ); source->state = ENTITY_STATE_TALKING; return; case ENTITY_TYPE_SIGN: conversationSet( conversationInteractEntityInit, conversationInteractEntityUpdate, (conversationdata_t){ .entityInteract = { .entity = target } } ); source->state = ENTITY_STATE_TALKING; 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: case TILE_LAMP: case TILE_RAIL_SLEEPER: case TILE_RAIL_TRACK: source->state = ENTITY_STATE_TALKING; conversationSet( conversationInteractTileInit, conversationInteractTileUpdate, (conversationdata_t){ .tileInteract = { .tile = tile } } ); return; default: break; } }