#############
# Resource buildings
#############
building_foundry_1 = {
	can_build = yes
	base_buildtime = @b1_time
	category = manufacturing

	building_sets = {
		industrial
		foundry
	}

	potential = {
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
		AND = {
			exists = owner
			owner = {
				is_wilderness_empire = no
			}
			OR = {
				has_carrier_flag = ignore_ai_building_limitations
				owner = {
					is_ai = no
				}

				# AI is allowed to build one of these if they have an industrial specialization.
				AND = {
					has_any_industrial_zone = yes
					NOR = {
						has_building = building_foundry_1
						has_building = building_foundry_2
						has_building = building_foundry_3
					}
				}

				# Nomadic AI is allowed to build up to 3 of these total across all tiers.
				AND = {
					owner = { is_nomadic = yes }
					tiered_building_below_cap = {
						BUILDING = foundry
					}
				}
			}
		}
	}

	destroy_trigger = {
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
	}

	prerequisites = {
		tech_basic_industry
	}
	show_tech_unlock_if = {
		is_wilderness_empire = no
	}

	allow = {
	}

	ai_weight_coefficient = @static_jobs_ai_weight_coefficient

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b1_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		upkeep = {
			energy = @b1_upkeep
		}
	}

	inline_script = {
		script = jobs/foundry_add
		AMOUNT = @building_static_jobs
	}

	upgrades = {
		"building_foundry_2"
	}
}

building_foundry_2 = {
	base_buildtime = @b2_time
	category = manufacturing
	can_build = no
	building_sets = {
		industrial
		foundry
	}

	potential = {
		exists = owner
		owner = { is_wilderness_empire = no } # see 'building_natural_furnace_2'
		is_special_colony_type = no
	}
	allow = {
	}
	destroy_trigger = {
		OR = {
			NOT = { exists = owner }
			has_modifier = resort_colony
			has_modifier = slave_colony
			owner = { is_wilderness_empire = yes }
		}
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b2_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			volatile_motes = @b3_rare_cost
		}
		upkeep = {
			energy = @b2_upkeep
			volatile_motes = @b3_rare_upkeep
		}
	}

	prerequisites = {
		tech_alloys_1
	}

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}

	inline_script = {
		script = jobs/foundry_add
		AMOUNT = @building_static_jobs_high
	}

	upgrades = {
		"building_foundry_3"
	}
}

building_foundry_3 = {
	base_buildtime = @b3_time
	category = manufacturing
	can_build = no
	building_sets = {
		foundry
		industrial
	}

	potential = {
		exists = owner
		owner = { is_wilderness_empire = no } # see 'building_natural_furnace_3'
		is_special_colony_type = no
	}
	allow = {
	}
	destroy_trigger = {
		exists = owner
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			owner = { is_wilderness_empire = yes }
		}
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b3_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			volatile_motes = @b4_rare_cost
		}
		upkeep = {
			energy = @b3_upkeep
			volatile_motes = @b4_rare_upkeep
		}
	}

	prerequisites = {
		tech_alloys_2
	}

	inline_script = {
		script = jobs/foundry_add
		AMOUNT = @building_static_jobs_very_high
	}
}

