has_upgraded_capital = {
	hidden_trigger = { exists = owner }
	if = {
		limit = { has_modifier = resort_colony }
		custom_tooltip = {
			fail_text = "requires_building_resort_capital"
			capital_tier >= 2
		}
	}
	else_if = {
		limit = { has_modifier = slave_colony }
		custom_tooltip = {
			fail_text = "requires_building_slave_capital"
			capital_tier >= 2
		}
	}
	else_if = {
		limit = { is_planet_class = pc_habitat }
		custom_tooltip = {
			fail_text = "requires_building_hab_capital"
			capital_tier >= 2
		}
	}
	else_if = {
		limit = { owner = { is_wilderness_empire = yes } }
		custom_tooltip = {
			fail_text = "requires_building_wilderness_capital"
			capital_tier >= 2
		}
	}
	else_if = {
		limit = { owner = { is_hive_empire = yes } } # excludes Wilderness, above
		custom_tooltip = {
			fail_text = "requires_building_hive_capital"
			capital_tier >= 2
		}
	}
	else_if = {
		limit = { owner = { is_machine_empire = yes } }
		custom_tooltip = {
			fail_text = "requires_building_machine_capital"
			capital_tier >= 2
		}
	}
	else = {
		custom_tooltip = {
			fail_text = "requires_building_capital"
			capital_tier >= 2
		}
	}
}

has_major_upgraded_capital = {
	hidden_trigger = { exists = owner }
	if = {
		limit = { has_modifier = resort_colony }
		custom_tooltip = {
			fail_text = "requires_building_resort_major_capital"
			capital_tier >= 3
		}
	}
	else_if = {
		limit = { has_modifier = slave_colony }
		custom_tooltip = {
			fail_text = "requires_building_slave_major_capital"
			capital_tier >= 3
		}
	}
	else_if = {
		limit = { is_planet_class = pc_habitat }
		custom_tooltip = {
			fail_text = "requires_building_hab_major_capital"
			capital_tier >= 3
		}
	}
	else_if = {
		limit = { owner = { is_wilderness_empire = yes } }
		custom_tooltip = {
			fail_text = "requires_building_wilderness_major_capital"
			capital_tier >= 3
		}
	}
	else_if = {
		limit = { owner = { is_hive_empire = yes } } # excludes Wilderness, above
		custom_tooltip = {
			fail_text = "requires_building_major_hive_capital"
			capital_tier >= 3
		}
	}
	else_if = {
		limit = { owner = { is_machine_empire = yes } }
		custom_tooltip = {
			fail_text = "requires_building_machine_major_capital"
			capital_tier >= 3
		}
	}
	else = {
		custom_tooltip = {
			fail_text = "requires_building_major_capital"
			capital_tier >= 3
		}
	}
}

has_fully_upgraded_capital = {
	hidden_trigger = { exists = owner }
	if = {
		limit = { has_modifier = resort_colony }
		custom_tooltip = {
			fail_text = "requires_building_resort_major_capital"
			capital_tier >= 3
		}
	}
	else_if = {
		limit = { has_modifier = slave_colony }
		custom_tooltip = {
			fail_text = "requires_building_slave_major_capital"
			capital_tier >= 3
		}
	}
	else_if = {
		limit = { is_planet_class = pc_habitat }
		custom_tooltip = {
			fail_text = "requires_building_hab_system_capital"
			capital_tier >= 4
		}
	}
	else_if = {
		limit = { owner = { is_wilderness_empire = yes } }
		custom_tooltip = {
			fail_text = "requires_building_wilderness_system_capital"
			capital_tier >= 4
		}
	}
	else_if = {
		limit = { owner = { is_hive_empire = yes } } # excludes Wilderness, above
		custom_tooltip = {
			fail_text = "requires_building_major_hive_capital"
			capital_tier >= 3
		}
	}
	else_if = {
		limit = { owner = { is_machine_empire = yes } }
		custom_tooltip = {
			fail_text = "requires_building_machine_system_capital"
			capital_tier >= 4
		}
	}
	else = {
		custom_tooltip = {
			fail_text = "requires_building_system_capital"
			capital_tier >= 4
		}
	}
}

uses_district_industrial = {
	OR = {
		uses_district_set = standard
		uses_district_set = hive_world
		uses_district_set = machine_world
		uses_district_set = shattered_ring_world
		uses_district_set = volcanic_world
	}
}

