2022-06-20 16:39:50 +02:00
|
|
|
/*
|
|
|
|
* Terrain.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 "ConstTransitivePtr.h"
|
2022-06-28 10:05:30 +02:00
|
|
|
#include "GameConstants.h"
|
2022-06-20 16:39:50 +02:00
|
|
|
#include "JsonNode.h"
|
|
|
|
|
2022-06-22 10:41:02 +02:00
|
|
|
|
2022-06-20 16:39:50 +02:00
|
|
|
class DLL_LINKAGE Terrain
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
friend class Manager;
|
|
|
|
|
|
|
|
struct Info
|
|
|
|
{
|
|
|
|
enum class Type
|
|
|
|
{
|
|
|
|
Land, Water, Subterranean, Rock
|
|
|
|
};
|
|
|
|
|
|
|
|
int moveCost;
|
2022-06-22 10:41:02 +02:00
|
|
|
bool transitionRequired;
|
2022-06-20 16:39:50 +02:00
|
|
|
std::array<int, 3> minimapBlocked;
|
|
|
|
std::array<int, 3> minimapUnblocked;
|
|
|
|
std::string musicFilename;
|
|
|
|
std::string tilesFilename;
|
|
|
|
std::string terrainText;
|
|
|
|
std::string typeCode;
|
2022-06-22 10:41:02 +02:00
|
|
|
std::string terrainViewPatterns;
|
2022-08-09 07:54:32 +02:00
|
|
|
std::string rockTerrain;
|
|
|
|
std::string river;
|
2022-06-20 16:39:50 +02:00
|
|
|
int horseSoundId;
|
|
|
|
Type type;
|
2022-06-28 10:05:30 +02:00
|
|
|
std::vector<std::string> battleFields;
|
2022-08-09 07:54:32 +02:00
|
|
|
std::vector<Terrain> prohibitTransitions;
|
2022-06-20 16:39:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class DLL_LINKAGE Manager
|
|
|
|
{
|
|
|
|
public:
|
2022-09-07 02:20:02 +02:00
|
|
|
static const std::vector<Terrain> & terrains();
|
2022-06-20 16:39:50 +02:00
|
|
|
static const Info & getInfo(const Terrain &);
|
2022-09-07 02:20:02 +02:00
|
|
|
static int id(const Terrain &);
|
2022-06-20 16:39:50 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
static Manager & get();
|
|
|
|
Manager();
|
|
|
|
|
2022-08-09 07:54:32 +02:00
|
|
|
std::unordered_map<std::string, Info> terrainInfo;
|
2022-09-07 02:20:02 +02:00
|
|
|
std::vector<Terrain> terrainVault;
|
|
|
|
std::map<Terrain, int> terrainId;
|
2022-06-20 16:39:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*enum EETerrainType
|
|
|
|
{
|
|
|
|
ANY_TERRAIN = -3,
|
|
|
|
WRONG = -2, BORDER = -1, DIRT, SAND, GRASS, SNOW, SWAMP,
|
|
|
|
ROUGH, SUBTERRANEAN, LAVA, WATER, ROCK // ROCK is also intended to be max value.
|
|
|
|
};*/
|
|
|
|
|
|
|
|
Terrain(const std::string & _type = "");
|
|
|
|
static Terrain createTerrainTypeH3M(int tId);
|
|
|
|
static Terrain createTerrainByCode(const std::string & typeCode);
|
|
|
|
|
|
|
|
int id() const; //TODO: has to be completely removed
|
|
|
|
|
|
|
|
Terrain& operator=(const Terrain & _type);
|
|
|
|
Terrain& operator=(const std::string & _type);
|
|
|
|
|
|
|
|
DLL_LINKAGE friend bool operator==(const Terrain & l, const Terrain & r);
|
|
|
|
DLL_LINKAGE friend bool operator!=(const Terrain & l, const Terrain & r);
|
|
|
|
DLL_LINKAGE friend bool operator<(const Terrain & l, const Terrain & r);
|
|
|
|
|
|
|
|
static const Terrain ANY;
|
|
|
|
|
|
|
|
bool isLand() const;
|
|
|
|
bool isWater() const;
|
|
|
|
bool isPassable() const; //ROCK
|
|
|
|
bool isUnderground() const;
|
|
|
|
bool isNative() const;
|
2022-06-22 10:41:02 +02:00
|
|
|
bool isTransitionRequired() const;
|
|
|
|
|
2022-06-20 16:39:50 +02:00
|
|
|
|
|
|
|
operator std::string() const;
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
|
|
|
h & name;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
std::string name;
|
|
|
|
};
|
|
|
|
|
|
|
|
DLL_LINKAGE std::ostream & operator<<(std::ostream & os, const Terrain terrainType);
|