building_factory_1 = {
	can_build = yes
	base_buildtime = @b1_time
	category = manufacturing

	building_sets = {
		industrial
		factory
	}

	potential = {
		exists = owner
		owner = {
			OR = {
				country_uses_consumer_goods = yes
				has_origin = origin_fear_of_the_dark
			}
		}
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
		OR = {
			has_carrier_flag = ignore_ai_building_limitations
			owner = {
				is_ai = no
			}

			# Obsessional machines can build these freely. Have fun paperclipping.
			owner = {
				has_valid_civic = civic_machine_obsessional_directive
			}

			# AI is allowed to build one of these if they have a FACTORY specialization - intentionally more restrictive than foundries.
			AND = {
				has_any_factory_zone = yes
				NOR = {
					has_building = building_factory_1
					has_building = building_factory_2
					has_building = building_factory_3
				}
			}

			# Nomadic AI is allowed to build up to 3 of these total across all tiers.
			AND = {
				owner = { is_nomadic = yes }
				tiered_building_below_cap = {
					BUILDING = factory
				}
			}
		}
	}

	destroy_trigger = {
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony

			AND = {
				exists = owner
				OR = {
					owner = {
						AND = {
							country_uses_consumer_goods = no
							NOT = { has_origin = origin_fear_of_the_dark }
						}
					}
				}
			}
		}
	}

	allow = {
	}

	ai_weight_coefficient = @static_jobs_ai_weight_coefficient

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b1_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		upkeep = {
			energy = @b1_upkeep
		}
	}

	inline_script = {
		script = jobs/factory_add
		AMOUNT = @building_static_jobs
	}

	prerequisites = {
		tech_basic_industry
	}

	upgrades = {
		"building_factory_2"
	}
}

building_factory_2 = {
	base_buildtime = @b2_time
	category = manufacturing
	can_build = no
	building_sets = {
		factory
		industrial
	}

	allow = {
	}

	potential = {
		exists = owner
		owner = {
			country_uses_consumer_goods = yes
		}
		NOT = {
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
	}

	destroy_trigger = {
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			AND = {
				exists = owner
				owner = { country_uses_consumer_goods = no }
			}
		}
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b2_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			rare_crystals = @b3_rare_cost
		}
		upkeep = {
			energy = @b2_upkeep
			rare_crystals = @b3_rare_upkeep
		}
	}

	inline_script = {
		script = jobs/factory_add
		AMOUNT = @building_static_jobs_high
	}

	prerequisites = {
		tech_luxuries_1
	}

	upgrades = {
		"building_factory_3"
	}
}

building_factory_3 = {
	base_buildtime = @b3_time
	category = manufacturing
	can_build = no
	building_sets = {
		factory
		industrial
	}

	allow = {
	}

	potential = {
		exists = owner
		owner = {
			country_uses_consumer_goods = yes
		}
		NOT = {
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
	}

	destroy_trigger = {
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony

			AND = {
				exists = owner
				owner = { country_uses_consumer_goods = no }
			}
		}
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b3_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			rare_crystals = @b4_rare_cost
		}
		upkeep = {
			energy = @b3_upkeep
			rare_crystals = @b4_rare_upkeep
		}
	}

	inline_script = {
		script = jobs/factory_add
		AMOUNT = @building_static_jobs_very_high
	}

	prerequisites = {
		tech_luxuries_2
	}
}

building_refinery = {
	base_buildtime = @b2_time
	planet_limit = 1

	exempt_from_ai_planet_specialization = no
	category = manufacturing

	building_sets = {
		industrial
		factory
		foundry
	}

	potential = {
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
		exists = owner
		owner = { is_wilderness_empire = no } # see 'building_churning_stomach'
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = 500
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		upkeep = {
			energy = 3
		}
	}

	planet_modifier = {
		industrial_jobs_exotic_gases_produces_add = 0.1
	}

	triggered_planet_modifier = {
		potential = {
			industrial_jobs_are_catalytic_trigger = no
		}
		planet_metallurgists_minerals_upkeep_add = 0.5
		planet_artisans_minerals_upkeep_add = 0.5
	}

	triggered_planet_modifier = {
		potential = {
			industrial_jobs_are_catalytic_trigger = yes
		}
		planet_metallurgists_food_upkeep_add = 0.5
		planet_artisans_food_upkeep_add = 0.5
	}

	prerequisites = {
		"tech_exotic_gases"
	}
	show_tech_unlock_if = {
		is_wilderness_empire = no
	}
}

