mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Few tweaks for boat placement to keep distance between it and other objects, especially guards.
This commit is contained in:
@ -212,8 +212,12 @@ bool WaterProxy::placeBoat(Zone & land, const Lake & lake, RouteInfo & info)
|
||||
auto waterAvailable = zone.areaPossible() + zone.freePaths();
|
||||
rmg::Area coast = lake.neighbourZones.at(land.getId()); //having land tiles
|
||||
coast.intersect(land.areaPossible() + land.freePaths()); //having only available land tiles
|
||||
auto boardingPositions = coast.getSubarea([&waterAvailable](const int3 & tile) //tiles where boarding is possible
|
||||
auto boardingPositions = coast.getSubarea([&waterAvailable, this](const int3 & tile) //tiles where boarding is possible
|
||||
{
|
||||
//We don't want place boat right to any land object, especiallly the zone guard
|
||||
if (map.getTile(tile).getNearestObjectDistance() <= 3)
|
||||
return false;
|
||||
|
||||
rmg::Area a({tile});
|
||||
a = a.getBorderOutside();
|
||||
a.intersect(waterAvailable);
|
||||
@ -234,7 +238,7 @@ bool WaterProxy::placeBoat(Zone & land, const Lake & lake, RouteInfo & info)
|
||||
}
|
||||
|
||||
//try to place boat at water, create paths on water and land
|
||||
auto path = manager->placeAndConnectObject(shipPositions, rmgObject, 2, false, true, ObjectManager::OptimizeType::NONE);
|
||||
auto path = manager->placeAndConnectObject(shipPositions, rmgObject, 4, false, true, ObjectManager::OptimizeType::NONE);
|
||||
auto landPath = land.searchPath(boardingPosition, false);
|
||||
if(!path.valid() || !landPath.valid())
|
||||
{
|
||||
@ -250,6 +254,7 @@ bool WaterProxy::placeBoat(Zone & land, const Lake & lake, RouteInfo & info)
|
||||
zone.connectPath(path);
|
||||
land.connectPath(landPath);
|
||||
manager->placeObject(rmgObject, false, true);
|
||||
land.getModificator<ObjectManager>()->updateDistances(rmgObject); //Keep land objects away from the boat
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user