diff options
Diffstat (limited to 'src/openvic-simulation/modifier')
-rw-r--r-- | src/openvic-simulation/modifier/ModifierSum.cpp | 17 | ||||
-rw-r--r-- | src/openvic-simulation/modifier/ModifierSum.hpp | 1 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/openvic-simulation/modifier/ModifierSum.cpp b/src/openvic-simulation/modifier/ModifierSum.cpp index 09cb36d..a3b8cd5 100644 --- a/src/openvic-simulation/modifier/ModifierSum.cpp +++ b/src/openvic-simulation/modifier/ModifierSum.cpp @@ -70,23 +70,28 @@ void ModifierSum::add_modifier_sum_exclude_source(ModifierSum const& modifier_su } // TODO - include value_sum[effect] in result? Early return if lookup in value_sum fails? -std::vector<ModifierSum::modifier_entry_t> ModifierSum::get_contributing_modifiers( - ModifierEffect const& effect + +void ModifierSum::push_contributing_modifiers( + ModifierEffect const& effect, std::vector<modifier_entry_t>& contributions ) const { using enum ModifierEffect::target_t; - std::vector<modifier_entry_t> ret; - for (modifier_entry_t const& modifier_entry : modifiers) { if ((modifier_entry.targets & effect.get_targets()) != NO_TARGETS) { bool effect_found = false; const fixed_point_t value = modifier_entry.modifier->get_effect(effect, &effect_found); if (effect_found) { - ret.push_back(modifier_entry); + contributions.push_back(modifier_entry); } } } +} + +std::vector<ModifierSum::modifier_entry_t> ModifierSum::get_contributing_modifiers(ModifierEffect const& effect) const { + std::vector<modifier_entry_t> contributions; + + push_contributing_modifiers(effect, contributions); - return ret; + return contributions; } diff --git a/src/openvic-simulation/modifier/ModifierSum.hpp b/src/openvic-simulation/modifier/ModifierSum.hpp index 0ca8caa..7c1b238 100644 --- a/src/openvic-simulation/modifier/ModifierSum.hpp +++ b/src/openvic-simulation/modifier/ModifierSum.hpp @@ -55,6 +55,7 @@ namespace OpenVic { void add_modifier_sum_filter_targets(ModifierSum const& modifier_sum, ModifierEffect::target_t targets); void add_modifier_sum_exclude_source(ModifierSum const& modifier_sum, modifier_source_t const& excluded_source); + void push_contributing_modifiers(ModifierEffect const& effect, std::vector<modifier_entry_t>& contributions) const; std::vector<modifier_entry_t> get_contributing_modifiers(ModifierEffect const& effect) const; }; } |