#############
# Science buildings
#############
building_research_lab_1 = {
	can_build = yes
	base_buildtime = @b1_time
	exempt_from_ai_planet_specialization = no

	category = research

	building_sets = {
		research
	}

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

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

			# AI is allowed to build one of these.
			AND = {
				has_any_research_zone = yes
				NOR = {
					has_building = building_research_lab_1
					has_building = building_research_lab_2
					has_building = building_research_lab_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 = research_lab
				}
			}
		}
	}

	allow = {
	}

	ai_weight_coefficient = @static_jobs_ai_weight_coefficient

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

	inline_script = {
		script = jobs/researchers_add
		AMOUNT = @building_static_jobs_3
	}

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

	prerequisites = {
		"tech_basic_science_lab_1"
	}

	upgrades = {
		"building_research_lab_2"
	}
}

building_research_lab_2 = {
	base_buildtime = @b2_time
	can_build = no
	category = research

	building_sets = {
		research
	}

	potential = {
		exists = owner
		owner = {
			is_wilderness_empire = no # see 'building_brain_node_3'
		}
		is_special_colony_type = no
	}

	allow = {
	}

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

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

	inline_script = {
		script = jobs/researchers_add
		AMOUNT = @building_static_jobs_high_3
	}

	prerequisites = {
		"tech_basic_science_lab_2"
	}

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}
	upgrades = {
		"building_research_lab_3"
	}
}

building_research_lab_3 = {
	base_buildtime = @b3_time
	category = research
	can_build = no
	building_sets = {
		research
	}

	potential = {
		exists = owner
		owner = {
			is_wilderness_empire = no # see 'building_brain_node_4'
		}
		is_special_colony_type = no
	}

	allow = {
	}

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

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = exotic_gases
			COST = @b3_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			exotic_gases = @b3_rare_cost
		}
		upkeep = {
			energy = @b3_upkeep
			exotic_gases = @b3_rare_upkeep
		}
	}

	inline_script = {
		script = jobs/researchers_add
		AMOUNT = @building_static_jobs_very_high_3
	}

	prerequisites = {
		"tech_basic_science_lab_3"
	}

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}
}

building_institute = {
	base_buildtime = @b2_time
	planet_limit = 1
	category = research

	building_sets = {
		research
	}

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

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

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

	convert_to = {
		building_supercomputer
	}

	allow = {
	}

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

	planet_modifier = {
		planet_physicists_physics_research_produces_add = 0.5
		planet_biologists_society_research_produces_add = 0.5
		planet_engineers_engineering_research_produces_add = 0.5
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				is_gestalt = no
			}
		}
		planet_researchers_consumer_goods_upkeep_add = 1
	}
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				is_machine_empire = yes
			}
		}
		planet_researchers_energy_upkeep_add = 2
	}
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				is_hive_empire = yes
			}
		}
		planet_researchers_minerals_upkeep_add = 2
	}

	inline_script = {
		script = "jobs/politician_add_from_civic"
		AMOUNT = @building_static_jobs
		CIVIC = civic_technocracy
	}

	prerequisites = {
		"tech_global_research_initiative"
	}

	show_tech_unlock_if = {
		is_regular_empire = yes
	}

	ai_weight_coefficient = 1.5

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

building_supercomputer = {
	base_buildtime = @b2_time
	planet_limit = 1
	icon = building_institute

	category = research

	building_sets = {
		research
	}

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

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

	allow = {
		has_major_upgraded_capital = yes
	}

	destroy_trigger = {
		exists = owner
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
			owner = { is_regular_empire = yes }
			owner = { is_wilderness_empire = yes }
		}
	}

	convert_to = {
		building_institute
	}

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

	planet_modifier = {
		planet_physicists_physics_research_produces_add = 0.5
		planet_biologists_society_research_produces_add = 0.5
		planet_engineers_engineering_research_produces_add = 0.5
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				is_gestalt = no
			}
		}
		planet_researchers_consumer_goods_upkeep_add = 1
	}
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				is_machine_empire = yes
			}
		}
		planet_researchers_energy_upkeep_add = 2
	}
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				is_hive_empire = yes
			}
		}
		planet_researchers_minerals_upkeep_add = 2
	}

	prerequisites = {
		"tech_global_research_initiative"
	}

	show_tech_unlock_if = {
		is_gestalt = yes
		is_wilderness_empire = no
	}

	ai_weight_coefficient = 1.5

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

