aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/research/Technology.cpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-12-07 22:04:05 +0100
committer GitHub <noreply@github.com>2023-12-07 22:04:05 +0100
commit085fe94212c6f0ddbdfca1b2ba58223e7f6dcc8a (patch)
tree2a73255f595eabb1441419a08bd0d5e5407213e7 /src/openvic-simulation/research/Technology.cpp
parent48a3f1729d709847d7cad33f594c77cac414e802 (diff)
parent398377011cb3d3c970451dcd215f3610159f1ae2 (diff)
Merge pull request #85 from OpenVicProject/container-callbacks
Container (pointer) callbacks + format cleanup
Diffstat (limited to 'src/openvic-simulation/research/Technology.cpp')
-rw-r--r--src/openvic-simulation/research/Technology.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/openvic-simulation/research/Technology.cpp b/src/openvic-simulation/research/Technology.cpp
index 07faaa3..f8ebb4b 100644
--- a/src/openvic-simulation/research/Technology.cpp
+++ b/src/openvic-simulation/research/Technology.cpp
@@ -111,8 +111,12 @@ bool TechnologyManager::load_technology_file_schools(ModifierManager const& modi
})(root);
}
-bool TechnologyManager::load_technologies_file(ModifierManager const& modifier_manager, UnitManager const& unit_manager, BuildingManager const& building_manager, ast::NodeCPtr root) {
- return expect_dictionary_reserve_length(technologies, [this, &modifier_manager, &unit_manager, &building_manager](std::string_view tech_key, ast::NodeCPtr tech_value) -> bool {
+bool TechnologyManager::load_technologies_file(
+ ModifierManager const& modifier_manager, UnitManager const& unit_manager, BuildingTypeManager const& building_type_manager,
+ ast::NodeCPtr root
+) {
+ return expect_dictionary_reserve_length(technologies, [this, &modifier_manager, &unit_manager, &building_type_manager](
+ std::string_view tech_key, ast::NodeCPtr tech_value) -> bool {
ModifierValue modifiers;
TechnologyArea const* area = nullptr;
Date::year_t year = 0;
@@ -128,15 +132,9 @@ bool TechnologyManager::load_technologies_file(ModifierManager const& modifier_m
"cost", ONE_EXACTLY, expect_fixed_point(assign_variable_callback(cost)),
"unciv_military", ZERO_OR_ONE, expect_bool(assign_variable_callback(unciv_military)),
"unit", ZERO_OR_ONE, expect_uint(assign_variable_callback(unit)),
- "activate_unit", ZERO_OR_MORE, unit_manager.expect_unit_identifier([&activated_units](Unit const& unit) -> bool {
- activated_units.insert(&unit);
- return true;
- }),
- "activate_building", ZERO_OR_MORE, building_manager.expect_building_type_identifier(
- [&activated_buildings](BuildingType const& building_type) -> bool {
- activated_buildings.insert(&building_type);
- return true;
- }
+ "activate_unit", ZERO_OR_MORE, unit_manager.expect_unit_identifier(set_callback_pointer(activated_units)),
+ "activate_building", ZERO_OR_MORE, building_type_manager.expect_building_type_identifier(
+ set_callback_pointer(activated_buildings)
),
"ai_chance", ONE_EXACTLY, success_callback //TODO
)(tech_value);
@@ -149,7 +147,7 @@ bool TechnologyManager::load_technologies_file(ModifierManager const& modifier_m
})(root);
}
-#define TECH_MODIFIER(NAME, POS) ret &= modifier_manager.add_modifier_effect(NAME, POS, ModifierEffect::format_t::PROPORTION_DECIMAL)
+#define TECH_MODIFIER(NAME, POS) ret &= modifier_manager.add_modifier_effect(NAME, POS)
#define UNCIV_TECH_MODIFIER(NAME) TECH_MODIFIER(NAME, false); TECH_MODIFIER(StringUtils::append_string_views("self_", NAME), false);
bool TechnologyManager::generate_modifiers(ModifierManager& modifier_manager) {
bool ret = true;
@@ -160,7 +158,7 @@ bool TechnologyManager::generate_modifiers(ModifierManager& modifier_manager) {
for (TechnologyFolder const& folder : get_technology_folders()) {
TECH_MODIFIER(StringUtils::append_string_views(folder.get_identifier(), "_research_bonus"), true);
}
-
+
return ret;
}
#undef UNCIV_TECH_MODIFIER