building_chemical_plant = {
	base_buildtime = @b2_time
	planet_limit = 1

	exempt_from_ai_planet_specialization = no
	category = manufacturing

	building_sets = {
		industrial
		factory
		foundry
	}

	potential = {
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
		exists = owner
		owner = { is_wilderness_empire = no } # see 'building_mote_aggravator'
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b2_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		upkeep = {
			energy = 3
		}
	}

	planet_modifier = {
		industrial_jobs_volatile_motes_produces_add = 0.1
	}

	triggered_planet_modifier = {
		potential = {
			industrial_jobs_are_catalytic_trigger = no
		}
		planet_metallurgists_minerals_upkeep_add = 0.5
		planet_artisans_minerals_upkeep_add = 0.5
	}


	triggered_planet_modifier = {
		potential = {
			industrial_jobs_are_catalytic_trigger = yes
		}
		planet_metallurgists_food_upkeep_add = 0.5
		planet_artisans_food_upkeep_add = 0.5
	}

	prerequisites = {
		"tech_volatile_motes"
	}
	show_tech_unlock_if = {
		is_wilderness_empire = no
	}
}

building_crystal_plant = {
	base_buildtime = @b2_time
	planet_limit = 1

	exempt_from_ai_planet_specialization = no
	category = manufacturing

	building_sets = {
		industrial
		factory
		foundry
	}

	potential = {
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
		exists = owner
		owner = { is_wilderness_empire = no }
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b2_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		upkeep = {
			energy = 3
		}
	}

	planet_modifier = {
		industrial_jobs_rare_crystals_produces_add = 0.1
	}

	triggered_planet_modifier = {
		potential = {
			industrial_jobs_are_catalytic_trigger = no
		}
		planet_metallurgists_minerals_upkeep_add = 0.5
		planet_artisans_minerals_upkeep_add = 0.5
	}


	triggered_planet_modifier = {
		potential = {
			industrial_jobs_are_catalytic_trigger = yes
		}
		planet_metallurgists_food_upkeep_add = 0.5
		planet_artisans_food_upkeep_add = 0.5
	}

	prerequisites = {
		"tech_rare_crystals"
	}

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}

	upgrades = {
		"building_crystal_plant_2"
	}
}

building_nanite_transmuter = {
	base_buildtime = @b3_time

	category = manufacturing

	building_sets = {
		industrial
		factory
		foundry
	}

	potential = {
		exists = owner
		OWNER = {
			OR = {
				has_monthly_income = {
					resource = nanites
					value > 0
				}
				AND = {
					is_ai = no
					has_resource = {
						type = nanites
						amount > 0
					}
				}
			}
		}
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
	}

	allow = {
		has_upgraded_capital = yes
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = 1000
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		produces = {
			trigger = {
				owner = {
					NOT = {
						has_deficit = nanites
					}
				}
			}
			rare_crystals = 5
			volatile_motes = 5
			exotic_gases = 5
		}
		upkeep = {
			nanites = 2
			energy = 5
		}
	}

	prerequisites = {
		"tech_nanite_transmutation"
	}

	ai_resource_production = {
		rare_crystals = @b3_rare_upkeep
		volatile_motes = @b3_rare_upkeep
		exotic_gases = @b3_rare_upkeep
		trigger = {
			always = yes
		}
	}
}

building_ministry_production = {
	base_buildtime = @b2_time
	planet_limit = 1
	icon = building_production_center

	category = manufacturing

	building_sets = {
		industrial
		factory
		foundry
	}

	potential = {
		exists = owner
		owner = {
			is_regular_empire = yes
		}
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
		}

		OR = {
			has_carrier_flag = ignore_ai_building_limitations
			owner = {
				is_ai = no
			}
			has_any_industrial_zone = yes
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			owner = { is_regular_empire = no }
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
	}

	allow = {
		has_major_upgraded_capital = yes
	}

	inline_script = {
		script = "jobs/politician_add"
		AMOUNT = @building_static_jobs
	}

	planet_modifier = {
		planet_metallurgists_alloys_produces_add = 0.2
		planet_artisans_consumer_goods_produces_add = 0.2
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b2_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			volatile_motes = @b2_rare_cost
		}
		upkeep = {
			energy = @b2_upkeep
			volatile_motes = @b2_rare_upkeep
		}
	}

	prerequisites = {
		"tech_global_production_strategy"
	}

	show_tech_unlock_if = {
		is_regular_empire = yes
	}

	inline_script = {
		script = districts/ai_alloys_extra_weighting
		AMOUNT = 10
	}

	inline_script = {
		script = districts/ai_consumer_goods_extra_weighting
		AMOUNT = 10
	}
}

