2022-08-09 07:54:32 +02:00
|
|
|
/*
|
|
|
|
* ObstaclePlacer.h, 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "Zone.h"
|
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2022-09-17 15:43:59 +02:00
|
|
|
class CMap;
|
|
|
|
class CMapEditManager;
|
|
|
|
class RiverPlacer;
|
|
|
|
class ObjectManager;
|
2022-07-26 15:07:42 +02:00
|
|
|
|
2022-09-17 15:43:59 +02:00
|
|
|
class DLL_LINKAGE ObstacleProxy
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ObstacleProxy() = default;
|
|
|
|
virtual ~ObstacleProxy() = default;
|
|
|
|
|
|
|
|
rmg::Area blockedArea;
|
|
|
|
|
2022-09-25 09:33:56 +02:00
|
|
|
void collectPossibleObstacles(TTerrainId terrain);
|
2022-09-17 15:43:59 +02:00
|
|
|
|
|
|
|
void placeObstacles(CMap * map, CRandomGenerator & rand);
|
|
|
|
|
|
|
|
virtual std::pair<bool, bool> verifyCoverage(const int3 & t) const;
|
|
|
|
|
|
|
|
virtual void placeObject(rmg::Object & object, std::set<CGObjectInstance*> & instances);
|
|
|
|
|
|
|
|
virtual void postProcess(const rmg::Object & object);
|
|
|
|
|
|
|
|
virtual bool isProhibited(const rmg::Area & objArea) const;
|
|
|
|
|
|
|
|
virtual void finalInsertion(CMapEditManager * manager, std::set<CGObjectInstance*> & instances);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int getWeightedObjects(const int3 & tile, const CMap * map, CRandomGenerator & rand, std::list<rmg::Object> & allObjects, std::vector<std::pair<rmg::Object*, int3>> & weightedObjects);
|
|
|
|
|
|
|
|
typedef std::vector<std::shared_ptr<const ObjectTemplate>> ObstacleVector;
|
|
|
|
std::map<int, ObstacleVector> obstaclesBySize;
|
|
|
|
typedef std::pair<int, ObstacleVector> ObstaclePair;
|
|
|
|
std::vector<ObstaclePair> possibleObstacles;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ObstaclePlacer: public Modificator, public ObstacleProxy
|
2022-08-09 07:54:32 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
MODIFICATOR(ObstaclePlacer);
|
|
|
|
|
|
|
|
void process() override;
|
|
|
|
void init() override;
|
2022-09-17 15:43:59 +02:00
|
|
|
|
|
|
|
std::pair<bool, bool> verifyCoverage(const int3 & t) const override;
|
|
|
|
|
|
|
|
void placeObject(rmg::Object & object, std::set<CGObjectInstance*> & instances) override;
|
|
|
|
|
|
|
|
void postProcess(const rmg::Object & object) override;
|
|
|
|
|
|
|
|
bool isProhibited(const rmg::Area & objArea) const override;
|
|
|
|
|
|
|
|
void finalInsertion(CMapEditManager * manager, std::set<CGObjectInstance*> & instances) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
rmg::Area prohibitedArea;
|
|
|
|
RiverPlacer * riverManager;
|
|
|
|
ObjectManager * manager;
|
2022-08-09 07:54:32 +02:00
|
|
|
};
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|