# Shroud-Forged
building_shroud_observatory_1 = {
	base_buildtime = @b1_time

	exempt_from_ai_planet_specialization = no

	category = research
	building_sets = {
		research
	}

	potential = {
		exists = owner
		owner = {
			has_origin = origin_shroud_forged
		}
	}

	allow = {
		custom_tooltip = {
			fail_text = SHROUD_RIFT_MISSING_TT
			has_deposit = d_shroud_rift_deposit
		}
	}

	destroy_trigger = {
		OR = {
			NOT = { exists = owner }
			owner = { NOT = { has_origin = origin_shroud_forged } }
			NOT = { has_deposit = d_shroud_rift_deposit }
		}
	}

	inline_script = {
		script = jobs/biologists_add
		AMOUNT = @building_static_jobs		# 200 jobs
	}

	triggered_desc = {
		text = biology_unit_is_observator_tt
	}

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

	upgrades = {
		"building_shroud_observatory_2"
	}
}

building_shroud_observatory_2 = {
	base_buildtime = @b2_time
	can_build = no

	exempt_from_ai_planet_specialization = no

	category = research
	building_sets = {
		research
	}

	potential = {
		exists = owner
		owner = { has_origin = origin_shroud_forged }
	}

	allow = {
		has_upgraded_capital = yes
	}

	destroy_trigger = {
		OR = {
			NOT = { exists = owner }
			owner = { NOT = { has_origin = origin_shroud_forged } }
			NOT = { has_deposit = d_shroud_rift_deposit }
		}
	}

	inline_script = {
		script = jobs/biologists_add
		AMOUNT = @building_static_jobs		# 200 jobs
	}

	planet_modifier = {
		planet_biologists_physics_research_produces_add = 0.25
		planet_biologists_society_research_produces_add = 0.25
		planet_biologists_sr_zro_upkeep_add	= 0.25
	}

	triggered_desc = {
		text = biology_unit_is_observator_tt
	}

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

	upgrades = {
		"building_shroud_observatory_3"
	}

	prerequisites = {
		"tech_psionic_theory"
	}

	show_tech_unlock_if = {
		exists = owner
		owner = { has_origin = origin_shroud_forged }
	}
}

building_shroud_observatory_3 = {
	base_buildtime = @b3_time
	can_build = no

	exempt_from_ai_planet_specialization = no

	category = research
	building_sets = {
		research
	}

	potential = {
		exists = owner
		owner = { has_origin = origin_shroud_forged }
	}

	allow = {
		has_major_upgraded_capital = yes
	}

	destroy_trigger = {
		OR = {
			NOT = { exists = owner }
			owner = { NOT = { has_origin = origin_shroud_forged } }
			NOT = { has_deposit = d_shroud_rift_deposit }
		}
	}

	inline_script = {
		script = jobs/biologists_add
		AMOUNT = @building_static_jobs		# 200 jobs
	}

	planet_modifier = {
		planet_biologists_physics_research_produces_add = 0.5
		planet_biologists_society_research_produces_add = 0.5
		planet_biologists_sr_zro_upkeep_add	= 0.5
	}

	triggered_desc = {
		text = biology_unit_is_observator_tt
	}

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

	prerequisites = {
		"tech_mine_zro"
	}

	show_tech_unlock_if = {
		exists = owner
		owner = { has_origin = origin_shroud_forged }
	}
}