building_production_center = {
	base_buildtime = @b2_time
	planet_limit = 1

	category = manufacturing

	building_sets = {
		industrial
		factory
		foundry
	}

	potential = {
		exists = owner
		owner = {
			is_gestalt = yes
			is_wilderness_empire = no
		}

		OR = {
			has_carrier_flag = ignore_ai_building_limitations
			owner = {
				is_ai = no
			}
			has_any_industrial_zone = yes
		}
	}

	destroy_trigger = {
		exists = owner
		owner = { is_gestalt = no }
	}

	allow = {
		has_major_upgraded_capital = yes
	}

	planet_modifier = {
		planet_metallurgists_alloys_produces_add = 0.2
		planet_artisans_consumer_goods_produces_add = 0.2
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b2_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			volatile_motes = @b2_rare_cost
		}
		upkeep = {
			energy = @b2_upkeep
			volatile_motes = @b2_rare_upkeep
		}
	}

	inline_script = {
		script = jobs/foundry_add
		AMOUNT = @b1_jobs
	}

	prerequisites = {
		"tech_global_production_strategy"
	}

	show_tech_unlock_if = {
		is_gestalt = yes
		is_wilderness_empire = no
	}

	inline_script = {
		script = districts/ai_alloys_extra_weighting
		AMOUNT = 10
	}

	inline_script = {
		script = districts/ai_consumer_goods_extra_weighting
		AMOUNT = 10
	}
}

building_coordinated_fulfillment_center_1 = {
	base_buildtime = @b1_time
	planet_limit = 1

	category = manufacturing

	building_sets = {
		industrial
		factory
		foundry
	}

	potential = {
		exists = owner
		owner = {
			is_relentless_industrialist_empire = yes
		}
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
		}

		OR = {
			has_carrier_flag = ignore_ai_building_limitations
			owner = {
				is_ai = no
			}
			has_any_industrial_zone = yes
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			owner = { is_relentless_industrialist_empire = no }
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
	}

	prerequisites = {
		tech_basic_industry
	}

	show_tech_unlock_if = {
		is_relentless_industrialist_empire = yes
	}

	allow = {
		has_upgraded_capital = yes
	}

	triggered_desc = {
		trigger = {
			NOR = {
				is_planet_class = pc_nuked
				is_planet_class = pc_city
				uses_district_set = habitat
				uses_district_set = ring_world
				uses_district_set = shattered_ring_world
			}
		}
		text = building_coordinated_fulfillment_center_tooltip
	}

	planet_modifier = {
		planet_metallurgists_alloys_produces_add = 0.2
		planet_artisans_consumer_goods_produces_add = 0.2
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_policy_flag = relentless_industrialists_full_steam_ahead }
		}
		modifier = {
			planet_metallurgists_alloys_produces_add = 0.1
			planet_artisans_consumer_goods_produces_add = 0.1
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { is_synthetic_empire = no }
		}
		modifier = {
			logistic_growth_mult = -0.15
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				is_synthetic_empire = no
				NAND = {
					has_policy_flag = relentless_industrialists_study
					has_country_flag = relentless_industrialists_study_completed
				}
			}
		}
		modifier = {
			logistic_growth_mult = -0.05
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { is_synthetic_empire = yes }
		}
		modifier = {
			habitability_ceil_add = -0.075
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				owner = { is_synthetic_empire = yes }
				NAND = {
					has_policy_flag = relentless_industrialists_study
					has_country_flag = relentless_industrialists_study_completed
				}
			}
		}
		modifier = {
			habitability_ceil_add = -0.025
		}
	}

	upgrades = {
		building_coordinated_fulfillment_center_2
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b1_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		upkeep = {
			energy = @b1_upkeep
		}
		upkeep = {
			unity = 10
			trigger = {
				owner = { has_policy_flag = relentless_industrialists_cleanup }
			}
		}
	}

	inline_script = {
		script = districts/ai_alloys_extra_weighting
		AMOUNT = 10
	}

	inline_script = {
		script = districts/ai_consumer_goods_extra_weighting
		AMOUNT = 10
	}
}

