aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/ProvinceInstance.hpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-07-14 16:01:25 +0200
committer hop311 <hop3114@gmail.com>2024-07-14 16:25:34 +0200
commite4701ebc08f57575a02bdc1777d9851a987c1cba (patch)
treedb365e5d71df41b7b35abdcc3d4c0d76f1653619 /src/openvic-simulation/map/ProvinceInstance.hpp
parentb9b35ad9536cfdcd61f5208eeaad7ead4bd0418d (diff)
Unit and leader rework (branch based templates and colony containers)unit-colonies
Diffstat (limited to 'src/openvic-simulation/map/ProvinceInstance.hpp')
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.hpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/openvic-simulation/map/ProvinceInstance.hpp b/src/openvic-simulation/map/ProvinceInstance.hpp
index ca7f149..a4f9e98 100644
--- a/src/openvic-simulation/map/ProvinceInstance.hpp
+++ b/src/openvic-simulation/map/ProvinceInstance.hpp
@@ -1,6 +1,8 @@
#pragma once
#include "openvic-simulation/economy/BuildingInstance.hpp"
+#include "openvic-simulation/military/UnitInstance.hpp"
+#include "openvic-simulation/military/UnitType.hpp"
#include "openvic-simulation/pop/Pop.hpp"
#include "openvic-simulation/types/fixed_point/FixedPointMap.hpp"
#include "openvic-simulation/types/HasIdentifier.hpp"
@@ -14,8 +16,6 @@ namespace OpenVic {
struct CountryDefinition;
struct Crime;
struct GoodDefinition;
- struct ArmyInstance;
- struct NavyInstance;
struct Ideology;
struct Culture;
struct Religion;
@@ -24,6 +24,15 @@ namespace OpenVic {
struct IdeologyManager;
struct IssueManager;
+ template<UnitType::branch_t>
+ struct UnitInstanceGroup;
+
+ template<UnitType::branch_t>
+ struct UnitInstanceGroupBranched;
+
+ using ArmyInstance = UnitInstanceGroupBranched<UnitType::branch_t::LAND>;
+ using NavyInstance = UnitInstanceGroupBranched<UnitType::branch_t::NAVAL>;
+
struct ProvinceInstance : HasIdentifierAndColour {
friend struct MapInstance;
@@ -83,6 +92,27 @@ namespace OpenVic {
bool add_navy(NavyInstance& navy);
bool remove_navy(NavyInstance& navy);
+ template<UnitType::branch_t Branch>
+ bool add_unit_instance_group(UnitInstanceGroup<Branch>& group) {
+ if constexpr (Branch == UnitType::branch_t::LAND) {
+ return add_army(static_cast<ArmyInstance&>(group));
+ } else if constexpr (Branch == UnitType::branch_t::NAVAL) {
+ return add_navy(static_cast<NavyInstance&>(group));
+ } else {
+ OpenVic::utility::unreachable();
+ }
+ }
+ template<UnitType::branch_t Branch>
+ bool remove_unit_instance_group(UnitInstanceGroup<Branch>& group) {
+ if constexpr (Branch == UnitType::branch_t::LAND) {
+ return remove_army(static_cast<ArmyInstance&>(group));
+ } else if constexpr (Branch == UnitType::branch_t::NAVAL) {
+ return remove_navy(static_cast<NavyInstance&>(group));
+ } else {
+ OpenVic::utility::unreachable();
+ }
+ }
+
bool setup(BuildingTypeManager const& building_type_manager);
bool apply_history_to_province(ProvinceHistoryEntry const* entry);