1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-18 17:40:48 +02:00
vcmi/lib/mapping/CDrawRoadsOperation.h
Nordsoft91 5151da59a7 New terrain support - part 1 (#755)
Initial support of new terrains
2022-08-29 08:53:35 +03:00

59 lines
1.4 KiB
C++

/*
* CDrawRoadsOperation.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 "../CRandomGenerator.h"
#include "CMapEditManager.h"
struct TerrainTile;
class CDrawRoadsOperation : public CMapOperation
{
public:
CDrawRoadsOperation(CMap * map, const CTerrainSelection & terrainSel, const std::string & roadType, CRandomGenerator * gen);
void execute() override;
void undo() override;
void redo() override;
std::string getLabel() const override;
private:
struct RoadPattern
{
std::string data[9];
std::pair<int, int> roadMapping, riverMapping;
bool hasHFlip, hasVFlip;
};
struct ValidationResult
{
ValidationResult(bool result): result(result), flip(0){};
bool result;
int flip;
};
static const std::vector<RoadPattern> patterns;
void flipPattern(RoadPattern & pattern, int flip) const;
void updateTiles(std::set<int3> & invalidated);
ValidationResult validateTile(const RoadPattern & pattern, const int3 & pos);
void updateTile(TerrainTile & tile, const RoadPattern & pattern, const int flip);
bool canApplyPattern(const RoadPattern & pattern) const;
bool needUpdateTile(const TerrainTile & tile) const;
bool tileHasSomething(const int3 & pos) const;
CTerrainSelection terrainSel;
std::string roadType;
CRandomGenerator * gen;
};