building_coordinated_fulfillment_center_2 = {
	base_buildtime = @b2_time
	can_build = no

	category = manufacturing

	building_sets = {
		industrial
		factory
		foundry
	}

	destroy_trigger = {
		exists = owner
		OR = {
			owner = { is_relentless_industrialist_empire = no }
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
	}

	allow = {
		has_major_upgraded_capital = yes
	}

	triggered_desc = {
		trigger = {
			NOR = {
				is_planet_class = pc_nuked
				is_planet_class = pc_city
				uses_district_set = habitat
				uses_district_set = ring_world
				uses_district_set = shattered_ring_world
			}
		}
		text = building_coordinated_fulfillment_center_tooltip
	}

	planet_modifier = {
		planet_metallurgists_alloys_produces_add = 0.3
		planet_artisans_consumer_goods_produces_add = 0.3
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_policy_flag = relentless_industrialists_full_steam_ahead }
		}
		modifier = {
			planet_metallurgists_alloys_produces_add = 0.2
			planet_artisans_consumer_goods_produces_add = 0.2
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { is_synthetic_empire = no }
		}
		modifier = {
			logistic_growth_mult = -0.25
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				is_synthetic_empire = no
				NAND = {
					has_policy_flag = relentless_industrialists_study
					has_country_flag = relentless_industrialists_study_completed
				}
			}
		}
		modifier = {
			logistic_growth_mult = -0.15
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { is_synthetic_empire = yes }
		}
		modifier = {
			habitability_ceil_add = -0.1
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				owner = { is_synthetic_empire = yes }
				NAND = {
					has_policy_flag = relentless_industrialists_study
					has_country_flag = relentless_industrialists_study_completed
				}
			}
		}
		modifier = {
			habitability_ceil_add = -0.05
		}
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b2_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			volatile_motes = @b3_rare_cost
		}
		upkeep = {
			energy = @b2_upkeep
			volatile_motes = @b3_rare_upkeep
		}
		upkeep = {
			unity = 20
			trigger = {
				owner = { has_policy_flag = relentless_industrialists_cleanup }
			}
		}
	}

	prerequisites = {
		tech_global_production_strategy
	}

	show_tech_unlock_if = {
		is_relentless_industrialist_empire = yes
	}

	inline_script = {
		script = districts/ai_alloys_extra_weighting
		AMOUNT = 15
	}

	inline_script = {
		script = districts/ai_consumer_goods_extra_weighting
		AMOUNT = 15
	}
}

