aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/Province.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/map/Province.hpp')
-rw-r--r--src/openvic-simulation/map/Province.hpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/openvic-simulation/map/Province.hpp b/src/openvic-simulation/map/Province.hpp
index 476ecc9..cfe5ed6 100644
--- a/src/openvic-simulation/map/Province.hpp
+++ b/src/openvic-simulation/map/Province.hpp
@@ -1,7 +1,5 @@
#pragma once
-#include <cassert>
-
#include "openvic-simulation/country/Country.hpp"
#include "openvic-simulation/economy/BuildingInstance.hpp"
#include "openvic-simulation/politics/Ideology.hpp"
@@ -20,6 +18,8 @@ namespace OpenVic {
struct ProvinceSetModifier;
using Climate = ProvinceSetModifier;
using Continent = ProvinceSetModifier;
+ struct ArmyInstance;
+ struct NavyInstance;
/* REQUIREMENTS:
* MAP-5, MAP-7, MAP-8, MAP-43, MAP-47
@@ -68,20 +68,17 @@ namespace OpenVic {
};
struct province_positions_t {
- /* Calculated average */
- fvec2_t centre;
-
/* Province name placement */
- fvec2_t text;
- fixed_point_t text_rotation;
- fixed_point_t text_scale;
+ std::optional<fvec2_t> text;
+ std::optional<fvec2_t> text_rotation;
+ std::optional<fvec2_t> text_scale;
/* Model positions */
std::optional<fvec2_t> unit;
- fvec2_t city;
- fvec2_t factory;
- fvec2_t building_construction;
- fvec2_t military_construction;
+ std::optional<fvec2_t> city;
+ std::optional<fvec2_t> factory;
+ std::optional<fvec2_t> building_construction;
+ std::optional<fvec2_t> military_construction;
ordered_map<BuildingType const*, fvec2_t> building_position;
fixed_point_map_t<BuildingType const*> building_rotation;
};
@@ -99,11 +96,14 @@ namespace OpenVic {
bool PROPERTY_CUSTOM_PREFIX(water, is);
bool PROPERTY_CUSTOM_PREFIX(coastal, is);
bool PROPERTY_CUSTOM_PREFIX(port, has);
+ Province const* PROPERTY(port_adjacent_province);
/* Terrain type calculated from terrain image */
TerrainType const* PROPERTY(default_terrain_type);
std::vector<adjacency_t> PROPERTY(adjacencies);
- province_positions_t PROPERTY(positions);
+ /* Calculated mean pixel position. */
+ fvec2_t PROPERTY(centre);
+ province_positions_t positions;
/* Mutable attributes (reset before loading history) */
TerrainType const* PROPERTY(terrain_type);
@@ -118,6 +118,8 @@ namespace OpenVic {
// TODO - change this into a factory-like structure
Good const* PROPERTY(rgo);
IdentifierRegistry<BuildingInstance> IDENTIFIER_REGISTRY(building);
+ ordered_set<ArmyInstance*> PROPERTY(armies);
+ ordered_set<NavyInstance*> PROPERTY(navies);
std::vector<Pop> PROPERTY(pops);
Pop::pop_size_t PROPERTY(total_population);
@@ -136,9 +138,13 @@ namespace OpenVic {
bool operator==(Province const& other) const;
std::string to_string() const;
- bool load_positions(BuildingTypeManager const& building_type_manager, ast::NodeCPtr root);
+ /* The positions' y coordinates need to be inverted. */
+ bool load_positions(Map const& map, BuildingTypeManager const& building_type_manager, ast::NodeCPtr root);
bool expand_building(size_t building_index);
+ /* This returns a pointer to the position of the specified building type, or nullptr if none exists. */
+ fvec2_t const* get_building_position(BuildingType const* building_type) const;
+ fixed_point_t get_building_rotation(BuildingType const* building_type) const;
bool add_pop(Pop&& pop);
bool add_pop_vec(std::vector<Pop> const& pop_vec);
@@ -154,6 +160,10 @@ namespace OpenVic {
bool has_adjacency_going_through(Province const* province) const;
fvec2_t get_unit_position() const;
+ bool add_army(ArmyInstance& army);
+ bool remove_army(ArmyInstance& army);
+ bool add_navy(NavyInstance& navy);
+ bool remove_navy(NavyInstance& navy);
bool reset(BuildingTypeManager const& building_type_manager);
bool apply_history_to_province(ProvinceHistoryEntry const* entry);