Project Alice
Loading...
Searching...
No Matches
supply.hpp
Go to the documentation of this file.
1#pragma once
2
3std::vector<uint32_t> supply_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 fat_id = dcon::fatten(state.world, prov_id);
11 auto nation = fat_id.get_nation_from_province_ownership();
12 int32_t supply_limit = military::supply_limit_in_province(state, nation, prov_id);
13 float interpolation = (supply_limit < 50 ? supply_limit : 50) / 50.f;
14
15 uint32_t color = ogl::color_gradient(interpolation, sys::pack_color(46, 247, 15), // red
16 sys::pack_color(247, 15, 15) // green
17 );
18
19 auto i = province::to_map_id(prov_id);
20
21 prov_color[i] = color;
22 prov_color[i + texture_size] = color;
23 });
24 return prov_color;
25}
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
int32_t supply_limit_in_province(sys::state &state, dcon::nation_id n, dcon::province_id p)
Definition: military.cpp:618
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
std::vector< uint32_t > supply_map_from(sys::state &state)
Definition: supply.hpp:3