building_archaeo_refinery = {
	base_buildtime = @b3_time
	planet_limit = 1

	category = manufacturing

	building_sets = {
		industrial
		factory
		foundry
	}

	potential = {
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
		owner = { has_technology = tech_archaeo_refinery }
	}

	planet_modifier = {
		planet_jobs_exotic_gases_produces_mult = 0.1
		planet_jobs_rare_crystals_produces_mult = 0.1
		planet_jobs_volatile_motes_produces_mult = 0.1
		industrial_jobs_exotic_gases_produces_add = 0.1
		industrial_jobs_rare_crystals_produces_add = 0.1
		industrial_jobs_volatile_motes_produces_add = 0.1
	}

	triggered_planet_modifier = {
		potential = {
			owner = {
				has_ascension_perk = ap_archaeoengineers
			}
		}
		planet_jobs_exotic_gases_produces_mult = 0.05
		planet_jobs_rare_crystals_produces_mult = 0.05
		planet_jobs_volatile_motes_produces_mult = 0.05
	}

	triggered_planet_modifier = {
		potential = {
			industrial_jobs_are_catalytic_trigger = no
		}
		planet_metallurgists_minerals_upkeep_add = 1
		planet_artisans_minerals_upkeep_add = 1
	}

	triggered_planet_modifier = {
		potential = {
			industrial_jobs_are_catalytic_trigger = yes
		}
		planet_metallurgists_food_upkeep_add = 1.5
		planet_artisans_food_upkeep_add = 1.5
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b2_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			minor_artifacts = @b4_rare_cost		# Deliberately higher than expected
		}
		upkeep = {
			energy = @b2_upkeep
		}
	}

	prerequisites = {
		"tech_archaeo_refinery"
	}
}

building_foundry_upkeep_1 = {
	base_buildtime = @b2_time
	planet_limit = 1
	category = manufacturing

	building_sets = {
		foundry
		industrial
	}

	potential = {
		exists = owner
		owner = { is_wilderness_empire = no } # see 'building_natural_furnace_2'
		NOT = {
			has_modifier = resort_colony
		}
	}
	destroy_trigger = {
		OR = {
			NOT = { exists = owner }
			has_modifier = resort_colony
			has_modifier = slave_colony
			owner = { is_wilderness_empire = yes }
		}
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b2_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			volatile_motes = @b3_rare_cost
		}
		upkeep = {
			energy = @b2_upkeep
			volatile_motes = @b3_rare_upkeep
		}
	}

	prerequisites = {
		tech_alloys_1
	}

	planet_modifier = {
		planet_metallurgists_upkeep_mult = -0.10
	}

	ai_resource_production = {
		minerals = 10
		trigger = {
			exists = owner
			owner = {
				is_catalytic_empire = no
			}
			has_any_foundry_zone = yes
		}
	}

	ai_resource_production = {
		food = 10
		trigger = {
			exists = owner
			owner = {
				is_catalytic_empire = yes
			}
			has_any_foundry_zone = yes
		}
	}

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}

}

building_foundry_efficiency_1 = {
	base_buildtime = @b3_time
	planet_limit = 1
	category = manufacturing

	building_sets = {
		foundry
		industrial
	}

	potential = {
		exists = owner
		owner = { is_wilderness_empire = no } # see 'building_natural_furnace_3'
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			owner = { is_wilderness_empire = yes }
		}
	}
	destroy_trigger = {
		exists = owner
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			owner = { is_wilderness_empire = yes }
		}
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher_with_additional_trigger
			TRIGGER = "has_ringworld_output_boost = no"
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b3_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			trigger = {
				has_ringworld_output_boost = no
			}
			volatile_motes = @b4_rare_cost
		}
		inline_script = {
			script = buildings/nomadic_cost_switcher_with_additional_trigger
			TRIGGER = "has_ringworld_output_boost = yes"
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = 1500
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			trigger = {
				has_ringworld_output_boost = yes
			}
			volatile_motes = 600
		}
		upkeep = {
			trigger = {
				has_ringworld_output_boost = no
			}
			energy = @b3_upkeep
			volatile_motes = @b4_rare_upkeep
		}
		upkeep = {
			trigger = {
				has_ringworld_output_boost = yes
			}
			energy = 15
			volatile_motes = 8
		}
	}

	prerequisites = {
		tech_alloys_2
	}

	planet_modifier = {
		foundry_jobs_bonus_workforce_mult = 0.10
	}

	ai_resource_production = {
		alloys = 10
		trigger = {
			has_any_foundry_zone = yes
		}
	}

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}
}

