/* * 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" #include "CMapGenerator.h" #include "float3.h" #include "../int3.h" class CMapGenerator; class CTileInfo; class int3; class CGObjectInstance; namespace ETemplateZoneType { enum ETemplateZoneType { PLAYER_START, CPU_START, TREASURE, JUNCTION }; } class DLL_LINKAGE CTileInfo { 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; }; /// 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 getOwner() const; void setOwner(boost::optional 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 & getTownTypes() const; /// Default: all void setTownTypes(const std::set & value); std::set getDefaultTownTypes() const; bool getMatchTerrainToTown() const; /// Default: true void setMatchTerrainToTown(bool value); const std::set & getTerrainTypes() const; /// Default: all void setTerrainTypes(const std::set & value); std::set getDefaultTerrainTypes() const; boost::optional getTerrainTypeLikeZone() const; void setTerrainTypeLikeZone(boost::optional value); boost::optional getTownTypeLikeZone() const; void setTownTypeLikeZone(boost::optional value); float3 getCenter() const; void setCenter(const float3 &f); int3 getPos() const; void setPos(const int3 &pos); void addTile (const int3 &pos); std::set getTileInfo () const; bool fill(CMapGenerator* gen); void createConnections(CMapGenerator* gen); void createBorder(CMapGenerator* gen); bool crunchPath (CMapGenerator* gen, int3 &src, int3 &dst, TRmgTemplateZoneId zone); void addConnection(TRmgTemplateZoneId otherZone); std::vector getConnections() const; private: //template info TRmgTemplateZoneId id; ETemplateZoneType::ETemplateZoneType type; int size; boost::optional owner; CTownInfo playerTowns, neutralTowns; bool townsAreSameType; std::set townTypes; bool matchTerrainToTown; std::set terrainTypes; boost::optional terrainTypeLikeZone, townTypeLikeZone; //content info std::vector shape; //TODO: remove std::vector objects; //placement info int3 pos; float3 center; std::set tileinfo; //irregular area assined to zone std::vector connections; //list of adjacent zones std::map alreadyConnected; //TODO: allow multiple connections between two zones? bool pointIsIn(int x, int y); bool findPlaceForObject(CMapGenerator* gen, CGObjectInstance* obj, si32 min_dist, int3 &pos); void checkAndPlaceObject(CMapGenerator* gen, CGObjectInstance* object, const int3 &pos); void placeObject(CMapGenerator* gen, CGObjectInstance* object, const int3 &pos); bool guardObject(CMapGenerator* gen, CGObjectInstance* object, si32 str); };