2023-05-19 20:30:15 +02:00
|
|
|
/*
|
|
|
|
* RockFiller.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "StdInc.h"
|
|
|
|
#include "RockFiller.h"
|
|
|
|
#include "RockPlacer.h"
|
|
|
|
#include "TreasurePlacer.h"
|
|
|
|
#include "ObjectManager.h"
|
|
|
|
#include "RiverPlacer.h"
|
2024-05-01 09:16:10 +02:00
|
|
|
#include "RoadPlacer.h"
|
2023-05-20 11:45:08 +02:00
|
|
|
#include "../RmgMap.h"
|
|
|
|
#include "../CMapGenerator.h"
|
|
|
|
#include "../Functions.h"
|
|
|
|
#include "../../TerrainHandler.h"
|
|
|
|
#include "../../CRandomGenerator.h"
|
|
|
|
#include "../lib/mapping/CMapEditManager.h"
|
|
|
|
#include "../TileInfo.h"
|
|
|
|
#include "../threadpool/MapProxy.h"
|
2023-05-19 20:30:15 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class TileInfo;
|
|
|
|
|
|
|
|
void RockFiller::process()
|
|
|
|
{
|
2023-05-20 13:15:46 +02:00
|
|
|
processMap();
|
2023-05-19 20:30:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void RockFiller::processMap()
|
|
|
|
{
|
|
|
|
//Merge all areas
|
2024-05-01 09:16:10 +02:00
|
|
|
for(auto & z : map.getZonesOnLevel(1))
|
2023-05-19 20:30:15 +02:00
|
|
|
{
|
2023-05-20 11:46:32 +02:00
|
|
|
auto zone = z.second;
|
|
|
|
if(auto * m = zone->getModificator<RockPlacer>())
|
2023-05-19 20:30:15 +02:00
|
|
|
{
|
|
|
|
auto tiles = m->rockArea.getTilesVector();
|
2023-05-20 11:46:32 +02:00
|
|
|
mapProxy->drawTerrain(zone->getRand(), tiles, m->rockTerrain);
|
2023-05-19 20:30:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-01 09:16:10 +02:00
|
|
|
for(auto & z : map.getZonesOnLevel(1))
|
2023-05-19 20:30:15 +02:00
|
|
|
{
|
2023-05-20 11:46:32 +02:00
|
|
|
auto zone = z.second;
|
|
|
|
if(auto * m = zone->getModificator<RockPlacer>())
|
2023-05-19 20:30:15 +02:00
|
|
|
{
|
|
|
|
//Now make sure all accessible tiles have no additional rock on them
|
|
|
|
auto tiles = m->accessibleArea.getTilesVector();
|
2023-05-20 11:46:32 +02:00
|
|
|
mapProxy->drawTerrain(zone->getRand(), tiles, zone->getTerrainType());
|
2023-05-19 20:30:15 +02:00
|
|
|
|
|
|
|
m->postProcess();
|
|
|
|
}
|
2024-05-01 09:16:10 +02:00
|
|
|
|
|
|
|
// Draw roads after rock is placed
|
|
|
|
if(auto * rp = zone->getModificator<RoadPlacer>())
|
|
|
|
{
|
|
|
|
rp->postProcess();
|
|
|
|
}
|
2023-05-19 20:30:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RockFiller::init()
|
|
|
|
{
|
2023-05-20 07:23:00 +02:00
|
|
|
DEPENDENCY_ALL(RockPlacer);
|
2023-05-19 20:30:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
char RockFiller::dump(const int3 & t)
|
2024-03-27 09:03:19 +02:00
|
|
|
{
|
2023-05-19 20:30:15 +02:00
|
|
|
if(!map.getTile(t).terType->isPassable())
|
|
|
|
{
|
2024-03-27 07:16:48 +02:00
|
|
|
return zone.area()->contains(t) ? 'R' : 'E';
|
2023-05-19 20:30:15 +02:00
|
|
|
}
|
|
|
|
return Modificator::dump(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|