2013-08-17 15:46:48 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CRmgTemplateZone.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 "../GameConstants.h"
|
2014-05-22 20:25:17 +03:00
|
|
|
#include "CMapGenerator.h"
|
2014-05-24 13:42:06 +03:00
|
|
|
#include "float3.h"
|
2014-05-30 17:50:06 +03:00
|
|
|
#include "../int3.h"
|
2014-05-22 20:25:17 +03:00
|
|
|
|
2014-05-30 17:50:06 +03:00
|
|
|
class CMapGenerator;
|
|
|
|
class CTileInfo;
|
|
|
|
class int3;
|
|
|
|
class CGObjectInstance;
|
2013-08-17 15:46:48 +03:00
|
|
|
|
|
|
|
namespace ETemplateZoneType
|
|
|
|
{
|
2014-05-30 17:50:06 +03:00
|
|
|
enum ETemplateZoneType
|
|
|
|
{
|
|
|
|
PLAYER_START,
|
|
|
|
CPU_START,
|
|
|
|
TREASURE,
|
|
|
|
JUNCTION
|
|
|
|
};
|
|
|
|
}
|
|
|
|
class DLL_LINKAGE CTileInfo
|
2013-08-17 15:46:48 +03:00
|
|
|
{
|
2014-05-30 17:50:06 +03:00
|
|
|
public:
|
|
|
|
|
|
|
|
CTileInfo();
|
|
|
|
|
|
|
|
int getNearestObjectDistance() const;
|
|
|
|
void setNearestObjectDistance(int value);
|
|
|
|
bool isBlocked() const;
|
|
|
|
bool shouldBeBlocked() const;
|
|
|
|
bool isPossible() const;
|
|
|
|
bool isFree() const;
|
|
|
|
void setOccupied(ETileType::ETileType value);
|
|
|
|
ETerrainType getTerrainType() const;
|
|
|
|
void setTerrainType(ETerrainType value);
|
|
|
|
|
|
|
|
private:
|
|
|
|
int nearestObjectDistance;
|
|
|
|
ETileType::ETileType occupied;
|
|
|
|
ETerrainType terrain;
|
2013-08-17 15:46:48 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/// The CRmgTemplateZone describes a zone in a template.
|
|
|
|
class DLL_LINKAGE CRmgTemplateZone
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
class DLL_LINKAGE CTownInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CTownInfo();
|
|
|
|
|
|
|
|
int getTownCount() const; /// Default: 0
|
|
|
|
void setTownCount(int value);
|
|
|
|
int getCastleCount() const; /// Default: 0
|
|
|
|
void setCastleCount(int value);
|
|
|
|
int getTownDensity() const; /// Default: 0
|
|
|
|
void setTownDensity(int value);
|
|
|
|
int getCastleDensity() const; /// Default: 0
|
|
|
|
void setCastleDensity(int value);
|
|
|
|
|
|
|
|
private:
|
|
|
|
int townCount, castleCount, townDensity, castleDensity;
|
|
|
|
};
|
|
|
|
|
|
|
|
CRmgTemplateZone();
|
|
|
|
|
|
|
|
TRmgTemplateZoneId getId() const; /// Default: 0
|
|
|
|
void setId(TRmgTemplateZoneId value);
|
|
|
|
ETemplateZoneType::ETemplateZoneType getType() const; /// Default: ETemplateZoneType::PLAYER_START
|
|
|
|
void setType(ETemplateZoneType::ETemplateZoneType value);
|
|
|
|
int getSize() const; /// Default: 1
|
|
|
|
void setSize(int value);
|
|
|
|
boost::optional<int> getOwner() const;
|
|
|
|
void setOwner(boost::optional<int> value);
|
|
|
|
const CTownInfo & getPlayerTowns() const;
|
|
|
|
void setPlayerTowns(const CTownInfo & value);
|
|
|
|
const CTownInfo & getNeutralTowns() const;
|
|
|
|
void setNeutralTowns(const CTownInfo & value);
|
|
|
|
bool getTownsAreSameType() const; /// Default: false
|
|
|
|
void setTownsAreSameType(bool value);
|
|
|
|
const std::set<TFaction> & getTownTypes() const; /// Default: all
|
|
|
|
void setTownTypes(const std::set<TFaction> & value);
|
|
|
|
std::set<TFaction> getDefaultTownTypes() const;
|
|
|
|
bool getMatchTerrainToTown() const; /// Default: true
|
|
|
|
void setMatchTerrainToTown(bool value);
|
|
|
|
const std::set<ETerrainType> & getTerrainTypes() const; /// Default: all
|
|
|
|
void setTerrainTypes(const std::set<ETerrainType> & value);
|
|
|
|
std::set<ETerrainType> getDefaultTerrainTypes() const;
|
|
|
|
boost::optional<TRmgTemplateZoneId> getTerrainTypeLikeZone() const;
|
|
|
|
void setTerrainTypeLikeZone(boost::optional<TRmgTemplateZoneId> value);
|
|
|
|
boost::optional<TRmgTemplateZoneId> getTownTypeLikeZone() const;
|
|
|
|
void setTownTypeLikeZone(boost::optional<TRmgTemplateZoneId> value);
|
2014-05-24 13:42:06 +03:00
|
|
|
|
|
|
|
float3 getCenter() const;
|
2014-05-30 17:50:06 +03:00
|
|
|
void setCenter(const float3 &f);
|
|
|
|
int3 getPos() const;
|
2014-05-25 12:02:15 +03:00
|
|
|
void setPos(const int3 &pos);
|
2014-05-24 13:42:06 +03:00
|
|
|
|
2014-05-25 12:02:15 +03:00
|
|
|
void addTile (const int3 &pos);
|
2014-05-31 11:56:14 +03:00
|
|
|
std::set<int3> getTileInfo () const;
|
|
|
|
|
2014-05-22 20:25:17 +03:00
|
|
|
bool fill(CMapGenerator* gen);
|
2014-05-31 11:56:14 +03:00
|
|
|
void createConnections(CMapGenerator* gen);
|
2014-05-30 22:23:41 +03:00
|
|
|
void createBorder(CMapGenerator* gen);
|
2014-05-31 11:56:14 +03:00
|
|
|
bool crunchPath (CMapGenerator* gen, int3 &src, int3 &dst, TRmgTemplateZoneId zone);
|
2013-08-17 15:46:48 +03:00
|
|
|
|
2014-05-24 13:42:06 +03:00
|
|
|
void addConnection(TRmgTemplateZoneId otherZone);
|
|
|
|
std::vector<TRmgTemplateZoneId> getConnections() const;
|
|
|
|
|
2013-08-17 15:46:48 +03:00
|
|
|
private:
|
2014-05-24 13:42:06 +03:00
|
|
|
//template info
|
2013-08-17 15:46:48 +03:00
|
|
|
TRmgTemplateZoneId id;
|
|
|
|
ETemplateZoneType::ETemplateZoneType type;
|
|
|
|
int size;
|
|
|
|
boost::optional<int> owner;
|
|
|
|
CTownInfo playerTowns, neutralTowns;
|
|
|
|
bool townsAreSameType;
|
|
|
|
std::set<TFaction> townTypes;
|
|
|
|
bool matchTerrainToTown;
|
|
|
|
std::set<ETerrainType> terrainTypes;
|
|
|
|
boost::optional<TRmgTemplateZoneId> terrainTypeLikeZone, townTypeLikeZone;
|
2014-05-22 20:25:17 +03:00
|
|
|
|
2014-05-24 13:42:06 +03:00
|
|
|
//content info
|
|
|
|
std::vector<int3> shape; //TODO: remove
|
2014-05-22 20:25:17 +03:00
|
|
|
std::vector<CGObjectInstance*> objects;
|
|
|
|
|
2014-05-24 13:42:06 +03:00
|
|
|
//placement info
|
|
|
|
int3 pos;
|
|
|
|
float3 center;
|
2014-05-30 22:23:41 +03:00
|
|
|
std::set<int3> tileinfo; //irregular area assined to zone
|
2014-05-24 13:42:06 +03:00
|
|
|
std::vector<TRmgTemplateZoneId> connections; //list of adjacent zones
|
|
|
|
std::map<TRmgTemplateZoneId, bool> alreadyConnected; //TODO: allow multiple connections between two zones?
|
|
|
|
|
2014-05-22 20:25:17 +03:00
|
|
|
bool pointIsIn(int x, int y);
|
|
|
|
bool findPlaceForObject(CMapGenerator* gen, CGObjectInstance* obj, si32 min_dist, int3 &pos);
|
2014-05-23 18:12:31 +03:00
|
|
|
void checkAndPlaceObject(CMapGenerator* gen, CGObjectInstance* object, const int3 &pos);
|
2014-05-22 20:25:17 +03:00
|
|
|
void placeObject(CMapGenerator* gen, CGObjectInstance* object, const int3 &pos);
|
|
|
|
bool guardObject(CMapGenerator* gen, CGObjectInstance* object, si32 str);
|
2013-08-17 15:46:48 +03:00
|
|
|
};
|