ideal_planet_is_wet = {
	OR = {
		ideal_planet_class = pc_continental
		ideal_planet_class = pc_ocean
		ideal_planet_class = pc_tropical
	}
}

ideal_planet_is_dry = {
	OR = {
		ideal_planet_class = pc_desert
		ideal_planet_class = pc_arid
		ideal_planet_class = pc_savannah
		ideal_planet_class = pc_volcanic
	}
}

ideal_planet_is_cold = {
	OR = {
		ideal_planet_class = pc_tundra
		ideal_planet_class = pc_arctic
		ideal_planet_class = pc_alpine
	}
}

ideal_planet_is_special = {
	NOR = {
		ideal_planet_class = pc_continental
		ideal_planet_class = pc_ocean
		ideal_planet_class = pc_tropical
		ideal_planet_class = pc_desert
		ideal_planet_class = pc_arid
		ideal_planet_class = pc_savannah
		ideal_planet_class = pc_tundra
		ideal_planet_class = pc_arctic
		ideal_planet_class = pc_alpine
	}
}

can_build_gaiaseeder = {
	# Can always build on ideal worlds
	# Or if you have Mutagenic Habitability
	if = {
		limit = {
			OR = {
				is_ideal_planet_class = {
					who = owner
					status = yes
				}
				owner_species = {
					has_trait = trait_auto_hab_preference
				}
			}
		}
		always = yes
	}

	# Requires Climate Restoration for Tomb Worlds
	else_if = {
		limit = {
			planet = { is_planet_class = pc_nuked }
		}
		custom_tooltip = {
			fail_text = gaiaseeders_tomb_world
			owner = { has_technology = tech_climate_restoration }
		}
	}

	# Requires Terrestrial Sculpting for same climate as homeworld
	else_if = {
		limit = {
			owner_species = {
				ideal_planet_is_wet = yes
			}
			planet = {
				is_wet = yes
				is_ideal_planet_class = {
					who = owner
					status = no
				}
			}
		}
		custom_tooltip = {
			fail_text = gaiaseeders_same_climate_wet
			owner = { has_technology = tech_terrestrial_sculpting }
		}
	}

	else_if = {
		limit = {
			owner_species = {
				ideal_planet_is_dry = yes
			}
			planet = {
				is_dry = yes
				is_ideal_planet_class = {
					who = owner
					status = no
				}
			}
		}
		custom_tooltip = {
			fail_text = gaiaseeders_same_climate_dry
			owner = { has_technology = tech_terrestrial_sculpting }
		}
	}

	else_if = {
		limit = {
			owner_species = {
				ideal_planet_is_cold = yes
			}
			planet = {
				is_cold = yes
				is_ideal_planet_class = {
					who = owner
					status = no
				}
			}
		}
		custom_tooltip = {
			fail_text = gaiaseeders_same_climate_cold
			owner = { has_technology = tech_terrestrial_sculpting }
		}
	}

	# Requires Ecological Adaptation for other climates
	else_if = {
		limit = {
			owner_species = {
				ideal_planet_is_wet = yes
			}
			planet = {
				OR = {
					is_dry = yes
					is_cold = yes
				}
			}
		}
		custom_tooltip = {
			fail_text = gaiaseeders_different_climate_wet
			owner = { has_technology = tech_ecological_adaptation }
		}
	}

	else_if = {
		limit = {
			owner_species = {
				ideal_planet_is_dry = yes
			}
			planet = {
				OR = {
					is_wet = yes
					is_cold = yes
				}
			}
		}
		custom_tooltip = {
			fail_text = gaiaseeders_different_climate_dry
			owner = { has_technology = tech_ecological_adaptation }
		}
	}

	else_if = {
		limit = {
			owner_species = {
				ideal_planet_is_cold = yes
			}
			planet = {
				OR = {
					is_wet = yes
					is_dry = yes
				}
			}
		}
		custom_tooltip = {
			fail_text = gaiaseeders_different_climate_cold
			owner = { has_technology = tech_ecological_adaptation }
		}
	}

	else_if = {
		limit = {
			owner_species = {
				ideal_planet_is_special = yes
			}
			planet = {
				OR = {
					is_wet = yes
					is_dry = yes
					is_cold = yes
				}
			}
		}
		custom_tooltip = {
			fail_text = gaiaseeders_special_habitability_preference
			owner = { has_technology = tech_ecological_adaptation }
		}
	}
}

