aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/modifier/ModifierValue.hpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-09-30 22:10:01 +0200
committer hop311 <hop3114@gmail.com>2024-10-05 22:48:42 +0200
commitf3f364f08cc8f1c80a5dfce689183c2f8f75bbd4 (patch)
treec7c206ab58440bd8d5200c4416e97a324489d018 /src/openvic-simulation/modifier/ModifierValue.hpp
parenteb77495ba874d474bbbbc950a65e8f496b13f285 (diff)
Move ModifierEffect and ModifierValue into their own files
Diffstat (limited to 'src/openvic-simulation/modifier/ModifierValue.hpp')
-rw-r--r--src/openvic-simulation/modifier/ModifierValue.hpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/openvic-simulation/modifier/ModifierValue.hpp b/src/openvic-simulation/modifier/ModifierValue.hpp
new file mode 100644
index 0000000..23c0ba5
--- /dev/null
+++ b/src/openvic-simulation/modifier/ModifierValue.hpp
@@ -0,0 +1,48 @@
+#pragma once
+
+#include "openvic-simulation/modifier/ModifierEffect.hpp"
+#include "openvic-simulation/types/fixed_point/FixedPointMap.hpp"
+
+namespace OpenVic {
+ struct ModifierValue {
+ friend struct ModifierManager;
+
+ using effect_map_t = fixed_point_map_t<ModifierEffect const*>;
+
+ private:
+ effect_map_t PROPERTY(values);
+
+ public:
+ ModifierValue();
+ ModifierValue(effect_map_t&& new_values);
+ ModifierValue(ModifierValue const&);
+ ModifierValue(ModifierValue&&);
+
+ ModifierValue& operator=(ModifierValue const&);
+ ModifierValue& operator=(ModifierValue&&);
+
+ /* Removes effect entries with a value of zero. */
+ void trim();
+ size_t get_effect_count() const;
+ void clear();
+ bool empty() const;
+
+ fixed_point_t get_effect(ModifierEffect const& effect, bool* effect_found = nullptr) const;
+ fixed_point_t get_effect_nullcheck(ModifierEffect const* effect, bool* effect_found = nullptr) const;
+ bool has_effect(ModifierEffect const& effect) const;
+ void set_effect(ModifierEffect const& effect, fixed_point_t value);
+
+ ModifierValue& operator+=(ModifierValue const& right);
+ ModifierValue operator+(ModifierValue const& right) const;
+ ModifierValue operator-() const;
+ ModifierValue& operator-=(ModifierValue const& right);
+ ModifierValue operator-(ModifierValue const& right) const;
+ ModifierValue& operator*=(fixed_point_t const& right);
+ ModifierValue operator*(fixed_point_t const& right) const;
+
+ void apply_target_filter(ModifierEffect::target_t targets);
+ void multiply_add_filter(ModifierValue const& other, fixed_point_t multiplier, ModifierEffect::target_t targets);
+
+ friend std::ostream& operator<<(std::ostream& stream, ModifierValue const& value);
+ };
+}