Project Alice
Loading...
Searching...
No Matches
civilization_level.hpp
Go to the documentation of this file.
1#pragma once
2
3std::vector<uint32_t> civilization_level_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 state.world.for_each_province([&](dcon::province_id prov_id) {
10 auto nation = state.world.province_get_nation_from_province_ownership(prov_id);
11 auto status = nations::get_status(state, nation);
12
13 uint32_t color;
14
15 // if it is uncolonized
16 if(!nation) {
17
18 color = sys::pack_color(250, 5, 5); // red
19
20 } else if(state.world.nation_get_is_civilized(nation)) {
21
22 color = sys::pack_color(53, 196, 53); // green
23
24 } else {
25
26 float civ_level = state.world.nation_get_modifier_values(nation, sys::national_mod_offsets::civilization_progress_modifier);
27 // gray <-> yellow
28 color = ogl::color_gradient(civ_level * (1 + (1 - civ_level)), sys::pack_color(250, 250, 5), sys::pack_color(64, 64, 64));
29 }
30 auto i = province::to_map_id(prov_id);
31
32 prov_color[i] = color;
33 if(!state.world.province_get_is_colonial(prov_id)) {
34 prov_color[i + texture_size] = color;
35 } else {
36 prov_color[i + texture_size] = sys::pack_color(53, 53, 250);
37 }
38 });
39 return prov_color;
40}
std::vector< uint32_t > civilization_level_map_from(sys::state &state)
status get_status(sys::state &state, dcon::nation_id n)
Definition: nations.cpp:580
uint32_t color_gradient(float percent, uint32_t top_color, uint32_t bot_color)
Definition: color.hpp:42
constexpr uint16_t to_map_id(dcon::province_id id)
Definition: province.hpp:10
uint32_t pack_color(float r, float g, float b)
uint uint32_t