can_build_overlord_gaiaseeder = {
	# Can always build on ideal worlds
	# Or if you have Mutagenic Habitability
	if = {
		limit = {
			OR = {
				is_ideal_planet_class = {
					who = owner.overlord
					status = yes
				}
				owner.overlord.species = {
					has_trait = trait_auto_hab_preference
				}
			}
		}
		always = yes
	}

	# Requires Climate Restoration for Tomb Worlds
	else_if = {
		limit = {
			planet = { is_planet_class = pc_nuked }
		}
		custom_tooltip = {
			fail_text = gaiaseeders_tomb_world
			owner.overlord = { has_technology = tech_climate_restoration }
		}
	}

	# Requires Terrestrial Sculpting for same climate as homeworld
	else_if = {
		limit = {
			owner.overlord.species = {
				ideal_planet_is_wet = yes
			}
			planet = {
				is_wet = yes
				is_ideal_planet_class = {
					who = owner.overlord
					status = no
				}
			}
		}
		custom_tooltip = {
			fail_text = gaiaseeders_same_climate_wet
			owner.overlord = { has_technology = tech_terrestrial_sculpting }
		}
	}

	else_if = {
		limit = {
			owner.overlord.species = {
				ideal_planet_is_dry = yes
			}
			planet = {
				is_dry = yes
				is_ideal_planet_class = {
					who = owner.overlord
					status = no
				}
			}
		}
		custom_tooltip = {
			fail_text = gaiaseeders_same_climate_dry
			owner.overlord = { has_technology = tech_terrestrial_sculpting }
		}
	}

	else_if = {
		limit = {
			owner.overlord.species = {
				ideal_planet_is_cold = yes
			}
			planet = {
				is_cold = yes
				is_ideal_planet_class = {
					who = owner.overlord
					status = no
				}
			}
		}
		custom_tooltip = {
			fail_text = gaiaseeders_same_climate_cold
			owner.overlord = { has_technology = tech_terrestrial_sculpting }
		}
	}

	# Requires Ecological Adaptation for other climates
	else_if = {
		limit = {
			owner.overlord.species = {
				ideal_planet_is_wet = yes
			}
			planet = {
				OR = {
					is_dry = yes
					is_cold = yes
				}
			}
		}
		custom_tooltip = {
			fail_text = gaiaseeders_different_climate_wet
			owner.overlord = { has_technology = tech_ecological_adaptation }
		}
	}

	else_if = {
		limit = {
			owner.overlord.species = {
				ideal_planet_is_dry = yes
			}
			planet = {
				OR = {
					is_wet = yes
					is_cold = yes
				}
			}
		}
		custom_tooltip = {
			fail_text = gaiaseeders_different_climate_dry
			owner.overlord = { has_technology = tech_ecological_adaptation }
		}
	}

	else_if = {
		limit = {
			owner.overlord.species = {
				ideal_planet_is_cold = yes
			}
			planet = {
				OR = {
					is_wet = yes
					is_dry = yes
				}
			}
		}
		custom_tooltip = {
			fail_text = gaiaseeders_different_climate_cold
			owner.overlord = { has_technology = tech_ecological_adaptation }
		}
	}

	else_if = {
		limit = {
			owner.overlord.species = {
				ideal_planet_is_special = yes
			}
			planet = {
				OR = {
					is_wet = yes
					is_dry = yes
					is_cold = yes
				}
			}
		}
		custom_tooltip = {
			fail_text = gaiaseeders_special_habitability_preference
			owner.overlord = { has_technology = tech_ecological_adaptation }
		}
	}
}

