engine/maps/source/MapUtils.cpp
// If there's a creature adjacent to the current one, but the next
// spot over is free, the creature can squeeze by the adjacent one
// and into the next tile.
If there's a creature adjacent to the current one, but the next
spot over is free, the creature can squeeze by the adjacent one
and into the next tile.
If there ' s a creature adjacent to the current one but the next spot over is free the creature can squeeze by the adjacent one and into the next tile .
bool MapUtils::squeeze_by(MapPtr map, CreaturePtr creature, const Coordinate& new_coords, const Direction d)
{
  bool movement_success = false;
  Coordinate potential_squeeze_coords = CoordUtils::get_new_coordinate(new_coords, d, 1);
  TilePtr potential_squeeze_tile = map->at(potential_squeeze_coords);
  if (creature != nullptr)
  {
    ostringstream ss;
    ss << "Creature " << creature->get_id() << " is squeezing by " << new_coords.first << "," << new_coords.second;
    Log::instance().debug(ss.str());
    if (potential_squeeze_tile != nullptr && MapUtils::is_tile_available_for_creature(creature, potential_squeeze_tile))
    {
      MapUtils::remove_creature(map, creature);
      MapUtils::add_or_update_location(map, creature, potential_squeeze_coords);
      movement_success = true;
    }
  }
  return movement_success;
}
bool MapUtils :: squeeze_by ( MapPtr map , CreaturePtr creature , const Coordinate & new_coords , const Direction d ) { bool movement_success = false ; Coordinate potential_squeeze_coords = CoordUtils :: get_new_coordinate ( new_coords , d , 1 ) ; TilePtr potential_squeeze_tile = map -> at ( potential_squeeze_coords ) ; if ( creature != nullptr ) { ostringstream ss ; ss << " " << creature -> get_id ( ) << " " << new_coords . first << " " << new_coords . second ; Log :: instance ( ) . debug ( ss . str ( ) ) ; if ( potential_squeeze_tile != nullptr && MapUtils :: is_tile_available_for_creature ( creature , potential_squeeze_tile ) ) { MapUtils :: remove_creature ( map , creature ) ; MapUtils :: add_or_update_location ( map , creature , potential_squeeze_coords ) ; movement_success = true ; } } return movement_success ; }
If there's a creature adjacent to the current one, but the next
spot over is free, the creature can squeeze by the adjacent one
and into the next tile.
If there ' s a creature adjacent to the current one but the next spot over is free the creature can squeeze by the adjacent one and into the next tile .