###############################
# "CYBERNETICS" ASCENSION PACK
###############################

has_cybernetic_ascension = {
	OR = {
		has_ascension_perk = ap_the_flesh_is_weak						# Regular
		has_ascension_perk = ap_organo_machine_interfacing				# Hive-Mind
		has_ascension_perk = ap_organo_machine_interfacing_assimilator	# Driven Assimilator
		has_origin = origin_cybernetic_creed							# Early Access Origin
		has_valid_civic = civic_augmentation_bazaars					# Restricted Civic
	}
}

has_genetic_ascension = {
	has_ascension_perk = ap_engineered_evolution						# Regular & Hive-Mind
}

has_psionic_ascension = {
	OR = {
		has_ascension_perk = ap_mind_over_matter						# Regular
		has_origin = origin_shroudwalker_apprentice						# Early Access Origin
		has_origin = origin_endbringers
		is_chosen_empire = yes											# Early Access Civic
		AND  = {														# Early Access Origin (must complete situation from right side)
			has_origin = origin_shroud_forged
			has_country_flag = finish_shroud_forged_liberation_flag
		}
	}
}

has_synthetic_ascension = {
	OR = {
		has_ascension_perk = ap_synthetic_evolution						# Regular
		has_ascension_perk = ap_synthetic_age							# Machine Intelligence
		has_origin = origin_synthetic_fertility							# Early Access Origin
	}
}

has_ascension_path = {
	OR = {
		has_cybernetic_ascension = yes
		has_genetic_ascension = yes
		has_psionic_ascension = yes
		has_synthetic_ascension = yes
	}
}

is_natural_design_empire = {
	OR = {
		has_valid_civic = civic_natural_design
		has_valid_civic = civic_hive_natural_design
	}
}

has_titan_tech = {
	exists = owner
	owner = {
		has_technology = tech_titans
	}
}

is_individual_machine = {
	founder_species = {
		is_archetype = MACHINE
	}
	is_gestalt = no
}

has_cybernetic_creed_trait = {
	OR = {
		has_trait = trait_cyborg_creed_of_construction
		has_trait = trait_cyborg_creed_of_war
		has_trait = trait_cyborg_creed_of_research
		has_trait = trait_cyborg_creed_of_labor
		has_trait = trait_cyborg_ritualistic_implants
	}
}

is_cyber_creed_advanced_government = {
	has_origin = origin_cybernetic_creed
	has_country_flag = cyber_creed_advanced_government
}

is_guided_sapience_empire = {
	OR = {
		has_valid_civic = civic_guided_sapience
		has_valid_civic = civic_hive_guided_sapience
		has_valid_civic = civic_machine_guided_sapience
		has_valid_civic = civic_corporate_guided_sapience
	}
}


has_murderous_civic_or_origin = {
	OR = {
		has_valid_civic = civic_scavengers
		has_valid_civic = civic_shadow_council
		has_valid_civic = civic_barbaric_despoilers
		has_valid_civic = civic_sovereign_guardianship
		has_valid_civic = civic_cutthroat_politics
		has_valid_civic = civic_death_cult
		has_origin = origin_necrophage
		has_origin = origin_legendary_leader
		has_origin = origin_cybernetic_creed
		has_origin = origin_overtuned
	}
}

has_genesis_preserve_trait = {
	OR = {
		has_trait = trait_presapient_starborn
		has_trait = trait_presapient_earthbound
		has_trait = trait_presapient_natural_intellectuals
		has_trait = trait_presapient_proles
		has_trait = trait_presapient_conservative
		has_trait = trait_presapient_irradiated
		has_trait = trait_presapient_docile_livestock
		has_trait = trait_presapient_forcefully_devolved
		has_trait = trait_presapient_unintelligent
	}
}

is_synth_queen_country_type = {
	OR = {
		is_country_type = synth_queen
		is_country_type = synth_queen_storm
		is_country_type = awakened_synth_queen
	}
}

has_made_cyber_creed_faction_choice = {
	OR = {
		has_country_flag = cybernetic_creed_labor
		has_country_flag = cybernetic_creed_construction
		has_country_flag = cybernetic_creed_war
		has_country_flag = cybernetic_creed_research
		has_country_flag = cybernetic_creed_general
	}
}

has_synth_queen_dialogue_flag = {
	OR = {
		has_country_flag = crisis.8060.1.flag
		has_country_flag = crisis.8060.2.flag
		has_country_flag = crisis.8060.3.flag
		has_country_flag = crisis.8060.4.flag
		has_country_flag = crisis.8060.5.flag
		has_country_flag = crisis.8060.6.flag
		has_country_flag = crisis.8060.7.flag
		has_country_flag = crisis.8060.8.flag
		has_country_flag = crisis.8060.8.1.flag
		has_country_flag = crisis.8060.9.flag
		has_country_flag = crisis.8060.10.flag
		has_country_flag = crisis.8060.11.flag
		has_country_flag = crisis.8060.12.flag
		has_country_flag = crisis.8060.war.flag
		has_country_flag = crisis.8060.war.1.flag
		has_global_flag = synth_queen_war_started
	}
}

system_has_dyson_swarm = {
	solar_system = {
		any_system_megastructure = {
			OR = {
				is_megastructure_type = dyson_swarm_1
				is_megastructure_type = dyson_swarm_2
				is_megastructure_type = dyson_swarm_3
			}
		}
	}
}

arc_furnace_overclock_obsessional_directive = {
	solar_system = {
		any_system_megastructure = {
			OR = {
				has_overclock = overclock_arc_furnace_3_obsessional_directive
				has_overclock = overclock_arc_furnace_4_obsessional_directive
			}
		}
	}
}

