add SurroundMap.resize(...)
This commit is contained in:
@@ -4,9 +4,9 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
SurroundMap::SurroundMap(int loadDistance, int8_t maxLevel)
|
SurroundMap::SurroundMap(int maxLevelRadius, int8_t maxLevel)
|
||||||
: areaMap((loadDistance + maxLevel) * 2 + 1,
|
: areaMap((maxLevelRadius + maxLevel) * 2 + 1,
|
||||||
(loadDistance + maxLevel) * 2 + 1),
|
(maxLevelRadius + maxLevel) * 2 + 1),
|
||||||
levelCallbacks(maxLevel),
|
levelCallbacks(maxLevel),
|
||||||
maxLevel(maxLevel)
|
maxLevel(maxLevel)
|
||||||
{}
|
{}
|
||||||
@@ -43,6 +43,11 @@ void SurroundMap::upgrade(int x, int y, int8_t level) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SurroundMap::resize(int maxLevelRadius) {
|
||||||
|
areaMap.resize((maxLevelRadius + maxLevel) * 2 + 1,
|
||||||
|
(maxLevelRadius + maxLevel) * 2 + 1);
|
||||||
|
}
|
||||||
|
|
||||||
void SurroundMap::completeAt(int x, int y) {
|
void SurroundMap::completeAt(int x, int y) {
|
||||||
if (!areaMap.isInside(x - maxLevel + 1, y - maxLevel + 1) ||
|
if (!areaMap.isInside(x - maxLevel + 1, y - maxLevel + 1) ||
|
||||||
!areaMap.isInside(x + maxLevel - 1, y + maxLevel - 1)) {
|
!areaMap.isInside(x + maxLevel - 1, y + maxLevel - 1)) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ private:
|
|||||||
|
|
||||||
void upgrade(int x, int y, int8_t level);
|
void upgrade(int x, int y, int8_t level);
|
||||||
public:
|
public:
|
||||||
SurroundMap(int loadDistance, int8_t maxLevel);
|
SurroundMap(int maxLevelRadius, int8_t maxLevel);
|
||||||
|
|
||||||
/// @brief Callback called on point level increments
|
/// @brief Callback called on point level increments
|
||||||
void setLevelCallback(int8_t level, LevelCallback callback);
|
void setLevelCallback(int8_t level, LevelCallback callback);
|
||||||
@@ -38,7 +38,13 @@ public:
|
|||||||
/// @brief Set map area center
|
/// @brief Set map area center
|
||||||
void setCenter(int x, int y);
|
void setCenter(int x, int y);
|
||||||
|
|
||||||
|
void resize(int maxLevelRadius);
|
||||||
|
|
||||||
/// @brief Get level at position
|
/// @brief Get level at position
|
||||||
/// @throws std::invalid_argument - position is out of area
|
/// @throws std::invalid_argument - position is out of area
|
||||||
int8_t at(int x, int y);
|
int8_t at(int x, int y);
|
||||||
|
|
||||||
|
const util::AreaMap2D<int8_t>& getArea() const {
|
||||||
|
return areaMap;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user