# from = country
# this = species

colonization_control_yes = {
	can_colonize = no
	potential = {
		NAND = {
			from = { has_authority = auth_machine_intelligence }
			OR = {
				has_trait = trait_machine_unit
				has_trait = trait_mechanical
			}
		}
	}

	allow = {
		hidden_trigger = { exists = from }
		if = {
			limit = {
				OR = {
					has_citizenship_type = { country = from type = citizenship_purge }
					has_citizenship_type = { country = from type = citizenship_purge_machine }
					has_citizenship_type = { country = from type = citizenship_slavery }
					has_citizenship_type = { country = from type = citizenship_robot_servitude }
				}
			}
			hidden_trigger = { always = yes }
		}
		else = {
			custom_tooltip = {
				fail_text = same_species_disallowed
				NOT = { is_same_species = from }
			}
		}
	}

	ai_will_do = {
		factor = 2
		modifier = {
			factor = 0
			from = {
				NOR = {
					has_ethic = ethic_xenophobe
					has_ethic = ethic_fanatic_xenophobe
					has_ethic = ethic_gestalt_consciousness
				}
			}
		}
		modifier = {
			factor = 0
			has_trait = trait_cybernetic
			from = { OR = { has_valid_civic = civic_machine_assimilator has_ascension_perk = ap_organo_machine_interfacing_assimilator } }
		}
		modifier = {
			factor = 0
			has_slavery_type = { country = from type = slavery_indentured }
		}
	}
}

colonization_control_no = {
	potential = {
		exists = from
		NAND = {
			from = { has_authority = auth_machine_intelligence }
			NOR = {
				has_trait = trait_machine_unit
				has_trait = trait_mechanical
				AND = {
					has_trait = trait_cybernetic
					from = { OR = { has_valid_civic = civic_machine_assimilator has_ascension_perk = ap_organo_machine_interfacing_assimilator } }
				}
				from = { has_valid_civic = civic_machine_servitor }
			}
		}
	}

	allow = {
		hidden_trigger = { exists = from }
		custom_tooltip = {
			NOR = {
				has_citizenship_type = { country = from type = citizenship_purge_machine }
				has_citizenship_type = { country = from type = citizenship_purge }
			}
			fail_text = is_undesirables_tooltip
		}
		custom_tooltip = {
			fail_text = "HIVE_MIND_SPECIES_CITIZENS_ONLY"
			OR = {
				NOT = { from = { has_authority = auth_hive_mind } }
				has_trait = trait_hive_mind
			}
		}
		custom_tooltip = {
			fail_text = "ROBOTS_CANNOT_COLONIZE"
			OR = {
				NOT = { has_trait = trait_mechanical }
				from = { has_technology = tech_droid_workers }
				from = { has_authority = auth_machine_intelligence }
			}
		}
		custom_tooltip = {
			fail_text = "SPECIES_CANNOT_COLONIZE"
			NOR = {
				has_trait = trait_syncretic_proles
				can_think = no
			}
		}
		custom_tooltip = {
			fail_text = is_slaves_not_battle_thralls_or_indentured_fail
			if = {
				limit = {
					has_citizenship_type = { country = from type = citizenship_slavery }
				}
				OR = {
					has_slavery_type = { country = from type = slavery_military }
					has_slavery_type = { country = from type = slavery_indentured }
				}
			}
		}
	}
	ai_will_do = {
		factor = 1
		modifier = {
			factor = 0
			from = { has_valid_civic = civic_machine_servitor }
			NOR = {
				has_trait = trait_machine_unit
				has_trait = trait_mechanical
			}
		}
	}
}