building_archaeostudies_faculty = {
	base_buildtime = @b2_time
	planet_limit = 1
	category = research

	building_sets = {
		research
	}

	empire_limit = {
		base = 1
	}

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

	destroy_trigger = {
		exists = owner
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
			owner = { is_wilderness_empire = yes }
		}
	}

	allow = {
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = exotic_gases
			COST = @b2_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			minor_artifacts = @b2_rare_cost
		}
		upkeep = {
			energy = @b3_upkeep
		}
	}

	planet_modifier = {
		planet_biologists_society_research_produces_add = 0.25
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				is_gestalt = no
			}
		}
		planet_biologists_consumer_goods_upkeep_add = 0.5
	}
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				is_machine_empire = yes
			}
		}
		planet_biologists_energy_upkeep_add = 1
	}
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				is_hive_empire = yes
			}
		}
		planet_biologists_minerals_upkeep_add = 1
	}

	triggered_planet_modifier = {
		potential = {
			is_planet_class = pc_relic
		}
		planet_biologists_minor_artifacts_produces_add = 0.25
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				has_ascension_perk = ap_archaeoengineers
			}
		}
		planet_biologists_minor_artifacts_produces_add = 0.15
	}

	triggered_country_modifier = {
		potential = {
			exists = owner
			owner = {
				has_ascension_perk = ap_archaeoengineers
			}
		}
		country_resource_max_minor_artifacts_add = 3000
	}

	triggered_country_modifier = {
		potential = {
			is_planet_class = pc_relic
		}
		category_archaeostudies_research_speed_mult = 0.25
	}

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

	country_modifier = {
		category_archaeostudies_research_speed_mult = 0.25
		country_resource_max_minor_artifacts_add = 2000
	}

	prerequisites = {
		"tech_archaeostudies"
	}

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}

	triggered_desc = {
		trigger = {
			exists = owner
			owner = {
				is_gestalt = no
			}
		}
		text = biologist_is_archaeo_engineer_tt
	}

	triggered_desc = {
		trigger = {
			exists = owner
			owner = {
				is_hive_empire = yes
			}
		}
		text = biology_drone_is_archaeo_engineer_tt
	}

	triggered_desc = {
		trigger = {
			exists = owner
			owner = {
				is_machine_empire = yes
			}
		}
		text = biology_unit_is_archaeo_engineer_tt
	}

	triggered_desc = {
		text = building_archaeostudies_faculty_relic_effect
	}

	ai_weight_coefficient = 1.5

	inline_script = {
		script = districts/ai_research_society_extra_weighting
		AMOUNT = 5
	}
}

building_vultaum_reality_computer = {
	base_buildtime = @b2_time
	planet_limit = 1
	category = research

	building_sets = {
		research
	}

	potential = {
		exists = owner
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
		}
	}

	allow = {
	}

	destroy_trigger = {
		exists = owner
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
		}
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = exotic_gases
			COST = @b2_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			minor_artifacts = @b2_rare_cost
		}
		cost = {
			trigger = {
				owner = { is_wilderness_empire = yes }
			}
			biomass = @b2_biomass
		}
		upkeep = {
			energy = @b2_upkeep
		}
	}

	inline_script = {
		script = buildings/on_all_wilderness_buildings_districts
	}

	planet_modifier = {
		planet_physicists_physics_research_produces_add = 1
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_ascension_perk = ap_archaeoengineers }
		}
		planet_physicists_physics_research_produces_add = 1
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				has_ascension_perk = ap_cosmogenesis
			}
		}
		planet_physicists_advanced_logic_produces_add = 0.25
	}

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

	inline_script = {
		script = districts/ai_research_physics_extra_weighting
		AMOUNT = 7.5
	}

	ai_weight_coefficient = 2

	prerequisites = {
		"tech_secrets_vultaum"
	}
}

building_physics_lab_1 = {
	can_build = yes
	base_buildtime = @b1_time
	planet_limit = 1
	exempt_from_ai_planet_specialization = no

	category = research

	building_sets = {
		research
		physics
	}

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

		OR = {
			has_carrier_flag = ignore_ai_building_limitations
			owner = {
				is_ai = no
			}
			has_any_research_physics_zone = yes
			has_any_unspecialized_research_zone = yes
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
			owner = { is_wilderness_empire = yes }
		}
	}

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

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

	planet_modifier = {
		planet_physicists_physics_research_produces_add = 0.25
	}

	upgrades = {
		building_physics_lab_2
	}

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}

	ai_weight_coefficient = 1.2

	inline_script = {
		script = districts/ai_research_physics_extra_weighting
		AMOUNT = 5
	}

	prerequisites = {
		"tech_physics_1"
	}
}

