diff options
author | Hop311 <Hop3114@gmail.com> | 2024-04-15 21:00:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-15 21:00:16 +0200 |
commit | 8f97145e9570a9b728010a818137cb31a51fd5f6 (patch) | |
tree | efe1150a7b6c92bf983dfcab2e0bd147bfcf54bf /src/openvic-simulation/map/Province.hpp | |
parent | a57e81703102bc52297fbdc074da755fa8edbedd (diff) | |
parent | a7f125a5f276e2951d1236fe88e32c5c08271504 (diff) |
Merge pull request #155 from OpenVicProject/province-positions
Province positions
Diffstat (limited to 'src/openvic-simulation/map/Province.hpp')
-rw-r--r-- | src/openvic-simulation/map/Province.hpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/openvic-simulation/map/Province.hpp b/src/openvic-simulation/map/Province.hpp index c4785dd..cfe5ed6 100644 --- a/src/openvic-simulation/map/Province.hpp +++ b/src/openvic-simulation/map/Province.hpp @@ -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); @@ -138,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); |