#pragma once #include #include #include #include "openvic-simulation/military/Leader.hpp" #include "openvic-simulation/military/UnitType.hpp" #include "openvic-simulation/types/HasIdentifier.hpp" #include "openvic-simulation/utility/Getters.hpp" namespace OpenVic { struct ProvinceDefinition; template struct UnitDeployment; template<> struct UnitDeployment { friend struct DeploymentManager; private: std::string PROPERTY(name); RegimentType const& PROPERTY(type); ProvinceDefinition const* PROPERTY(home); UnitDeployment(std::string_view new_name, RegimentType const& new_type, ProvinceDefinition const* new_home); public: UnitDeployment(UnitDeployment&&) = default; }; using RegimentDeployment = UnitDeployment; template<> struct UnitDeployment { friend struct DeploymentManager; private: std::string PROPERTY(name); ShipType const& PROPERTY(type); UnitDeployment(std::string_view new_name, ShipType const& new_type); public: UnitDeployment(UnitDeployment&&) = default; }; using ShipDeployment = UnitDeployment; template struct UnitDeploymentGroup { friend struct DeploymentManager; using _Unit = UnitDeployment; private: std::string PROPERTY(name); ProvinceDefinition const* PROPERTY(location); std::vector<_Unit> PROPERTY(units); UnitDeploymentGroup( std::string_view new_name, ProvinceDefinition const* new_location, std::vector<_Unit>&& new_units ); public: UnitDeploymentGroup(UnitDeploymentGroup&&) = default; }; using ArmyDeployment = UnitDeploymentGroup; using NavyDeployment = UnitDeploymentGroup; struct Deployment : HasIdentifier { friend struct DeploymentManager; private: std::vector PROPERTY(armies); std::vector PROPERTY(navies); std::vector PROPERTY(leaders); Deployment( std::string_view new_path, std::vector&& new_armies, std::vector&& new_navies, std::vector&& new_leaders ); public: Deployment(Deployment&&) = default; UNIT_BRANCHED_GETTER_CONST(get_unit_deployment_groups, armies, navies); }; struct DefinitionManager; class Dataloader; struct DeploymentManager { private: IdentifierRegistry IDENTIFIER_REGISTRY(deployment); string_set_t missing_oob_files; public: bool add_deployment( std::string_view path, std::vector&& armies, std::vector&& navies, std::vector&& leaders ); bool load_oob_file( DefinitionManager const& definition_manager, Dataloader const& dataloader, std::string_view history_path, Deployment const*& deployment, bool fail_on_missing ); size_t get_missing_oob_file_count() const; }; }