15 parse_good(gen, err, new_context);
18 if(name ==
"military_goods") {
20 parse_goods_group(gen, err, new_context);
21 }
else if(name ==
"raw_material_goods") {
23 parse_goods_group(gen, err, new_context);
24 }
else if(name ==
"industrial_goods") {
26 parse_goods_group(gen, err, new_context);
27 }
else if(name ==
"consumer_goods") {
29 parse_goods_group(gen, err, new_context);
31 }
else if(name ==
"industrial_and_consumer_goods") {
33 parse_goods_group(gen, err, new_context);
37 parse_goods_group(gen, err, new_context);
44 }
else if(
is_fixed_token_ci(value.data(), value.data() + value.length(),
"province_selector")) {
47 }
else if(
is_fixed_token_ci(value.data(), value.data() + value.length(),
"immigrator")
48 ||
is_fixed_token_ci(value.data(), value.data() + value.length(),
"immigrator_selector")
49 ||
is_fixed_token_ci(value.data(), value.data() + value.length(),
"province_immigrator")) {
52 }
else if(
is_fixed_token_ci(value.data(), value.data() + value.length(),
"infrastructure")) {
62 "Unknown building type " + std::string(value) +
" in file " + err.
file_name +
" line " + std::to_string(line) +
"\n";
71 auto factory_id = context.
state.
world.create_factory_type();
77 context.
state.
world.factory_type_set_description(factory_id, desc_id);
78 context.
state.
world.factory_type_set_construction_time(factory_id, int16_t(res.time));
79 context.
state.
world.factory_type_set_is_available_from_start(factory_id, res.default_enabled);
85 auto& cc = context.
state.
world.factory_type_get_construction_costs(factory_id);
86 context.
state.
world.for_each_commodity([&](dcon::commodity_id
id) {
87 auto amount = res.goods_cost.data.safe_get(
id);
92 cc.commodity_type[added] = id;
93 cc.commodity_amounts[added] = amount;
98 if(res.production_type.length() > 0) {
108 auto t = res.stored_type;
112 for(
uint32_t i = 0; i < 8 && i < res.colonial_points.data.size(); ++i)
117 context.
state.
world.for_each_commodity([&](dcon::commodity_id
id) {
118 auto amount = res.goods_cost.data.safe_get(
id);
133 if(res.next_to_add_p != 0) {
136 res.peek_province_mod());
138 res.peek_national_mod());
154 auto pt = parse_production_type(gen, err, context);
156 if(!
bool(pt.output_goods_)) {
165 for(
auto& wt : pt.employees.employees) {
171 context.
templates.insert_or_assign(std::string(name), std::move(pt));
180 auto amount = pt.input_goods.data.safe_get(
id);
201 auto amount = pt.input_goods.data.safe_get(
id);
216 auto amount = pt.efficiency.data.safe_get(
id);
228 factory_handle.set_inputs(cset);
229 factory_handle.set_efficiency_inputs(sm_cset);
230 factory_handle.set_output(pt.output_goods_);
231 factory_handle.set_output_amount(pt.value);
232 factory_handle.set_is_coastal(pt.is_coastal);
233 factory_handle.set_base_workforce(pt.workforce);
235 if(pt.bonuses.size() >= 1) {
236 factory_handle.set_bonus_1_amount(pt.bonuses[0].value);
237 factory_handle.set_bonus_1_trigger(pt.bonuses[0].trigger);
239 if(pt.bonuses.size() >= 2) {
240 factory_handle.set_bonus_2_amount(pt.bonuses[1].value);
241 factory_handle.set_bonus_2_trigger(pt.bonuses[1].trigger);
243 if(pt.bonuses.size() >= 3) {
244 factory_handle.set_bonus_3_amount(pt.bonuses[2].value);
245 factory_handle.set_bonus_3_trigger(pt.bonuses[2].trigger);
247 if(pt.bonuses.size() >= 4) {
248 err.
accumulated_errors +=
"Too many factory bonuses (" + std::to_string(pt.bonuses.size()) +
") for " + std::string(name) +
" (" + err.
file_name +
")\n";
257 return parse_commodity_array(gen, err, context.
outer_context);
std::string accumulated_errors
std::string accumulated_warnings
std::string_view province_building_type_get_name(economy::province_building_type v)
dcon::trigger_key make_trigger(token_generator &gen, error_handler &err, trigger_building_context &context)
void make_goods_group(std::string_view name, token_generator &gen, error_handler &err, scenario_building_context &context)
dcon::trigger_key make_production_bonus_trigger(token_generator &gen, error_handler &err, production_context &context)
void make_good(std::string_view name, token_generator &gen, error_handler &err, good_group_context &context)
bool is_fixed_token_ci(char const *start, char const *end, char const (&t)[N])
void make_production_type(std::string_view name, token_generator &gen, error_handler &err, production_context &context)
commodity_array make_prod_commodity_array(token_generator &gen, error_handler &err, production_context &context)
@ industrial_and_consumer_goods
dcon::text_key find_or_add_key(sys::state &state, std::string_view key, bool as_unicode)
dcon::pop_type_id secondary_factory_worker
dcon::pop_type_id primary_factory_worker
dcon::pop_type_id aristocrat
float commodity_amounts[set_size]
dcon::commodity_id commodity_type[set_size]
static constexpr uint32_t set_size
dcon::modifier_id selector_modifier
building_information building_definitions[max_building_types]
dcon::modifier_id immigrator_modifier
float commodity_amounts[set_size]
static constexpr uint32_t set_size
dcon::commodity_id commodity_type[set_size]
void type(association_type, std::string_view value, error_handler &err, int32_t line, scenario_building_context &context)
economy::province_building_type stored_type
void result(std::string_view name, building_definition &&res, error_handler &err, int32_t line, scenario_building_context &context)
sys::commodity_group group
scenario_building_context & outer_context
scenario_building_context & outer_context
ankerl::unordered_dense::map< std::string, production_type > templates
ankerl::unordered_dense::map< std::string, dcon::factory_type_id > map_of_production_types
ankerl::unordered_dense::map< std::string, dcon::commodity_id > map_of_commodity_names
ankerl::unordered_dense::map< std::string, dcon::factory_type_id > map_of_factory_names
culture::global_cultural_state culture_definitions
dcon::data_container world
economy::global_economy_state economy_definitions