Refactor farm building speed to builder unit action_speeds and enable infinite charges
This commit is contained in:
+21
-2
@@ -6,6 +6,8 @@
|
||||
#include <QMap>
|
||||
#include <vector>
|
||||
|
||||
#include "terrainmovementmanager.h"
|
||||
|
||||
enum class UnitCategory {
|
||||
Military, // militair
|
||||
Reconnaissance, // verkenning
|
||||
@@ -33,23 +35,40 @@ struct UnitConfig {
|
||||
QString id;
|
||||
QString name;
|
||||
UnitCategory category;
|
||||
MovementDomain movementDomain;
|
||||
int health;
|
||||
float movementSpeed;
|
||||
int cost;
|
||||
int attackDamage;
|
||||
int attackRange; // 1 for melee, >1 for ranged
|
||||
int buildCharges;
|
||||
bool infiniteCharges;
|
||||
QString iconPath;
|
||||
QStringList actions;
|
||||
QMap<QString, float> actionSpeeds; // Duration in seconds per action (e.g. "boerderij_bouwen": 10.0f)
|
||||
QStringList impassableTerrains;
|
||||
QStringList passableTerrains;
|
||||
|
||||
UnitConfig()
|
||||
: id(""), name(""), category(UnitCategory::Builder), health(100),
|
||||
: id(""), name(""), category(UnitCategory::Builder),
|
||||
movementDomain(MovementDomain::Land), health(100),
|
||||
movementSpeed(2.0f), cost(10), attackDamage(0), attackRange(1),
|
||||
iconPath("") {}
|
||||
buildCharges(-1), infiniteCharges(true), iconPath("") {}
|
||||
|
||||
bool isRanged() const { return attackRange > 1; }
|
||||
bool isMilitary() const { return category == UnitCategory::Military; }
|
||||
bool isNaval() const { return movementDomain == MovementDomain::Naval; }
|
||||
bool isLand() const { return movementDomain == MovementDomain::Land; }
|
||||
bool canAttack() const { return actions.contains("aanvallen") || isMilitary(); }
|
||||
bool canBuildCity() const { return actions.contains("steden_bouwen") || actions.contains("build_city"); }
|
||||
bool canBuildFarm() const { return actions.contains("boerderij_bouwen") || actions.contains("build_farm"); }
|
||||
|
||||
float getActionDuration(const QString &actionName, float fallback = 10.0f) const {
|
||||
if (actionSpeeds.contains(actionName)) {
|
||||
return actionSpeeds.value(actionName);
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
};
|
||||
|
||||
class UnitConfigManager {
|
||||
|
||||
Reference in New Issue
Block a user