From 1ba9a2a42a830d09c1686e71191efe98b98d02e1 Mon Sep 17 00:00:00 2001 From: krs Date: Sun, 18 Jun 2023 12:03:12 +0300 Subject: [PATCH] calculateRangeLimitAndHighlightImages() is now separate function --- client/battle/BattleFieldController.cpp | 18 ++++++++++-------- client/battle/BattleFieldController.h | 3 +++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/client/battle/BattleFieldController.cpp b/client/battle/BattleFieldController.cpp index 507cfe11e..910cfef16 100644 --- a/client/battle/BattleFieldController.cpp +++ b/client/battle/BattleFieldController.cpp @@ -533,6 +533,14 @@ std::vector> BattleFieldController::calculateRangeHighli return output; } +void BattleFieldController::calculateRangeLimitAndHighlightImages(uint8_t distance, std::shared_ptr rangeLimitImages, std::vector & rangeLimitHexes, std::vector> & rangeLimitHexesHighligts) +{ + std::vector rangeHexes = getRangeHexes(hoveredHex, distance); + rangeLimitHexes = getRangeLimitHexes(hoveredHex, rangeHexes, distance); + std::vector> rangeLimitNeighbourDirections = getOutsideNeighbourDirectionsForLimitHexes(rangeHexes, rangeLimitHexes); + rangeLimitHexesHighligts = calculateRangeHighlightImages(rangeLimitNeighbourDirections, rangeLimitImages); +} + void BattleFieldController::flipRangedFullDamageLimitImagesIntoPositions(std::shared_ptr images) { images->getImage(hexEdgeMaskToFrameIndex[HexMasks::topRight])->verticalFlip(); @@ -576,17 +584,11 @@ void BattleFieldController::showHighlightedHexes(Canvas & canvas) { // calculate array with highlight images for ranged full damage limit auto rangedFullDamageDistance = hoveredStack->getRangedFullDamageDistance(); - std::vector rangedFullDamageHexes = getRangeHexes(hoveredHex, rangedFullDamageDistance); - rangedFullDamageLimitHexes = getRangeLimitHexes(hoveredHex, rangedFullDamageHexes, rangedFullDamageDistance); - std::vector> rangedFullDamageLimitHexesNeighbourDirections = getOutsideNeighbourDirectionsForLimitHexes(rangedFullDamageHexes, rangedFullDamageLimitHexes); - rangedFullDamageLimitHexesHighligts = calculateRangeHighlightImages(rangedFullDamageLimitHexesNeighbourDirections, rangedFullDamageLimitImages); + calculateRangeLimitAndHighlightImages(rangedFullDamageDistance, rangedFullDamageLimitImages, rangedFullDamageLimitHexes, rangedFullDamageLimitHexesHighligts); // calculate array with highlight images for shooting range limit auto shootingRangeDistance = hoveredStack->getSootingRangeDistance(); - std::vector shootingRangeHexes = getRangeHexes(hoveredHex, shootingRangeDistance); - shootingRangeLimitHexes = getRangeLimitHexes(hoveredHex, shootingRangeHexes, shootingRangeDistance); - std::vector> shootingRangeLimitHexesNeighbourDirections = getOutsideNeighbourDirectionsForLimitHexes(shootingRangeHexes, shootingRangeLimitHexes); - shootingRangeLimitHexesHighligts = calculateRangeHighlightImages(shootingRangeLimitHexesNeighbourDirections, shootingRangeLimitImages); + calculateRangeLimitAndHighlightImages(shootingRangeDistance, shootingRangeLimitImages, shootingRangeLimitHexes, shootingRangeLimitHexesHighligts); } auto const & hoveredMouseHexes = owner.actionsController->currentActionSpellcasting(getHoveredHex()) ? hoveredSpellHexes : hoveredMoveHexes; diff --git a/client/battle/BattleFieldController.h b/client/battle/BattleFieldController.h index 1eac44473..5890ec0e5 100644 --- a/client/battle/BattleFieldController.h +++ b/client/battle/BattleFieldController.h @@ -74,6 +74,9 @@ class BattleFieldController : public CIntObject /// based on this mask the corresponding image is selected std::vector> calculateRangeHighlightImages(std::vector> hexesNeighbourDirections, std::shared_ptr limitImages); + /// calculates all hexes for a range limit and what images to be shown as highlight for each of the hexes + void calculateRangeLimitAndHighlightImages(uint8_t distance, std::shared_ptr rangedFullDamageLimitImages, std::vector & rangedFullDamageLimitHexes, std::vector> & rangedFullDamageLimitHexesHighligts); + /// to reduce the number of source images used, some images will be used as flipped versions of preloaded ones void flipRangedFullDamageLimitImagesIntoPositions(std::shared_ptr images);