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/Map.hpp | |
parent | a57e81703102bc52297fbdc074da755fa8edbedd (diff) | |
parent | a7f125a5f276e2951d1236fe88e32c5c08271504 (diff) |
Merge pull request #155 from OpenVicProject/province-positions
Province positions
Diffstat (limited to 'src/openvic-simulation/map/Map.hpp')
-rw-r--r-- | src/openvic-simulation/map/Map.hpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/openvic-simulation/map/Map.hpp b/src/openvic-simulation/map/Map.hpp index 807945a..2a3f224 100644 --- a/src/openvic-simulation/map/Map.hpp +++ b/src/openvic-simulation/map/Map.hpp @@ -69,8 +69,7 @@ namespace OpenVic { ProvinceSet water_provinces; TerrainTypeManager PROPERTY_REF(terrain_type_manager); - int32_t PROPERTY(width); - int32_t PROPERTY(height); + ivec2_t PROPERTY(dims); std::vector<shape_pixel_t> PROPERTY(province_shape_image); colour_index_map_t colour_index_map; @@ -84,9 +83,16 @@ namespace OpenVic { StateManager PROPERTY_REF(state_manager); + inline constexpr int32_t get_pixel_index_from_pos(ivec2_t pos) const { + return pos.x + pos.y * dims.x; + } + public: Map(); + inline constexpr int32_t get_width() const { return dims.x; } + inline constexpr int32_t get_height() const { return dims.y; } + bool add_province(std::string_view identifier, colour_t colour); IDENTIFIER_REGISTRY_NON_CONST_ACCESSORS_CUSTOM_INDEX_OFFSET(province, 1); @@ -110,7 +116,9 @@ namespace OpenVic { bool set_water_province_list(std::vector<std::string_view> const& list); void lock_water_provinces(); - Province::index_t get_province_index_at(size_t x, size_t y) const; + Province::index_t get_province_index_at(ivec2_t pos) const; + Province* get_province_at(ivec2_t pos); + Province const* get_province_at(ivec2_t pos) const; bool set_max_provinces(Province::index_t new_max_provinces); void set_selected_province(Province::index_t index); Province* get_selected_province(); |