building_physics_lab_2 = {
	can_build = no
	base_buildtime = @b2_time
	exempt_from_ai_planet_specialization = no

	category = research

	building_sets = {
		research
		physics
	}

	potential = {
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
			owner = { is_wilderness_empire = yes }
		}
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = exotic_gases
			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/physicists_add
		AMOUNT = @building_static_jobs
	}

	planet_modifier = {
		planet_physicists_physics_research_produces_add = 0.5
		planet_physicists_volatile_motes_upkeep_add = 0.25
	}

	upgrades = {
		building_physics_lab_3
	}

	prerequisites = {
		"tech_physics_2"
	}

	inline_script = {
		script = districts/ai_research_physics_extra_weighting
		AMOUNT = 7.5
	}

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}

}

building_physics_lab_3 = {
	can_build = no
	base_buildtime = @b3_time
	exempt_from_ai_planet_specialization = no

	category = research

	building_sets = {
		research
		physics
	}

	potential = {
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
			owner = { is_wilderness_empire = yes }
		}
	}

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

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

	planet_modifier = {
		physicist_jobs_bonus_workforce_mult = 0.1
		planet_physicists_physics_research_produces_add = 0.5
		planet_physicists_volatile_motes_upkeep_add = 0.25
	}

	prerequisites = {
		"tech_physics_3"
	}

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

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}
}

building_biolab_1 = {
	can_build = yes
	base_buildtime = @b1_time
	planet_limit = 1
	exempt_from_ai_planet_specialization = no

	category = research

	building_sets = {
		research
		society
	}

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

		OR = {
			has_carrier_flag = ignore_ai_building_limitations
			owner = {
				is_ai = no
			}
			has_any_research_society_zone = yes
			has_any_unspecialized_research_zone = yes
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
			owner = { is_wilderness_empire = yes }
		}
	}

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

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

	planet_modifier = {
		planet_biologists_society_research_produces_add = 0.25
	}

	upgrades = {
		building_biolab_2
	}

	prerequisites = {
		"tech_society_1"
	}

	ai_weight_coefficient = 1.2

	inline_script = {
		script = districts/ai_research_society_extra_weighting
		AMOUNT = 5
	}

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}

}

building_biolab_2 = {
	can_build = no
	base_buildtime = @b2_time
	exempt_from_ai_planet_specialization = no

	category = research

	building_sets = {
		research
		society
	}

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

	destroy_trigger = {
		exists = owner
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
			owner = { is_wilderness_empire = yes }
		}
	}

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

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

	planet_modifier = {
		planet_biologists_society_research_produces_add = 0.5
		planet_biologists_exotic_gases_upkeep_add = 0.25
	}

	upgrades = {
		building_biolab_3
	}

	prerequisites = {
		"tech_society_2"
	}

	inline_script = {
		script = districts/ai_research_society_extra_weighting
		AMOUNT = 7.5
	}

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}

}

building_biolab_3 = {
	can_build = no
	base_buildtime = @b2_time
	exempt_from_ai_planet_specialization = no

	category = research

	building_sets = {
		research
		society
	}

	potential = {
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
			owner = { is_wilderness_empire = yes }
		}
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = exotic_gases
			COST = @b3_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			exotic_gases = @b3_rare_cost
		}
		upkeep = {
			energy = @b3_upkeep
			exotic_gases = @b3_rare_upkeep
		}
	}

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

	planet_modifier = {
		biologist_jobs_bonus_workforce_mult = 0.1
		planet_biologists_society_research_produces_add = 0.5
		planet_biologists_exotic_gases_upkeep_add = 0.25
	}

	prerequisites = {
		"tech_society_3"
	}

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

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}
}

