engine/maps/source/MapUtils.cpp
// Get the adjacent tiles to a creature by getting the adjacent coordinates,
// mapping each coordinate to a direction, then looking up the tile and placing
// it in the result map.
Get the adjacent tiles to a creature by getting the adjacent coordinates,
mapping each coordinate to a direction, then looking up the tile and placing
it in the result map.
Get the adjacent tiles to a creature by getting the adjacent coordinates mapping each coordinate to a direction then looking up the tile and placing it in the result map .
std::map<Direction, TilePtr> MapUtils::get_adjacent_tiles_to_creature(const MapPtr& map, const CreaturePtr& creature)
{
  std::map<Direction, TilePtr> result_map;
  if (map && creature)
  {
    Coordinate creature_coord = map->get_location(creature->get_id());
    vector<Coordinate> adjacent_coords = CoordUtils::get_adjacent_map_coordinates(map->size(), creature_coord.first, creature_coord.second);
    for (const Coordinate& c : adjacent_coords)
    {
      Direction d = CoordUtils::get_direction(creature_coord, c);
      TilePtr tile = map->at(c);
      result_map.insert(make_pair(d, tile));
    }
  }
  return result_map;
}
std :: map < Direction , TilePtr > MapUtils :: get_adjacent_tiles_to_creature ( const MapPtr & map , const CreaturePtr & creature ) { std :: map < Direction , TilePtr > result_map ; if ( map && creature ) { Coordinate creature_coord = map -> get_location ( creature -> get_id ( ) ) ; vector < Coordinate > adjacent_coords = CoordUtils :: get_adjacent_map_coordinates ( map -> size ( ) , creature_coord . first , creature_coord . second ) ; for ( const Coordinate & c : adjacent_coords ) { Direction d = CoordUtils :: get_direction ( creature_coord , c ) ; TilePtr tile = map -> at ( c ) ; result_map . insert ( make_pair ( d , tile ) ) ; } } return result_map ; }
Get the adjacent tiles to a creature by getting the adjacent coordinates,
mapping each coordinate to a direction, then looking up the tile and placing
it in the result map.
Get the adjacent tiles to a creature by getting the adjacent coordinates mapping each coordinate to a direction then looking up the tile and placing it in the result map .