arc_furnace_overclock_balanced = {
	solar_system = {
		any_system_megastructure = {
			OR = {
				has_overclock = overclock_arc_furnace_3_balanced
				has_overclock = overclock_arc_furnace_4_balanced
			}
		}
	}
}

arc_furnace_overclock_minerals = {
	solar_system = {
		any_system_megastructure = {
			OR = {
				has_overclock = overclock_arc_furnace_3_minerals
				has_overclock = overclock_arc_furnace_4_minerals
			}
		}
	}
}

arc_furnace_overclock_alloys = {
	solar_system = {
		any_system_megastructure = {
			OR = {
				has_overclock = overclock_arc_furnace_3_alloys
				has_overclock = overclock_arc_furnace_4_alloys
			}
		}
	}
}

is_arc_furnace_megastructure = {
	OR = {
		is_megastructure_type = orbital_arc_furnace_1
		is_megastructure_type = orbital_arc_furnace_2
		is_megastructure_type = orbital_arc_furnace_3
		is_megastructure_type = orbital_arc_furnace_4
		is_megastructure_type = orbital_arc_furnace_destroyed
		is_megastructure_type = orbital_arc_furnace_restored
	}
}

system_has_arc_furnace = {
	solar_system = {
		any_system_megastructure = {
			is_arc_furnace_megastructure = yes
		}
	}
}

has_completed_synth_queen_history_chain = {
	has_country_flag = crisis_20100_happened
	has_country_flag = crisis_20200_happened
	has_country_flag = crisis_20300_happened
	has_country_flag = crisis_20500_happened
}

has_ascension_situation_ongoing = {
	OR = {
		is_situation_type = situation_cybernetic_creed_cyberization
		is_situation_type = situation_synthetic_fertility_synthesization
		is_situation_type = situation_cyberization
		is_situation_type = situation_cyberization_hive
		is_situation_type = situation_digitization
		is_situation_type = situation_transformation
		is_situation_type = genetic_ascension_situation
		is_situation_type = genetic_ascension_situation_hive
	}
}

can_create_paperclip_universe = {
	OR = {
		has_country_flag = can_create_paperclip_universe
		AND = {
			has_valid_civic = civic_machine_obsessional_directive
			NOT = {
				has_country_flag = failed_paperclip_quota
			}
		}
	}
}

# Check if the Queen can steal this system during the initial expansion phase
synth_queen_can_steal_system = {
	NOT = { has_modifier = queen_scorn_storm }
	OR = {
		# Free system
		NOT = { exists = owner }
		# System owned by a non-standard empire (FE, enclave, marauders)
		owner = {
			NOT = { is_country_type = default }
		}
		# System owned by a player, but with no planets or megastructures
		AND = {
			owner = {
				is_country_type = default
			}
			has_any_megastructure = no
			NOT = {
				any_system_planet = {
					is_colony = yes
				}
			}
		}
	}
}

just_researched_fe_tech = {
	OR = {
		last_increased_tech = tech_dark_matter_deflector
		last_increased_tech = tech_dark_matter_power_core
		last_increased_tech = tech_dark_matter_propulsion
		last_increased_tech = tech_cloaking_dark_matter
		last_increased_tech = tech_fe_affluence_1
		last_increased_tech = tech_fe_affluence_2
		last_increased_tech = tech_fe_nourishment_1
		last_increased_tech = tech_fe_nourishment_2
		last_increased_tech = tech_fe_fabricator_1
		last_increased_tech = tech_fe_fabricator_2
		last_increased_tech = tech_fe_singularity_1
		last_increased_tech = tech_fe_singularity_2
		last_increased_tech = tech_fe_forge_1
		last_increased_tech = tech_fe_forge_2
		last_increased_tech = tech_fe_dome_1
		last_increased_tech = tech_fe_dome_2
		last_increased_tech = tech_fe_fortress_1
		last_increased_tech = tech_fe_fortress_2
		last_increased_tech = tech_fe_administration_1
		last_increased_tech = tech_fe_administration_2
		last_increased_tech = tech_fe_assembly_1
		last_increased_tech = tech_fe_assembly_2
		last_increased_tech = tech_fe_clinic_1
		last_increased_tech = tech_fe_clinic_2
		last_increased_tech = tech_fe_security_1
		last_increased_tech = tech_fe_security_2
		last_increased_tech = tech_fe_market_1
		last_increased_tech = tech_fe_market_2
		last_increased_tech = tech_fe_silo_1
		last_increased_tech = tech_fe_silo_2
		last_increased_tech = tech_fe_entertainment_1
		last_increased_tech = tech_fe_entertainment_2
		last_increased_tech = tech_fe_lab_1
		last_increased_tech = tech_fe_lab_2
		last_increased_tech = tech_fe_mine_1
		last_increased_tech = tech_fe_mine_2
		last_increased_tech = tech_cosmogenesis_escort
		last_increased_tech = tech_cosmogenesis_battlecruiser
		last_increased_tech = tech_cosmogenesis_FE_titan
		last_increased_tech = tech_cosmogenesis_mauler
		last_increased_tech = tech_cosmogenesis_weaver
		last_increased_tech = tech_cosmogenesis_harbinger
		last_increased_tech = tech_cosmogenesis_stinger
	}
}

# Scope: pop_group
# True if this cyborg pop belongs to a Democratic Interlink empire and should join the Interlink faction exclusively
is_interlink_cyborg_pop = {
	has_trait = trait_cybernetic
	owner = {
		is_democratic_authority = yes
		has_country_flag = cyber_collectivist
	}
}
