aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/economy/production/ResourceGatheringOperation.hpp
diff options
context:
space:
mode:
author wvpm <24685035+wvpm@users.noreply.github.com>2024-09-22 01:07:51 +0200
committer wvpm <24685035+wvpm@users.noreply.github.com>2024-10-30 22:04:41 +0100
commit0d861669d9e1f5d487c810ae01be50f142790f1e (patch)
tree187df50130475006b404c5ab57f0fa679173ad04 /src/openvic-simulation/economy/production/ResourceGatheringOperation.hpp
parent48e4e92682db99239e928a67e6677cdd2c53a375 (diff)
Implement rgo for new gameprepare_for_rgo
Map province history rgo to production type for province instance output_goods back to ZERO_OR_ONE Link trade_goods in history to RGO instance for province. Other producer types as structs instead of classes Convert pops to equivalents & calculate rgo size Also convert pops when changing rgo Clean up Refactored RGO into part of ProvinceInstance ProductionType const& output_good Remove unused imports Clean up unused imports Restore constructor for ResourceGatheringOperation to initialise from savegame Move rgo size calculation to rgo Use terrain modifiers to calculate rgo size (placeholder code) Clean up Basic production & sales for rgo when initialising new game Use mutable pops Paychecks for owners, workers and slaves Clean up Simplify rgo instantiation Co-authored-by: Hop311 <Hop3114@gmail.com> Simplify good_to_rgo_production_type assignment Co-authored-by: Hop311 <Hop3114@gmail.com> Fix import Co-authored-by: Hop311 <Hop3114@gmail.com> min(3, great_powers.size()) Co-authored-by: Hop311 <Hop3114@gmail.com> Fix import Co-authored-by: Hop311 <Hop3114@gmail.com> Apply comments Log errors and return result when applying history Cleanup
Diffstat (limited to 'src/openvic-simulation/economy/production/ResourceGatheringOperation.hpp')
-rw-r--r--src/openvic-simulation/economy/production/ResourceGatheringOperation.hpp55
1 files changed, 47 insertions, 8 deletions
diff --git a/src/openvic-simulation/economy/production/ResourceGatheringOperation.hpp b/src/openvic-simulation/economy/production/ResourceGatheringOperation.hpp
index d71c569..a15e87d 100644
--- a/src/openvic-simulation/economy/production/ResourceGatheringOperation.hpp
+++ b/src/openvic-simulation/economy/production/ResourceGatheringOperation.hpp
@@ -1,25 +1,64 @@
#pragma once
+#include "openvic-simulation/economy/production/Employee.hpp"
#include "openvic-simulation/economy/production/ProductionType.hpp"
+#include "openvic-simulation/modifier/ModifierEffectCache.hpp"
+#include "openvic-simulation/pop/Pop.hpp"
#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
#include "openvic-simulation/utility/Getters.hpp"
namespace OpenVic {
- class ResourceGatheringOperation final {
+ struct ResourceGatheringOperation {
private:
- ProductionType const& PROPERTY(production_type);
+ ProductionType const* PROPERTY_RW(production_type_nullable);
fixed_point_t PROPERTY(revenue_yesterday);
fixed_point_t PROPERTY(output_quantity_yesterday);
fixed_point_t PROPERTY(unsold_quantity_yesterday);
- fixed_point_t PROPERTY(size_multiplier);
- ordered_map<Pop*, Pop::pop_size_t> PROPERTY(employees);
+ fixed_point_t PROPERTY_RW(size_multiplier);
+ std::vector<Employee> PROPERTY(employees);
+ Pop::pop_size_t PROPERTY(max_employee_count_cache);
+ Pop::pop_size_t PROPERTY(total_employees_count_cache);
+ Pop::pop_size_t PROPERTY(total_paid_employees_count_cache);
+ fixed_point_t PROPERTY(total_owner_income_cache);
+ fixed_point_t PROPERTY(total_employee_income_cache);
+ IndexedMap<PopType, Pop::pop_size_t> PROPERTY(employee_count_per_type_cache);
+
+ Pop::pop_size_t update_size_and_return_total_worker_count(
+ ProvinceInstance& location,
+ ModifierEffectCache const& modifier_effect_cache,
+ const fixed_point_t size_modifier
+ );
+ fixed_point_t calculate_size_modifier(ProvinceInstance const& location, ModifierEffectCache const& modifier_effect_cache) const;
+ void hire(ProvinceInstance& location, const Pop::pop_size_t available_worker_count);
+ fixed_point_t produce(
+ ProvinceInstance& location,
+ std::vector<Pop*>& owner_pops_cache,
+ Pop::pop_size_t& total_owner_count_in_state_cache,
+ ModifierEffectCache const& modifier_effect_cache,
+ const fixed_point_t size_modifier
+ );
+ void pay_employees(
+ ProvinceInstance& location,
+ const fixed_point_t revenue,
+ const Pop::pop_size_t total_worker_count_in_province,
+ std::vector<Pop*>& owner_pops_cache,
+ const Pop::pop_size_t total_owner_count_in_state_cache
+ );
public:
ResourceGatheringOperation(
- ProductionType const& new_production_type, fixed_point_t new_size_multiplier, fixed_point_t new_revenue_yesterday,
- fixed_point_t new_output_quantity_yesterday, fixed_point_t new_unsold_quantity_yesterday,
- ordered_map<Pop*, Pop::pop_size_t>&& new_employees
+ ProductionType const* new_production_type_nullable,
+ fixed_point_t new_size_multiplier,
+ fixed_point_t new_revenue_yesterday,
+ fixed_point_t new_output_quantity_yesterday,
+ fixed_point_t new_unsold_quantity_yesterday,
+ std::vector<Employee>&& new_employees,
+ decltype(employee_count_per_type_cache)::keys_t const& pop_type_keys
);
- ResourceGatheringOperation(ProductionType const& new_production_type, fixed_point_t new_size_multiplier);
+ ResourceGatheringOperation(decltype(employee_count_per_type_cache)::keys_t const& pop_type_keys);
+ constexpr bool is_valid() const {
+ return production_type_nullable != nullptr;
+ }
+ void initialise_for_new_game(ProvinceInstance& location, ModifierEffectCache const& modifier_effect_cache);
};
}