mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-19 21:10:12 +02:00
Place Monoliths at max distance in Junction zone
This commit is contained in:
parent
bd5361a108
commit
985a2682ae
@ -15,6 +15,7 @@
|
|||||||
#include "TileInfo.h"
|
#include "TileInfo.h"
|
||||||
#include "CMapGenerator.h"
|
#include "CMapGenerator.h"
|
||||||
#include "RmgPath.h"
|
#include "RmgPath.h"
|
||||||
|
#include "modificators/ObjectManager.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@ -307,6 +308,16 @@ void Zone::fractalize()
|
|||||||
tilesToIgnore.clear();
|
tilesToIgnore.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Handle special case - place Monoliths at the edge of a zone
|
||||||
|
auto objectManager = getModificator<ObjectManager>();
|
||||||
|
if (objectManager)
|
||||||
|
{
|
||||||
|
objectManager->createMonoliths();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Lock lock(areaMutex);
|
Lock lock(areaMutex);
|
||||||
//cut straight paths towards the center. A* is too slow for that.
|
//cut straight paths towards the center. A* is too slow for that.
|
||||||
auto areas = connectedAreas(clearedTiles, false);
|
auto areas = connectedAreas(clearedTiles, false);
|
||||||
|
@ -356,6 +356,41 @@ rmg::Path ObjectManager::placeAndConnectObject(const rmg::Area & searchArea, rmg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ObjectManager::createMonoliths()
|
||||||
|
{
|
||||||
|
// Special case for Junction zone only
|
||||||
|
logGlobal->trace("Creating Monoliths");
|
||||||
|
for(const auto & objInfo : requiredObjects)
|
||||||
|
{
|
||||||
|
if (objInfo.obj->ID != Obj::MONOLITH_TWO_WAY)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
rmg::Object rmgObject(*objInfo.obj);
|
||||||
|
rmgObject.setTemplate(zone.getTerrainType(), zone.getRand());
|
||||||
|
bool guarded = addGuard(rmgObject, objInfo.guardStrength, true);
|
||||||
|
|
||||||
|
Zone::Lock lock(zone.areaMutex);
|
||||||
|
auto path = placeAndConnectObject(zone.areaPossible(), rmgObject, 3, guarded, false, OptimizeType::DISTANCE);
|
||||||
|
|
||||||
|
if(!path.valid())
|
||||||
|
{
|
||||||
|
logGlobal->error("Failed to fill zone %d due to lack of space", zone.getId());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
zone.connectPath(path);
|
||||||
|
placeObject(rmgObject, guarded, true, objInfo.createRoad);
|
||||||
|
}
|
||||||
|
|
||||||
|
vstd::erase_if(requiredObjects, [](const auto & objInfo)
|
||||||
|
{
|
||||||
|
return objInfo.obj->ID == Obj::MONOLITH_TWO_WAY;
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ObjectManager::createRequiredObjects()
|
bool ObjectManager::createRequiredObjects()
|
||||||
{
|
{
|
||||||
logGlobal->trace("Creating required objects");
|
logGlobal->trace("Creating required objects");
|
||||||
|
@ -62,6 +62,7 @@ public:
|
|||||||
void addCloseObject(const RequiredObjectInfo & info);
|
void addCloseObject(const RequiredObjectInfo & info);
|
||||||
void addNearbyObject(const RequiredObjectInfo & info);
|
void addNearbyObject(const RequiredObjectInfo & info);
|
||||||
|
|
||||||
|
bool ObjectManager::createMonoliths();
|
||||||
bool createRequiredObjects();
|
bool createRequiredObjects();
|
||||||
|
|
||||||
int3 findPlaceForObject(const rmg::Area & searchArea, rmg::Object & obj, si32 min_dist, OptimizeType optimizer) const;
|
int3 findPlaceForObject(const rmg::Area & searchArea, rmg::Object & obj, si32 min_dist, OptimizeType optimizer) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user