Implement builder road construction with hex-edge auto-connection, winding rendering, and speed bonus
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user