Implement builder road construction with hex-edge auto-connection, winding rendering, and speed bonus

This commit is contained in:
bart
2026-11-08 21:52:34 +01:00
parent 4b237872eb
commit dfefb2d7fb
15 changed files with 620 additions and 16 deletions
+11 -3
View File
@@ -2,6 +2,7 @@
#include "unitconfig.h"
#include "pathfinder.h"
#include "yamlparser.h"
#include "gamemanager.h"
#include <QDebug>
#include <cmath>
#include <algorithm>
@@ -300,15 +301,22 @@ float TerrainMovementManager::calculateStepCost(
return -1.0f;
}
float cost = baseCost;
if (deltaH > 0.001f) {
// Uphill penalty: going uphill increases movement cost
float penalty = deltaH * m_config.uphillSlopeMultiplier;
return baseCost + penalty;
cost = baseCost + penalty;
} else if (deltaH < -0.001f) {
// Downhill bonus: going downhill decreases movement cost (negative penalty)
float bonus = (-deltaH) * m_config.downhillSlopeBonusMultiplier;
return std::max(m_config.minStepCost, baseCost - bonus);
cost = std::max(m_config.minStepCost, baseCost - bonus);
}
return baseCost;
// Road speed bonus: if traveling between connected road tiles, movement speed increases!
float roadMult = GameManager::instance().getRoadSpeedMultiplierBetween(fromX, fromY, toX, toY);
if (roadMult > 1.0f) {
cost /= roadMult;
}
return std::max(0.1f, cost);
}