Project Alice
Loading...
Searching...
No Matches
naval.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5std::vector<uint32_t> naval_map_from(sys::state& state) {
6 uint32_t province_size = state.world.province_size();
7 uint32_t texture_size = province_size + 256 - province_size % 256;
8
9 std::vector<uint32_t> prov_color(texture_size * 2);
10
11 state.world.for_each_province([&](dcon::province_id prov_id) {
12 auto fat_id = dcon::fatten(state.world, prov_id);
13 auto nation = fat_id.get_nation_from_province_ownership();
14
15 if(nation == state.local_player_nation) {
16 uint32_t color = 0x222222;
17 uint32_t stripe_color = 0x222222;
18
19 if(province::has_naval_base_being_built(state, prov_id)) {
20 color = 0x00FF00;
21 stripe_color = 0x005500;
22 } else if(province::can_build_naval_base(state, prov_id, state.local_player_nation)) {
23 if(state.world.province_get_building_level(prov_id, uint8_t(economy::province_building_type::naval_base)) != 0) {
24 color = 0x00FF00;
25 stripe_color = 0x00FF00;
26 } else {
27 color = sys::pack_color(50, 150, 200);
28 stripe_color = sys::pack_color(50, 150, 200);
29 }
30 } else if(state.world.province_get_building_level(prov_id, uint8_t(economy::province_building_type::naval_base)) != 0) {
31 color = 0x005500;
32 stripe_color = 0x005500;
33 } else { // no naval base, not build target
34
35 }
36
37 auto i = province::to_map_id(prov_id);
38 prov_color[i] = color;
39 prov_color[i + texture_size] = stripe_color;
40 }
41 });
42
43 return prov_color;
44}
pop_satisfaction_wrapper_fat fatten(data_container const &c, pop_satisfaction_wrapper_id id) noexcept
bool has_naval_base_being_built(sys::state &state, dcon::province_id id)
Definition: province.cpp:384
bool can_build_naval_base(sys::state &state, dcon::province_id id, dcon::nation_id n)
Definition: province.cpp:391
constexpr uint16_t to_map_id(dcon::province_id id)
Definition: province.hpp:10
uint32_t pack_color(float r, float g, float b)
std::vector< uint32_t > naval_map_from(sys::state &state)
Definition: naval.hpp:5
uint uint32_t
uchar uint8_t