has_no_research_specialization = {
	NOR = {
		num_zones = {
			type = zone_research_physics
			value < 1
		}
		num_zones = {
			type = zone_research_engineering
			value < 1
		}
		num_zones = {
			type = zone_research_society
			value < 1
		}
		num_zones = {
			type = zone_research_physics_arcology
			value < 1
		}
		num_zones = {
			type = zone_research_society_arcology
			value < 1
		}
		num_zones = {
			type = zone_research_engineering_arcology
			value < 1
		}
		num_zones = {
			type = zone_research_physics_ring_world
			value < 1
		}
		num_zones = {
			type = zone_research_society_ring_world
			value < 1
		}
		num_zones = {
			type = zone_research_engineering_ring_world
			value < 1
		}
		num_zones = {
			type = zone_research_physics_nexus
			value < 1
		}
		num_zones = {
			type = zone_research_society_nexus
			value < 1
		}
		num_zones = {
			type = zone_research_engineering_nexus
			value < 1
		}
		num_zones = {
			type = zone_research_physics_hive
			value < 1
		}
		num_zones = {
			type = zone_research_society_hive
			value < 1
		}
		num_zones = {
			type = zone_research_engineering_hive
			value < 1
		}
	}
}

has_any_unspecialized_research_zone = {
	OR  = {
		has_zone = {
			zone = zone_research
		}
		has_zone = {
			zone = zone_research_wilderness
		}
		has_zone = {
			zone = zone_research_unity
		}
		has_zone = {
			zone = zone_research_unity_wilderness
		}
		has_zone = {
			zone = zone_habitat_research
		}
		has_zone = {
			zone = zone_habitat_research_unity
		}
		has_zone = {
			zone = zone_research_arcology
		}
		has_zone = {
			zone = zone_research_ring_world
		}
		has_zone = {
			zone = zone_research_nexus
		}
		has_zone = {
			zone = zone_research_hive
		}
		has_zone = {
			zone = zone_central_spire
		}
		has_zone = {
			zone = zone_ark_research_unity
		}
		has_zone = {
			zone = zone_ark_research_unity_gestalt
		}
		has_zone = {
			zone = zone_ark_sacred_path_pilgrims
		}
	}
}

has_any_research_unity_zone = {
	OR = {
		has_zone = {
			zone = zone_research_unity
		}
		has_zone = {
			zone = zone_ark_research_unity
		}
		has_zone = {
			zone = zone_ark_research_unity_gestalt
		}
		has_zone = {
			zone = zone_ark_sacred_path_pilgrims
		}
	}
}

has_any_research_physics_zone = {
	OR = {
		has_zone = {
			zone = zone_research_physics
		}
		has_zone = {
			zone = zone_research_physics_arcology
		}
		has_zone = {
			zone = zone_research_physics_ring_world
		}
		has_zone = {
			zone = zone_research_physics_nexus
		}
		has_zone = {
			zone = zone_research_physics_hive
		}
		has_zone = {
			zone = zone_ark_reactor_physics
		}
	}
}

has_any_research_society_zone = {
	OR = {
		has_zone = {
			zone = zone_research_society
		}
		has_zone = {
			zone = zone_research_society_arcology
		}
		has_zone = {
			zone = zone_research_society_ring_world
		}
		has_zone = {
			zone = zone_research_society_nexus
		}
		has_zone = {
			zone = zone_research_society_hive
		}
		has_zone = {
			zone = zone_ark_farm_society
		}
	}
}

has_any_research_engineering_zone = {
	OR = {
		has_zone = {
			zone = zone_research_engineering
		}
		has_zone = {
			zone = zone_research_engineering_arcology
		}
		has_zone = {
			zone = zone_research_engineering_ring_world
		}
		has_zone = {
			zone = zone_research_engineering_nexus
		}
		has_zone = {
			zone = zone_research_engineering_hive
		}
		has_zone = {
			zone = zone_ark_military_engineering
		}
		has_zone = {
			zone = zone_ark_forever_cruise_engineering
		}
	}
}

has_any_specialized_research_zone = {
	OR = {
		has_any_research_physics_zone = yes
		has_any_research_society_zone = yes
		has_any_research_engineering_zone = yes
	}
}

has_any_research_zone = {
	OR = {
		has_any_unspecialized_research_zone = yes
		has_any_specialized_research_zone = yes
	}
}

has_any_agriculture_zone = {
	OR = {
		has_any_normal_agriculture_zone = yes
		has_any_exotic_gases_zone = yes
		has_zone = {
			zone = zone_anglers
		}
		has_zone = {
			zone = zone_agrarian_urban
		}
		has_zone = {
			zone = zone_agrarian_anglers
		}
		has_zone = {
			zone = zone_habitat_hydroponics
		}
	}
}

