2022-08-09 07:54:32 +02:00
|
|
|
/*
|
|
|
|
* RmgMap.cpp, 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 "../int3.h"
|
|
|
|
#include "../GameConstants.h"
|
2023-05-19 20:30:15 +02:00
|
|
|
#include "threadpool/MapProxy.h"
|
2022-08-09 07:54:32 +02:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2023-02-24 22:38:12 +02:00
|
|
|
class CMap;
|
2022-08-09 07:54:32 +02:00
|
|
|
class CMapEditManager;
|
|
|
|
class TileInfo;
|
|
|
|
class CMapGenOptions;
|
|
|
|
class Zone;
|
|
|
|
class CMapGenerator;
|
2023-05-19 20:30:15 +02:00
|
|
|
class MapProxy;
|
|
|
|
class playerInfo;
|
2022-08-09 07:54:32 +02:00
|
|
|
|
2024-06-01 17:28:17 +02:00
|
|
|
namespace vstd
|
|
|
|
{
|
|
|
|
class RNG;
|
|
|
|
}
|
|
|
|
|
2022-08-09 07:54:32 +02:00
|
|
|
class RmgMap
|
|
|
|
{
|
|
|
|
public:
|
2023-12-22 17:41:30 +02:00
|
|
|
int getDecorationsPercentage() const;
|
|
|
|
|
2022-08-09 07:54:32 +02:00
|
|
|
mutable std::unique_ptr<CMap> mapInstance;
|
2023-05-19 20:30:15 +02:00
|
|
|
std::shared_ptr<MapProxy> getMapProxy() const;
|
|
|
|
CMap & getMap(const CMapGenerator *) const; //limited access
|
2022-08-09 07:54:32 +02:00
|
|
|
|
2024-01-01 16:37:48 +02:00
|
|
|
RmgMap(const CMapGenOptions& mapGenOptions, IGameCallback * cb);
|
2023-02-11 18:05:02 +02:00
|
|
|
~RmgMap() = default;
|
|
|
|
|
2022-08-09 07:54:32 +02:00
|
|
|
CMapEditManager* getEditManager() const;
|
|
|
|
const CMapGenOptions& getMapGenOptions() const;
|
2023-02-11 18:05:02 +02:00
|
|
|
|
|
|
|
void foreach_neighbour(const int3 & pos, const std::function<void(int3 & pos)> & foo) const;
|
|
|
|
void foreachDirectNeighbour(const int3 & pos, const std::function<void(int3 & pos)> & foo) const;
|
|
|
|
void foreachDiagonalNeighbour(const int3 & pos, const std::function<void(int3 & pos)> & foo) const;
|
|
|
|
|
2022-08-09 07:54:32 +02:00
|
|
|
bool isBlocked(const int3 &tile) const;
|
|
|
|
bool shouldBeBlocked(const int3 &tile) const;
|
|
|
|
bool isPossible(const int3 &tile) const;
|
|
|
|
bool isFree(const int3 &tile) const;
|
|
|
|
bool isUsed(const int3 &tile) const;
|
|
|
|
bool isRoad(const int3 &tile) const;
|
|
|
|
bool isOnMap(const int3 & tile) const;
|
2023-05-19 20:30:15 +02:00
|
|
|
|
|
|
|
int levels() const;
|
|
|
|
int width() const;
|
|
|
|
int height() const;
|
|
|
|
PlayerInfo & getPlayer(int playerId);
|
2022-08-09 07:54:32 +02:00
|
|
|
|
2023-08-19 21:35:44 +02:00
|
|
|
void setOccupied(const int3 &tile, ETileType state);
|
2022-09-29 11:44:46 +02:00
|
|
|
void setRoad(const int3 &tile, RoadId roadType);
|
2022-08-09 07:54:32 +02:00
|
|
|
|
2023-05-19 20:30:15 +02:00
|
|
|
TileInfo getTileInfo(const int3 & tile) const;
|
|
|
|
TerrainTile & getTile(const int3 & tile) const;
|
2022-08-09 07:54:32 +02:00
|
|
|
|
|
|
|
float getNearestObjectDistance(const int3 &tile) const;
|
2023-12-13 23:10:39 +02:00
|
|
|
void setNearestObjectDistance(const int3 &tile, float value);
|
2022-08-09 07:54:32 +02:00
|
|
|
|
|
|
|
TRmgTemplateZoneId getZoneID(const int3& tile) const;
|
|
|
|
void setZoneID(const int3& tile, TRmgTemplateZoneId zid);
|
|
|
|
|
|
|
|
using Zones = std::map<TRmgTemplateZoneId, std::shared_ptr<Zone>>;
|
2023-04-29 11:46:03 +02:00
|
|
|
using ZonePair = std::pair<TRmgTemplateZoneId, std::shared_ptr<Zone>>;
|
|
|
|
using ZoneVector = std::vector<ZonePair>;
|
2022-08-09 07:54:32 +02:00
|
|
|
|
|
|
|
Zones & getZones();
|
2024-03-24 19:04:33 +02:00
|
|
|
Zones getZonesOnLevel(int level) const;
|
2022-08-09 07:54:32 +02:00
|
|
|
|
2023-04-09 17:26:32 +02:00
|
|
|
void registerZone(FactionID faction);
|
|
|
|
ui32 getZoneCount(FactionID faction);
|
2022-08-09 07:54:32 +02:00
|
|
|
ui32 getTotalZoneCount() const;
|
2024-06-01 17:28:17 +02:00
|
|
|
void initTiles(CMapGenerator & generator, vstd::RNG & rand);
|
2022-08-09 07:54:32 +02:00
|
|
|
void addModificators();
|
2023-02-11 18:05:02 +02:00
|
|
|
|
|
|
|
bool isAllowedSpell(const SpellID & sid) const;
|
|
|
|
|
2022-08-09 07:54:32 +02:00
|
|
|
void dump(bool zoneId) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void assertOnMap(const int3 &tile) const; //throws
|
2023-04-17 23:11:16 +02:00
|
|
|
|
2022-08-09 07:54:32 +02:00
|
|
|
private:
|
2023-05-19 20:30:15 +02:00
|
|
|
|
|
|
|
std::shared_ptr<MapProxy> mapProxy;
|
|
|
|
|
2022-08-09 07:54:32 +02:00
|
|
|
Zones zones;
|
2023-04-09 17:26:32 +02:00
|
|
|
std::map<FactionID, ui32> zonesPerFaction;
|
2022-08-09 07:54:32 +02:00
|
|
|
ui32 zonesTotal; //zones that have their main town only
|
|
|
|
const CMapGenOptions& mapGenOptions;
|
|
|
|
boost::multi_array<TileInfo, 3> tiles; //[x][y][z]
|
|
|
|
boost::multi_array<TRmgTemplateZoneId, 3> zoneColouring; //[x][y][z]
|
|
|
|
};
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|