diff options
author | hop311 <hop3114@gmail.com> | 2024-10-23 01:21:25 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-10-23 01:21:25 +0200 |
commit | eca580673aec46cd6e730e7307c13afb858efd94 (patch) | |
tree | 8ad859f8c3b4cad664a7a3e4cd93edbbed60bb5f /src/openvic-simulation/modifier/ModifierManager.hpp | |
parent | c88cf59997529cbca008f9a2b629822de9deaa2a (diff) |
[Work-In-Progress] Add ModifierEffectMappingmodifier-effect-mappings
Diffstat (limited to 'src/openvic-simulation/modifier/ModifierManager.hpp')
-rw-r--r-- | src/openvic-simulation/modifier/ModifierManager.hpp | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/src/openvic-simulation/modifier/ModifierManager.hpp b/src/openvic-simulation/modifier/ModifierManager.hpp index 51f89ae..bb946a7 100644 --- a/src/openvic-simulation/modifier/ModifierManager.hpp +++ b/src/openvic-simulation/modifier/ModifierManager.hpp @@ -2,14 +2,12 @@ #include "openvic-simulation/modifier/Modifier.hpp" #include "openvic-simulation/modifier/ModifierEffectCache.hpp" +#include "openvic-simulation/modifier/ModifierEffectMapping.hpp" #include "openvic-simulation/modifier/StaticModifierCache.hpp" #include "openvic-simulation/types/IdentifierRegistry.hpp" namespace OpenVic { - template<typename Fn> - concept ModifierEffectValidator = std::predicate<Fn, ModifierEffect const&>; - struct ModifierManager { friend struct StaticModifierCache; friend struct BuildingTypeManager; @@ -37,10 +35,11 @@ namespace OpenVic { ModifierEffectCache PROPERTY(modifier_effect_cache); StaticModifierCache PROPERTY(static_modifier_cache); + std::vector<ModifierEffectMapping> PROPERTY(modifier_effect_mappings); + /* effect_validator takes in ModifierEffect const& */ NodeTools::key_value_callback_t _modifier_effect_callback( - ModifierValue& modifier, Modifier::modifier_type_t type, NodeTools::key_value_callback_t default_callback, - ModifierEffectValidator auto effect_validator + ModifierValue& modifier, Modifier::modifier_type_t type, NodeTools::key_value_callback_t default_callback ) const; public: @@ -50,7 +49,9 @@ namespace OpenVic { bool positive_good, ModifierEffect::format_t format, ModifierEffect::target_t targets, - std::string_view localisation_key = {} + std::string_view localisation_key = {}, + // mapping_key is placed after localisation_key as it's less likely to be set explicitly + std::string_view mapping_key = {} ); bool register_complex_modifier(std::string_view identifier); @@ -62,6 +63,7 @@ namespace OpenVic { std::string const& identifier, ModifierEffect const* effect, std::vector<Modifier::modifier_type_t> const& types ); + bool setup_modifier_effect_mappings(); bool setup_modifier_effects(); bool add_event_modifier(std::string_view identifier, ModifierValue&& values, IconModifier::icon_t icon); @@ -77,15 +79,6 @@ namespace OpenVic { bool parse_scripts(DefinitionManager const& definition_manager); - NodeTools::node_callback_t expect_validated_modifier_value_and_default( - NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type, - NodeTools::key_value_callback_t default_callback, ModifierEffectValidator auto effect_validator - ) const; - NodeTools::node_callback_t expect_validated_modifier_value( - NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type, - ModifierEffectValidator auto effect_validator - ) const; - NodeTools::node_callback_t expect_modifier_value_and_default( NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type, NodeTools::key_value_callback_t default_callback @@ -94,15 +87,6 @@ namespace OpenVic { NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type ) const; - NodeTools::node_callback_t expect_whitelisted_modifier_value_and_default( - NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type, - string_set_t const& whitelist, NodeTools::key_value_callback_t default_callback - ) const; - NodeTools::node_callback_t expect_whitelisted_modifier_value( - NodeTools::callback_t<ModifierValue&&> modifier_callback, Modifier::modifier_type_t type, - string_set_t const& whitelist - ) const; - // In the functions below, key_map refers to a map from identifier strings to NodeTools::dictionary_entry_t, // allowing any non-modifier effect keys found to be parsed in a custom way, similar to expect_dictionary_keys. NodeTools::node_callback_t expect_modifier_value_and_key_map_and_default( |