4#include "dcon_generated.hpp"
10 return float(v & 0xFF) / 255.0f;
13 return float((v >> 8) & 0xFF) / 255.0f;
16 return float((v >> 16) & 0xFF) / 255.0f;
19 return ((
uint32_t(r * 255.0f) & 0xFF) << 0) | ((
uint32_t(g * 255.0f) & 0xFF) << 8) | ((
uint32_t(b * 255.0f) & 0xFF) << 16);
23 return int32_t(v & 0xFF);
26 return int32_t((v >> 8) & 0xFF);
29 return int32_t((v >> 16) & 0xFF);
46 auto cmin = std::min(r, std::min(g, b));
47 auto cmax = std::max(r, std::max(g, b));
48 auto delta = cmax - cmin;
53 }
else if(cmax == r) {
54 h = 60.0f * (fmod((g - b) / delta, 6.0f));
55 }
else if(cmax == g) {
56 h = 60.0f * ((b - r) / delta + 2.0f);
58 h = 60.0f * ((r - g) / delta + 4.0f);
63 cmax == 0.0f ? 0.0f : delta / cmax,
70 auto x = c * (1.0f - std::abs(fmod(v.
h / 60.0f, 2.0f) - 1.0f));
72 float r = 0.0f;
float g = 0.0f;
float b = 0.0f;
73 if(0.0f <= v.
h && v.
h < 60.0f) {
74 r = c; g = x; b = 0.0f;
75 }
else if(60.0f <= v.
h && v.
h < 120.0f) {
76 r = x; g = c; b = 0.0f;
77 }
else if(120.0f <= v.
h && v.
h < 180.0f) {
78 r = 0.0f; g = c; b = x;
79 }
else if(180.0f <= v.
h && v.
h < 240.0f) {
80 r = 0.0f; g = x; b = c;
81 }
else if(240.0f <= v.
h && v.
h < 300.0f) {
82 r = x; g = 0.0f; b = c;
84 r = c; g = 0.0f; b = x;
87 std::clamp(r + m, 0.0f, 255.0f),
88 std::clamp(g + m, 0.0f, 255.0f),
89 std::clamp(b + m, 0.0f, 255.0f)
131 int32_t index = m.index();
132 return ankerl::unordered_dense::hash<int32_t>()(index);
152template<
typename value_type,
typename tag_type,
typename allocator = std::allocator<value_type>>
155 std::vector<value_type, allocator> storage;
165 storage.resize(
size);
169 storage = other.storage;
173 storage = std::move(other.storage);
177 assert(
size_t(t.index()) < storage.size());
178 return *(storage.data() + t.index());
181 assert(
size_t(t.index()) < storage.size());
182 return *(storage.data() + t.index());
184 template<
typename... T>
186 storage.emplace_back(std::forward<T>(ts)...);
187 return tag_type(
typename tag_type::value_base_t(storage.size() - 1));
190 if(t.index() >= std::ssize(storage))
191 storage.resize(t.index() + 1);
192 return storage[t.index()];
195 return storage.data();
198 return storage.data();
201 return storage.data();
204 return storage.data();
207 return storage.begin();
210 return storage.end();
213 return storage.begin();
216 return storage.end();
219 return storage.size();
222 return std::ssize(storage);
225 storage.resize(
size);
228 storage.reserve(
size);
234 storage.push_back(v);
235 return tag_type(
typename tag_type::value_base_t(storage.size() - 1));
238 storage.push_back(std::move(v));
239 return tag_type(
typename tag_type::value_base_t(storage.size() - 1));
242 return storage.back();
244 value_type
const&
back()
const {
245 return storage.back();
257static_assert(
sizeof(commodity_set) ==
282 for(
size_t i = 0; i <
key_size; i++)
283 if(
key[i] != a.key[i])
291 char data[48] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
295 if(
data[i] ==
' ' ||
data[i] ==
'\0') {
296 return std::string_view{
reinterpret_cast<const char*
>(&
data[0]),
uint32_t(i) };
312 return std::memcmp(
this, &o,
sizeof(*
this));
value_type & operator[](tag_type t)
tagged_vector(tagged_vector< value_type, tag_type, allocator > &&other) noexcept
value_type const & operator[](tag_type t) const
tagged_vector & operator=(tagged_vector< value_type, tag_type, allocator > &&other) noexcept
tagged_vector(tagged_vector< value_type, tag_type, allocator > const &other) noexcept
tagged_vector(size_t size)
tag_type push_back(value_type &&v)
tag_type push_back(value_type const &v)
void reserve(size_t size)
value_type const & back() const
tag_type emplace_back(T &&... ts)
value_type public_value_type
value_type & safe_get(tag_type t)
tagged_vector & operator=(tagged_vector< value_type, tag_type, allocator > const &other) noexcept
#define assert(condition)
float blue_from_int(uint32_t v)
float green_from_int(uint32_t v)
uint32_t pack_color(float r, float g, float b)
float red_from_int(uint32_t v)
uint32_t hsv_to_rgb(hsv v)
int32_t int_red_from_int(uint32_t v)
int32_t int_blue_from_int(uint32_t v)
hsv rgb_to_hsv(uint32_t v)
int32_t int_green_from_int(uint32_t v)
float commodity_amounts[set_size]
dcon::commodity_id commodity_type[set_size]
static constexpr uint32_t set_size
float commodity_amounts[set_size]
static constexpr uint32_t set_size
dcon::commodity_id commodity_type[set_size]
static constexpr uint32_t key_size
bool is_equal(const checksum_key &a) noexcept
dcon::national_identity_id wargoal_tag
dcon::state_definition_id wargoal_state
dcon::nation_id wargoal_secondary_nation
dcon::cb_type_id wargoal_type
dcon::value_modifier_key ai_chance
bool operator!=(macro_builder_template &o)
sys::checksum_key scenario_checksum
uint8_t amounts[max_types]
static constexpr uint32_t max_types
auto operator()(dcon::modifier_id m) const noexcept -> uint64_t
std::string_view to_string_view() noexcept
uint16_t first_segment_offset
dcon::trigger_key condition