Implement technology tree, research queue by least remaining work, and unit/building tech availability & obsolescence
This commit is contained in:
+28
-1
@@ -33,6 +33,9 @@ bool ActionNeededManager::loadConfigFile(const QString &filePath)
|
||||
if (node.hasChild("track_city_free_population")) {
|
||||
m_config.trackCityFreePopulation = node["track_city_free_population"].asBool(true);
|
||||
}
|
||||
if (node.hasChild("track_no_research")) {
|
||||
m_config.trackNoResearch = node["track_no_research"].asBool(true);
|
||||
}
|
||||
if (node.hasChild("max_visible_items")) {
|
||||
m_config.maxVisibleItems = node["max_visible_items"].asInt(8);
|
||||
}
|
||||
@@ -70,6 +73,10 @@ bool ActionNeededManager::loadConfigFile(const QString &filePath)
|
||||
QString hex = node["city_free_pop_color"].asString("#46DC82");
|
||||
m_config.cityFreePopColor = QColor(hex);
|
||||
}
|
||||
if (node.hasChild("no_research_color")) {
|
||||
QString hex = node["no_research_color"].asString("#38C8FF");
|
||||
m_config.noResearchColor = QColor(hex);
|
||||
}
|
||||
if (node.hasChild("card_bg_color")) {
|
||||
QString hex = node["card_bg_color"].asString("#121822");
|
||||
m_config.cardBgColor = QColor(hex);
|
||||
@@ -85,7 +92,8 @@ bool ActionNeededManager::loadConfigFile(const QString &filePath)
|
||||
|
||||
void ActionNeededManager::update(float deltaTime, int activePlayerId,
|
||||
const std::vector<std::shared_ptr<Unit>> &units,
|
||||
const std::vector<City> &cities)
|
||||
const std::vector<City> &cities,
|
||||
bool needsResearch)
|
||||
{
|
||||
if (!m_config.enabled) return;
|
||||
|
||||
@@ -93,6 +101,25 @@ void ActionNeededManager::update(float deltaTime, int activePlayerId,
|
||||
|
||||
std::set<QString> currentConditionKeys;
|
||||
|
||||
// 0. Player has no active research
|
||||
if (m_config.trackNoResearch && needsResearch) {
|
||||
QString key = QString("%1_%2").arg(static_cast<int>(ActionNeededType::NoResearch)).arg(activePlayerId);
|
||||
currentConditionKeys.insert(key);
|
||||
|
||||
auto it = std::find_if(m_items.begin(), m_items.end(), [&](const ActionItem &item) {
|
||||
return item.type == ActionNeededType::NoResearch && item.entityId == activePlayerId;
|
||||
});
|
||||
|
||||
if (it == m_items.end()) {
|
||||
ActionItem newItem;
|
||||
newItem.type = ActionNeededType::NoResearch;
|
||||
newItem.entityId = activePlayerId;
|
||||
newItem.firstDetectedTime = m_elapsedGameTime;
|
||||
newItem.dismissed = false;
|
||||
m_items.push_back(newItem);
|
||||
}
|
||||
}
|
||||
|
||||
// 1. Idle Units waiting for action
|
||||
if (m_config.trackIdleUnits) {
|
||||
for (const auto &u : units) {
|
||||
|
||||
Reference in New Issue
Block a user