has_any_normal_agriculture_zone = {
	OR = {
		has_zone = {
			zone = zone_food
		}
		has_zone = {
			zone = zone_food_wilderness
		}
		has_zone = {
			zone = zone_food_ring_world
		}
		has_zone = {
			zone = zone_food_hive
		}
		has_zone = {
			zone = zone_ark_food
		}
	}
}

has_any_exotic_gases_zone = {
	OR = {
		has_zone = {
			zone = zone_exotic_gases
		}
		has_zone = {
			zone = zone_exotic_gases_nexus
		}
		has_zone = {
			zone = zone_exotic_gases_hive
		}
		has_zone = {
			zone = zone_habitat_exotic_gases
		}
	}
}

has_any_generator_zone = {
	OR = {
		has_any_normal_generator_zone = yes
		has_volatile_motes_zone = yes
		has_zone = {
			zone = zone_habitat_hydroponics
		}
		has_zone = {
			zone = zone_ark_engine_bypass
		}
		has_zone = {
			zone = zone_ark_shield_overloader
		}
		has_zone = {
			zone = zone_ark_reactor_physics
		}
	}
}

has_any_normal_generator_zone = {
	OR = {
		has_zone = {
			zone = zone_energy
		}
		has_zone = {
			zone = zone_energy_wilderness
		}
		has_zone = {
			zone = zone_energy_ring_world
		}
		has_zone = {
			zone = zone_energy_nexus
		}
		has_zone = {
			zone = zone_energy_hive
		}
	}
}

has_volatile_motes_zone = {
	OR = {
		has_zone = {
			zone = zone_volatile_motes
		}
		has_zone = {
			zone = zone_volatile_motes_nexus
		}
		has_zone = {
			zone = zone_volatile_motes_hive
		}
		has_zone = {
			zone = zone_habitat_volatile_motes
		}
	}
}

has_any_mining_zone = {
	OR = {
		has_any_normal_mining_zone = yes
		has_any_rare_crystals_zone = yes
		has_any_betharian_zone = yes
		has_zone = {
			zone = zone_subterranean_urban
		}
		has_zone = {
			zone = zone_ark_harvest
		}
	}
}

has_any_normal_mining_zone = {
	OR = {
		has_zone = {
			zone = zone_minerals
		}
		has_zone = {
			zone = zone_minerals_wilderness
		}
		has_zone = {
			zone = zone_minerals_nexus
		}
		has_zone = {
			zone = zone_minerals_hive
		}
	}
}

has_any_rare_crystals_zone = {
	OR = {
		has_zone = {
			zone = zone_rare_crystals
		}
		has_zone = {
			zone = zone_rare_crystals_nexus
		}
		has_zone = {
			zone = zone_rare_crystals_hive
		}
		has_zone = {
			zone = zone_habitat_rare_crystals
		}
	}
}

has_any_betharian_zone = {
	OR = {
		has_zone = {
			zone = zone_betharian
		}
		has_zone = {
			zone = zone_betharian_nexus
		}
		has_zone = {
			zone = zone_betharian_hive
		}
	}
}

has_any_factory_zone = {
	hidden_trigger = { exists = owner }
	owner = {
		country_uses_consumer_goods = yes
	}
	OR = {
		has_zone = {
			zone = zone_factory
		}
		has_zone = {
			zone = zone_factory_arcology
		}
		has_zone = {
			zone = zone_factory_ring_world
		}
		has_zone = {
			zone = zone_factory_nexus
		}
		has_zone = {
			zone = zone_factory_hive
		}
	}
}

has_any_foundry_zone = {
	OR = {
		has_zone = {
			zone = zone_foundry
		}
		has_zone = {
			zone = zone_foundry_wilderness
		}
		has_zone = {
			zone = zone_foundry_arcology
		}
		has_zone = {
			zone = zone_foundry_ring_world
		}
		has_zone = {
			zone = zone_foundry_nexus
		}
		has_zone = {
			zone = zone_foundry_hive
		}
		has_zone = {
			zone = zone_ark_foundry
		}
		has_zone = {
			zone = zone_ark_military_eco
		}
		has_zone = {
			zone = zone_ark_shipwright
		}
	}
}

