engine/maps/source/MapUtils.cpp
// Get a map of adjacent creatures to the current creature on the current
// map, keyed by their direction from the creature.
Get a map of adjacent creatures to the current creature on the current
map, keyed by their direction from the creature.
Get a map of adjacent creatures to the current creature on the current map keyed by their direction from the creature .
CreatureDirectionMap MapUtils::get_adjacent_creatures(const MapPtr& map, const CreaturePtr& creature)
{
  CreatureDirectionMap adjacent_creatures;
  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);
      CreaturePtr creature;
      if (tile && tile->has_creature())
      {
        creature = tile->get_creature();
        adjacent_creatures.insert(make_pair(d, creature));
      }
    }
  }
  return adjacent_creatures;
}
CreatureDirectionMap MapUtils :: get_adjacent_creatures ( const MapPtr & map , const CreaturePtr & creature ) { CreatureDirectionMap adjacent_creatures ; 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 ) ; CreaturePtr creature ; if ( tile && tile -> has_creature ( ) ) { creature = tile -> get_creature ( ) ; adjacent_creatures . insert ( make_pair ( d , creature ) ) ; } } } return adjacent_creatures ; }
Get a map of adjacent creatures to the current creature on the current
map, keyed by their direction from the creature.
Get a map of adjacent creatures to the current creature on the current map keyed by their direction from the creature .