building_engineering_facility_1 = {
	can_build = yes
	base_buildtime = @b1_time
	planet_limit = 1
	exempt_from_ai_planet_specialization = no

	category = research

	building_sets = {
		research
		engineering
	}

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

		OR = {
			has_carrier_flag = ignore_ai_building_limitations
			owner = {
				is_ai = no
			}
			has_any_research_engineering_zone = yes
			has_any_unspecialized_research_zone = yes
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
			owner = { is_wilderness_empire = yes }
		}
	}

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

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

	planet_modifier = {
		planet_engineers_engineering_research_produces_add = 0.25
	}

	upgrades = {
		building_engineering_facility_2
	}

	prerequisites = {
		"tech_engineering_1"
	}

	ai_weight_coefficient = 1.2

	inline_script = {
		script = districts/ai_research_engineering_extra_weighting
		AMOUNT = 5
	}

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}
}

building_engineering_facility_2 = {
	can_build = no
	base_buildtime = @b2_time
	exempt_from_ai_planet_specialization = no

	category = research

	building_sets = {
		research
		engineering
	}

	potential = {
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
			owner = { is_wilderness_empire = yes }
		}
	}

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

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

	planet_modifier = {
		planet_engineers_engineering_research_produces_add = 0.5
		planet_engineers_rare_crystals_upkeep_add = 0.25
	}

	upgrades = {
		building_engineering_facility_3
	}

	prerequisites = {
		"tech_engineering_2"
	}

	inline_script = {
		script = districts/ai_research_engineering_extra_weighting
		AMOUNT = 7.5
	}

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}
}

building_engineering_facility_3 = {
	can_build = no
	base_buildtime = @b3_time
	exempt_from_ai_planet_specialization = no

	category = research

	building_sets = {
		research
		engineering
	}

	potential = {
		NOR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			has_modifier = resort_colony
			has_modifier = slave_colony
			has_modifier = penal_colony
			owner = { is_wilderness_empire = yes }
		}
	}

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

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

	planet_modifier = {
		engineer_jobs_bonus_workforce_mult = 0.1
		planet_engineers_engineering_research_produces_add = 0.5
		planet_engineers_rare_crystals_upkeep_add = 0.25
	}

	prerequisites = {
		"tech_engineering_3"
	}

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

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}
}

building_ranger_lodge = {
	base_buildtime = @b1_time
	planet_limit = 1
	icon = holding_park_ranger_lodge

	category = research

	building_sets = {
		research
		society
	}

	potential = {
		NOT = {	has_modifier = slave_colony	}
		owner = {
			is_regular_empire = yes
			has_valid_civic = civic_environmentalist
		}
		NOR = {
			is_planet_class = pc_city
			is_planet_class = pc_hive
			is_planet_class = pc_machine
			is_planet_class = pc_relic
		}
		is_artificial = no
	}

	allow = {
		custom_tooltip = {
			fail_text = no_free_district_for_ranger_lodge
			planet = {
				num_free_districts = {
					type = any
					value > 0
				}
			}
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			owner = { is_regular_empire = no }
			has_modifier = slave_colony
			owner = { NOT = { has_valid_civic = civic_environmentalist } }
			is_planet_class = pc_city
			is_planet_class = pc_hive
			is_planet_class = pc_machine
			is_planet_class = pc_relic
		}
	}

	ai_resource_production = {
		unity = 1.0
		mult = value:natural_blocker_count
	}

	ai_resource_production = {
		unity = 0.5
		trigger = { owner_has_resolution = { RES = resolution_ecology_integrated_gardens } }
		mult = value:natural_blocker_count
	}

	ai_resource_production = {
		unity = 0.5
		trigger = { owner_has_resolution = { RES = resolution_ecology_environmental_control_board } }
		mult = value:natural_blocker_count
	}

	ai_resource_production = {
		unity = 0.5
		trigger = { owner_has_resolution = { RES = resolution_ecology_paradise_initiative } }
		mult = value:natural_blocker_count
	}

	planet_modifier = {
		job_biologist_add = 100 # 100 Rangers no matter what
		deposit_blockers_natural_unity_produces_add = 1.0
	}

	triggered_planet_modifier = {
		potential = {
			always = yes
		}
		job_biologist_add = 100 # +100 Rangers per natural blocker
		mult = value:natural_blocker_count
	}

	triggered_planet_modifier = {
		potential = {
			owner_has_resolution = { RES = resolution_ecology_paradise_initiative }
		}
		job_biologist_add = 100 # +100 Rangers per natural blocker if GalCom approves
		mult = value:natural_blocker_count
	}


	triggered_planet_modifier = {
		potential = { owner_has_resolution = { RES = resolution_ecology_integrated_gardens } }
		deposit_blockers_natural_unity_produces_add = 0.5
	}

	triggered_planet_modifier = {
		potential = { owner_has_resolution = { RES = resolution_ecology_environmental_control_board } }
		deposit_blockers_natural_unity_produces_add = 1.0
	}

	triggered_planet_modifier = {
		potential = { owner_has_resolution = { RES = resolution_ecology_paradise_initiative } }
		deposit_blockers_natural_unity_produces_add = 1.5
	}

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

	triggered_desc = {
		text = biologist_is_ranger_tt
	}

	on_built = {
		planet = {
			add_blocker = { type = d_big_nature_preserve_blocker }
		}
	}

	on_destroy = {
		planet = {
			if = {
				limit = { has_deposit = d_big_nature_preserve_blocker }
				every_deposit = {
					limit = {
						is_deposit_type = d_big_nature_preserve_blocker
					}
					remove_deposit = yes
				}
			}
		}
	}
}