has_mixed_industrial_zone = {
	OR = {
		has_zone = {
			zone = zone_industrial
		}
		has_zone = {
			zone = zone_industrial_arcology
		}
		has_zone = {
			zone = zone_industrial_ring_world
		}
		has_zone = {
			zone = zone_industrial_nexus
		}
		has_zone = {
			zone = zone_industrial_hive
		}
		has_zone = {
			zone = zone_ark_industrial
		}
		has_zone = {
			zone = zone_ark_forever_cruise_city_mixed
		}
	}
}

has_any_industrial_zone = {
	OR = {
		has_mixed_industrial_zone = yes
		has_any_foundry_zone = yes
		has_any_factory_zone = yes
	}
}

has_any_unity_zone = {
	OR = {
		has_zone = {
			zone = zone_unity
		}
		has_zone = {
			zone = zone_unity_spiritualist
		}
		has_zone = {
			zone = zone_unity_bio_trophy
		}
		has_zone = {
			zone = zone_unity_arcology
		}
		has_zone = {
			zone = zone_unity_spiritualist_arcology
		}
		has_zone = {
			zone = zone_unity_bio_trophy_arcology
		}
		has_zone = {
			zone = zone_unity_ring_world
		}
		has_zone = {
			zone = zone_unity_spiritualist_ring_world
		}
		has_zone = {
			zone = zone_unity_bio_trophy_ring_world
		}
		has_zone = {
			zone = zone_unity_nexus
		}
		has_zone = {
			zone = zone_unity_spiritualist_nexus
		}
		has_zone = {
			zone = zone_unity_bio_trophy_nexus
		}
		has_zone = {
			zone = zone_unity_hive
		}
		has_zone = {
			zone = zone_unity_wilderness
		}
		has_zone = {
			zone = zone_research_unity
		}
		has_zone = {
			zone = zone_research_unity_wilderness
		}
		has_zone = {
			zone = zone_habitat_research_unity
		}
		has_zone = {
			zone = zone_ark_research_unity
		}
		has_zone = {
			zone = zone_ark_research_unity_gestalt
		}
		has_zone = {
			zone = zone_ark_sacred_path_pilgrims
		}
	}
}

has_any_trade_zone = {
	OR = {
		has_zone = {
			zone = zone_trade
		}
		has_zone = {
			zone = zone_trade_wilderness
		}
		has_zone = {
			zone = zone_trade_arcology
		}
		has_zone = {
			zone = zone_trade_ring_world
		}
		has_zone = {
			zone = zone_trade_nexus
		}
		has_zone = {
			zone = zone_trade_hive
		}
		has_zone = {
			zone = zone_ark_waystation_trade
		}
	}
}

has_any_fortress_zone = {
	OR = {
		has_zone = {
			zone = zone_fortress
		}
		has_zone = {
			zone = zone_fortress_wilderness
		}
		has_zone = {
			zone = zone_fortress_arcology
		}
		has_zone = {
			zone = zone_fortress_ring_world
		}
		has_zone = {
			zone = zone_fortress_nexus
		}
		has_zone = {
			zone = zone_fortress_hive
		}
		has_zone = {
			zone = zone_habitat_knights
		}
		has_zone = {
			zone = zone_ark_missile_silos
		}
		has_zone = {
			zone = zone_ark_ammunition_lines
		}
		has_zone = {
			zone = zone_ark_laser_capacitors
		}
		has_zone = {
			zone = zone_ark_flight_decks
		}
	}
}

# True on a Knights of the Toxic God colony (habitat variant or nomad/arkship variant)
has_knights_zone = {
	OR = {
		has_zone = { zone = zone_habitat_knights }
		has_zone = { zone = zone_ark_knights }
	}
}

# These are scripted triggers checking district sets for mod compatibility
planet_is_habitat_equivalent = {
	uses_district_set = habitat					# Habitats
}

planet_is_ecu_equivalent = {
	NOT = {
		has_deposit = d_machine_prototype_pc_machine
	}
	OR = {
		uses_district_set = city_world 			# Ecumenopoleis
		uses_district_set = machine_world		# Machine & Nanotech Worlds
		uses_district_set = hive_world			# Hive Worlds
	}
}

planet_is_ring_world_equivalent = {
	uses_district_set = ring_world				# Ring Worlds
}

