Project Alice
Loading...
Searching...
No Matches
relation.hpp
Go to the documentation of this file.
1#pragma once
2
3std::vector<uint32_t> relation_map_from(sys::state& state) {
4 uint32_t province_size = state.world.province_size();
5 uint32_t texture_size = province_size + 256 - province_size % 256;
6
7 std::vector<uint32_t> prov_color(texture_size * 2);
8
9 auto selected_province = state.map_state.get_selected_province();
10 auto fat_id = dcon::fatten(state.world, selected_province);
11 auto selected_nation = fat_id.get_nation_from_province_ownership();
12
13 if(!selected_nation) {
14 selected_nation = state.local_player_nation;
15 }
16
17 auto relations = selected_nation.get_diplomatic_relation_as_related_nations();
18
19 state.world.for_each_province([&](dcon::province_id prov_id) {
20 auto other_nation = state.world.province_get_nation_from_province_ownership(prov_id);
21
22 // if the province has no owners
23 if(!other_nation) {
24 return;
25 }
26
27 uint32_t color;
28
29 if(other_nation == selected_nation.id) {
30 // the selected nation should be blue
31 color = sys::pack_color(66, 106, 227);
32 } else {
33 auto diplo_relation = state.world.get_diplomatic_relation_by_diplomatic_pair(other_nation, selected_nation);
34 auto relation_value = state.world.diplomatic_relation_get_value(diplo_relation);
35
36 float interpolation = (200 + relation_value) / 400.f;
37
38 color = ogl::color_gradient(interpolation, sys::pack_color(46, 247, 15), // green
39 sys::pack_color(247, 15, 15) // red
40 );
41 }
42
43 auto i = province::to_map_id(prov_id);
44
45 prov_color[i] = color;
46 prov_color[i + texture_size] = color;
47 });
48
49 return prov_color;
50}
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
constexpr uint16_t to_map_id(dcon::province_id id)
Definition: province.hpp:10
uint uint32_t
std::vector< uint32_t > relation_map_from(sys::state &state)
Definition: relation.hpp:3