building_research_upkeep_1 = {
	base_buildtime = @b2_time
	planet_limit = 1
	category = research

	building_sets = {
		research
	}

	potential = {
		exists = owner
		owner = {
			is_wilderness_empire = no
		}
		NOT = {
			has_modifier = resort_colony
		}
	}

	allow = {
	}

	destroy_trigger = {
		exists = owner
		OR = {
			has_modifier = resort_colony
			owner = { is_wilderness_empire = yes }
		}
	}

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

	planet_modifier = {
		planet_researchers_upkeep_mult = -0.10
	}

	prerequisites = {
		"tech_basic_science_lab_2"
	}

	ai_resource_production = {
		consumer_goods = 5

		trigger = {
			exists = owner
			owner = { is_gestalt = no }
			has_any_research_zone = yes
		}
	}

	ai_resource_production = {
		energy = 10

		trigger = {
			exists = owner
			owner = {
				is_gestalt = yes
				is_hive_empire = no
			}
			has_any_research_zone = yes
		}
	}

	ai_resource_production = {
		minerals = 10

		trigger = {
			exists = owner
			owner = {
				is_gestalt = yes
				is_hive_empire = yes
			}
			has_any_research_zone = yes
		}
	}

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}
}

building_research_efficiency_1 = {
	base_buildtime = @b3_time
	planet_limit = 1
	category = research

	building_sets = {
		research
	}

	potential = {
		exists = owner
		owner = {
			is_wilderness_empire = no
		}
		NOT = {
			has_modifier = resort_colony
		}
	}

	allow = {
	}

	destroy_trigger = {
		exists = owner
		OR = {
			has_modifier = resort_colony
			owner = { is_wilderness_empire = yes }
		}
	}

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

	planet_modifier = {
		researcher_jobs_bonus_workforce_mult = 0.10
	}

	triggered_planet_modifier = {
		potential = {
			owner? = {
				is_galactic_community_member = yes
			}
			is_active_resolution = "resolution_galacticstudies_extradimensional_experimentation"
			has_modifier = pm_extradimensional_experimentation
		}
		planet_physicists_sr_zro_upkeep_add = 0.5
		planet_physicists_physics_research_produces_add = 1
	}

	prerequisites = {
		"tech_basic_science_lab_2"
	}

	inline_script = {
		script = districts/ai_research_extra_weighting
		AMOUNT = 5
	}

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}
}