has_volatile_motes_deposit = {
	if = {
		limit = {
			planet_is_habitat_equivalent = yes
		}
		solar_system = {
			any_system_planet = {
				has_deposit_for = shipclass_mining_station
				has_resource = { type = volatile_motes amount > 0 }
			}
		}
	}
	else = {
		OR = {
			has_deposit = d_dust_caverns
			has_deposit = d_dust_desert
			has_deposit = d_industrial_sector
			has_deposit = d_explosive_atmosphere
			has_deposit = d_particle_storm_3_motes
		}
	}
}

has_exotic_gases_deposit = {
	if = {
		limit = {
			planet_is_habitat_equivalent = yes
		}
		solar_system = {
			any_system_planet = {
				has_deposit_for = shipclass_mining_station
				has_resource = { type = exotic_gases amount > 0 }
			}
		}
	}
	else = {
		OR = {
			has_deposit = d_bubbling_swamp
			has_deposit = d_fuming_bog
			has_deposit = d_industrial_sector
			has_deposit = d_exotic_mountain
			has_deposit = d_bogplants
			has_deposit = d_toxic_god_envenomed_seas_upgraded
		}
	}
}

has_rare_crystals_deposit = {
	if = {
		limit = {
			planet_is_habitat_equivalent = yes
		}
		solar_system = {
			any_system_planet = {
				has_deposit_for = shipclass_mining_station
				has_resource = { type = rare_crystals amount > 0 }
			}
		}
	}
	else = {
		OR = {
			has_deposit = d_crystalline_caverns
			has_deposit = d_crystal_forest
			has_deposit = d_crystal_reef
			has_deposit = d_industrial_sector
			has_deposit = d_crystaline_growths
			has_deposit = d_crystal_kraken_body
			has_deposit = d_crystal_kraken_body_bombed
			has_deposit = d_crystalline_glacier
			has_deposit = d_celestial_storm_1_mines
			has_deposit = d_celestial_storm_3_crystal
		}
	}
}

has_offspring_nest = {
	OR = {
		has_building = building_offspring_nest
		starbase? = {
			has_starbase_building = arkship_offspring_outlook
		}
	}
}

# Returns true if this colony has fewer than 3 buildings of the given type total across all tiers.
# Usage: tiered_building_below_cap = { BUILDING = foundry }
# Assumes tiers are named building_$BUILDING$_1, building_$BUILDING$_2, building_$BUILDING$_3.
tiered_building_below_cap = {
	NOR = {
		num_buildings = {
			type = building_$BUILDING$_1
			value >= 3
		}
		num_buildings = {
			type = building_$BUILDING$_2
			value >= 3
		}
		num_buildings = {
			type = building_$BUILDING$_3
			value >= 3
		}
		AND = {
			num_buildings = {
				type = building_$BUILDING$_1
				value >= 2
			}
			OR = {
				num_buildings = {
					type = building_$BUILDING$_2
					value >= 1
				}
				num_buildings = {
					type = building_$BUILDING$_3
					value >= 1
				}
			}
		}
		AND = {
			num_buildings = {
				type = building_$BUILDING$_2
				value >= 2
			}
			OR = {
				num_buildings = {
					type = building_$BUILDING$_1
					value >= 1
				}
				num_buildings = {
					type = building_$BUILDING$_3
					value >= 1
				}
			}
		}
		AND = {
			num_buildings = {
				type = building_$BUILDING$_3
				value >= 2
			}
			OR = {
				num_buildings = {
					type = building_$BUILDING$_1
					value >= 1
				}
				num_buildings = {
					type = building_$BUILDING$_2
					value >= 1
				}
			}
		}
		AND = {
			num_buildings = {
				type = building_$BUILDING$_1
				value >= 1
			}
			num_buildings = {
				type = building_$BUILDING$_2
				value >= 1
			}
			num_buildings = {
				type = building_$BUILDING$_3
				value >= 1
			}
		}
	}
}

# Colony-scope allow check: true when the matching $RING$ / $ARKSHIP$ starbase variant is absent.
orbital_ring_and_arkship_equivalent_absent = {
	carrier = {
		if = {
			limit = {
				is_planet_class = pc_ark
			}
			fleet.starbase? = {
				NOR = {
					has_starbase_building = $ARKSHIP$
					is_starbase_building_building = $ARKSHIP$
				}
			}
		}
		if = {
			limit = {
				exists = orbital_defence
			}
			orbital_defence.starbase? = {
				NOR = {
					has_starbase_building = $RING$
					is_starbase_building_building = $RING$
				}
			}
		}
	}
}
