diff options
author | Hop311 <Hop3114@gmail.com> | 2024-07-23 19:47:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-23 19:47:47 +0200 |
commit | 6cd55c452d1643666ff4169a89402fd3e3b66c61 (patch) | |
tree | 888b847a54c66b6e9d1b2f7ee3e3d0f8071eceda /src/openvic-simulation/military | |
parent | 9d57ca273e4b32ab82a51789ec58e08fefb5276a (diff) | |
parent | 67cbd14630c4344902d3fa1ddca178809da4293b (diff) |
Merge pull request #177 from OpenVicProject/country-instance
Fleshing out Country, State and Province instances + history
Diffstat (limited to 'src/openvic-simulation/military')
-rw-r--r-- | src/openvic-simulation/military/UnitInstanceGroup.cpp | 13 | ||||
-rw-r--r-- | src/openvic-simulation/military/UnitInstanceGroup.hpp | 4 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/openvic-simulation/military/UnitInstanceGroup.cpp b/src/openvic-simulation/military/UnitInstanceGroup.cpp index 80ca3a9..07736f3 100644 --- a/src/openvic-simulation/military/UnitInstanceGroup.cpp +++ b/src/openvic-simulation/military/UnitInstanceGroup.cpp @@ -155,6 +155,17 @@ UnitInstanceGroupBranched<UnitType::branch_t::NAVAL>::UnitInstanceGroupBranched( std::vector<ShipInstance*>&& new_units ) : UnitInstanceGroup { new_name, std::move(new_units) } {} + +fixed_point_t UnitInstanceGroupBranched<UnitType::branch_t::NAVAL>::get_total_consumed_supply() const { + fixed_point_t total_consumed_supply = 0; + + for (ShipInstance const* ship : get_units()) { + total_consumed_supply += ship->get_unit_type().get_supply_consumption_score(); + } + + return total_consumed_supply; +} + template<UnitType::branch_t Branch> bool UnitInstanceManager::generate_unit_instance( UnitDeployment<Branch> const& unit_deployment, UnitInstanceBranched<Branch>*& unit_instance @@ -220,7 +231,7 @@ bool UnitInstanceManager::generate_unit_instance_group( }); ret &= unit_instance_group.set_position( - map_instance.get_province_instance_from_const(unit_deployment_group.get_location()) + &map_instance.get_province_instance_from_definition(*unit_deployment_group.get_location()) ); ret &= unit_instance_group.set_country(&country); diff --git a/src/openvic-simulation/military/UnitInstanceGroup.hpp b/src/openvic-simulation/military/UnitInstanceGroup.hpp index 4fe0cba..78ff289 100644 --- a/src/openvic-simulation/military/UnitInstanceGroup.hpp +++ b/src/openvic-simulation/military/UnitInstanceGroup.hpp @@ -90,7 +90,7 @@ namespace OpenVic { friend struct UnitInstanceManager; private: - std::vector<ArmyInstance const*> PROPERTY(carried_armies); + std::vector<ArmyInstance*> PROPERTY(carried_armies); UnitInstanceGroupBranched( std::string_view new_name, @@ -99,6 +99,8 @@ namespace OpenVic { public: UnitInstanceGroupBranched(UnitInstanceGroupBranched&&) = default; + + fixed_point_t get_total_consumed_supply() const; }; using NavyInstance = UnitInstanceGroupBranched<UnitType::branch_t::NAVAL>; |