building_factory_upkeep_1 = {
	base_buildtime = @b2_time
	planet_limit = 1
	category = manufacturing

	building_sets = {
		factory
		industrial
	}

	potential = {
		exists = owner
		owner = {
			country_uses_consumer_goods = yes
		}
		NOT = {
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
	}

	destroy_trigger = {
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			AND = {
				exists = owner
				owner = { country_uses_consumer_goods = no }
			}
		}
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b2_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			rare_crystals = @b3_rare_cost
		}
		upkeep = {
			energy = @b2_upkeep
			rare_crystals = @b3_rare_upkeep
		}
	}

	planet_modifier = {
		planet_artisans_upkeep_mult = -0.10
	}

	ai_resource_production = {
		minerals = 10
		trigger = {
			exists = owner
			owner = {
				is_catalytic_empire = no
			}
			has_any_foundry_zone = yes
		}
	}

	ai_resource_production = {
		food = 10
		trigger = {
			exists = owner
			owner = {
				is_catalytic_empire = yes
			}
			has_any_foundry_zone = yes
		}
	}

	prerequisites = {
		tech_luxuries_1
	}
}

building_factory_efficiency_1 = {
	base_buildtime = @b3_time
	planet_limit = 1
	category = manufacturing

	building_sets = {
		factory
		industrial
	}

	potential = {
		exists = owner
		owner = {
			country_uses_consumer_goods = yes
		}
		NOT = {
			has_modifier = resort_colony
			has_modifier = slave_colony
		}
	}

	destroy_trigger = {
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony

			AND = {
				exists = owner
				owner = { country_uses_consumer_goods = no }
			}
		}
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher_with_additional_trigger
			TRIGGER = "has_ringworld_output_boost = no"
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = rare_crystals
			COST = @b3_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			trigger = {
				has_ringworld_output_boost = no
			}
			rare_crystals = @b4_rare_cost
		}
		inline_script = {
			script = buildings/nomadic_cost_switcher_with_additional_trigger
			TRIGGER = "has_ringworld_output_boost = yes"
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = rare_crystals
			COST = 1500
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			trigger = {
				has_ringworld_output_boost = yes
			}
			rare_crystals = 600
		}
		upkeep = {
			trigger = {
				has_ringworld_output_boost = no
			}
			energy = @b3_upkeep
			rare_crystals = @b4_rare_upkeep
		}
		upkeep = {
			trigger = {
				has_ringworld_output_boost = yes
			}
			energy = 15
			rare_crystals = 8
		}
	}

	planet_modifier = {
		artisan_jobs_bonus_workforce_mult = 0.10
	}

	ai_resource_production = {
		consumer_goods = 10
		trigger = {
			has_any_factory_zone = yes
		}
	}

	prerequisites = {
		tech_luxuries_2
	}
}

building_offworld_expedition_hub = {
	base_buildtime = @b2_time
	planet_limit = 1
	category = manufacturing

	building_sets = {
		factory
		foundry
		industrial
	}

	allow = {
		custom_tooltip = {
			fail_text = offworld_molten_world_req
			OR = {
				owner = { is_nomadic = yes }
				solar_system? = {
					any_system_planet = {
						is_planet_class = pc_molten
					}
				}
			}
		}
	}
	potential = {
		exists = owner
		owner = {
			is_galvanic_empire = yes
		}
	}
	destroy_trigger = {
		exists = owner
		owner = {
			is_galvanic_empire = no
		}
	}
	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b2_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		upkeep = { energy = @b2_upkeep }
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { is_gestalt = no }
		}
		job_offworld_prospector_add = @building_static_jobs
	}
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { is_gestalt = yes }
		}
		job_offworld_prospector_drone_add = @building_static_jobs
	}
}
