###############################################
# === xenomorph_amenity_buildings.txt ===
###############################################
###############################################
# XENOMORPH AMENITY BUILDINGS
# Split from xenomorph_buildings_combined.txt.
###############################################

@b1_time = 360
@b2_time = 720
@b3_time = 1080

building_xenomorph_resin_spire = {
	base_buildtime = @b1_time
	category = resource

	building_sets = {
		government
		urban
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
	}
	destroy_trigger = {
		exists = owner
		NOT = { any_owned_pop_group = { is_xenomorph = yes } }
	}

	# T1 amenity: 1 Tunnel Drone for housing/amenity work.
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_tunnel_drone_gestalt_add = 100
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_tunnel_drone_add = 100
		}
	}

	planet_modifier = {
		planet_housing_add = 300
		planet_amenities_add = 300
	}

	resources = {
		category = planet_buildings
		cost = { food = 300 }
		upkeep = { food = 1 }
	}

	upgrades = { building_xenomorph_tunnel_lattice }
}

building_xenomorph_tunnel_lattice = {
	base_buildtime = @b2_time
	can_build = no
	category = amenity
	prerequisites = { tech_xenomorph_tunnel_lattice }

	building_sets = {
		government
		urban
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
	}
	destroy_trigger = {
		exists = owner
		NOT = { any_owned_pop_group = { is_xenomorph = yes } }
	}

	# T2 amenity: 2 Tunnel Drones; light defense bonus.
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_tunnel_drone_gestalt_add = 200
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_tunnel_drone_add = 200
		}
	}

	planet_modifier = {
		planet_housing_add = 500
		planet_amenities_add = 500
		planet_defense_armies_add = 100
	}

	resources = {
		category = planet_buildings
		cost = { food = 500 }
		upkeep = { food = 2 }
	}

	upgrades = { building_xenomorph_hive_resonance_spire }
}


building_xenomorph_hive_resonance_spire = {
	base_buildtime = @b3_time
	can_build = no
	category = amenity
	prerequisites = { tech_xenomorph_hive_resonance_spire }

	building_sets = {
		government
		urban
	}

	# T3 amenity capstone. Requires an upper-tier capital to construct.
	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
	}

	possible = {
		OR = {
			has_building = building_xenomorph_matriarch_hive
			has_building = building_xenomorph_brood_queen_hive
			has_building = building_xenomorph_empress_hive
			has_building = building_xenomorph_war_matriarch_hive
			has_building = building_xenomorph_queen_mother_hive
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			NOR = {
				has_building = building_xenomorph_matriarch_hive
				has_building = building_xenomorph_brood_queen_hive
				has_building = building_xenomorph_empress_hive
				has_building = building_xenomorph_war_matriarch_hive
				has_building = building_xenomorph_queen_mother_hive
			}
		}
	}

	# T3 amenity: 3 Tunnel Drones; broader hive-coordination amenity layer.
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_tunnel_drone_gestalt_add = 300
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_tunnel_drone_add = 300
		}
	}

	planet_modifier = {
		planet_housing_add = 800
		planet_amenities_add = 800
		planet_stability_add = 5
		planet_crime_add = -10
		planet_defense_armies_add = 200
	}

	# Empire-wide minor unity from coordinated pheromone broadcasting.
	country_modifier = {
		country_unity_produces_mult = 0.02
	}

	resources = {
		category = planet_buildings
		cost = { food = 800 minerals = 400 }
		upkeep = { food = 3 energy = 1 }
	}
}

###############################################
# === xenomorph_defense_buildings.txt ===
###############################################
###############################################
# XENOMORPH DEFENSE / ARMY BUILDINGS
# Split from xenomorph_buildings_combined.txt.
###############################################

@b1_time = 360
@b2_time = 720
@b3_time = 1080




###############################################
# DEFENSE CHAIN
# 6-tier linear chain providing planetary defense armies and combat-caste jobs.
# Available to all Xenomorph empires (no civic gate).
# Drone's Nest -> Warrior's Nest -> Sentry's Nest -> Heavy Caste Warren ->
# Adaptive Brood Arsenal -> Apex Caste Warren
###############################################

building_xenomorph_drones_nest = {
	base_buildtime = @b1_time
	category = army

	building_sets = {
		government
		urban
		fortress
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
	}
	destroy_trigger = {
		exists = owner
		NOT = { any_owned_pop_group = { is_xenomorph = yes } }
	}

	# T1 defense: 2 Hunter Drones (basic combat caste).
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_hunter_drone_gestalt_add = 200
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_hunter_drone_add = 200
		}
	}

	planet_modifier = {
		planet_defense_armies_add = 300
	}

	resources = {
		category = planet_buildings
		cost = { food = 400 minerals = 200 }
		upkeep = { food = 3 }
	}

	upgrades = { building_xenomorph_warriors_nest }
	prerequisites = { "tech_xenomorph_drones_nest" }
	can_build = no
}

building_xenomorph_warriors_nest = {
	base_buildtime = @b1_time
	can_build = no
	category = army
	prerequisites = { tech_xenomorph_warriors_nest }

	building_sets = {
		government
		urban
		fortress
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
	}
	destroy_trigger = {
		exists = owner
		NOT = { any_owned_pop_group = { is_xenomorph = yes } }
	}

	# T2 defense: 3 Warrior Drones (combat specialists).
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_warrior_drone_gestalt_add = 200
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_warrior_drone_add = 200
		}
	}

	planet_modifier = {
		planet_defense_armies_add = 600
		army_defense_damage_mult = 0.10
	}

	resources = {
		category = planet_buildings
		cost = { food = 600 minerals = 300 }
		upkeep = { food = 4 }
	}

	upgrades = { building_xenomorph_sentrys_nest }
}

building_xenomorph_sentrys_nest = {
	base_buildtime = @b2_time
	can_build = no
	category = army
	prerequisites = { tech_xenomorph_sentrys_nest }

	building_sets = {
		government
		urban
		fortress
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
	}
	destroy_trigger = {
		exists = owner
		NOT = { any_owned_pop_group = { is_xenomorph = yes } }
	}

	# T3 defense: 2 Warrior Drones + 2 Sentry Drones (perimeter/scout caste).
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_warrior_drone_gestalt_add = 200
			job_xenomorph_sentry_drone_gestalt_add = 100
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_warrior_drone_add = 200
			job_xenomorph_sentry_drone_add = 100
		}
	}

	planet_modifier = {
		planet_defense_armies_add = 900
		army_defense_damage_mult = 0.15
		army_defense_health_mult = 0.10
		planet_orbital_bombardment_damage = -0.10
	}

	resources = {
		category = planet_buildings
		cost = { food = 900 minerals = 500 }
		upkeep = { food = 6 }
	}

	upgrades = { building_xenomorph_hybrid_caste_warren building_xenomorph_heavy_caste_warren }
}

building_xenomorph_heavy_caste_warren = {
	base_buildtime = @b2_time
	can_build = no
	category = army

	building_sets = {
		government
		urban
		fortress
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
		owner = { has_country_flag = xenomorph_heavy_caste_warren_unlocked }
	}

	# Mutually exclusive with the Hybrid branch.
	possible = {
		NOT = { has_building = building_xenomorph_hybrid_caste_warren }
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			has_building = building_xenomorph_hybrid_caste_warren
		}
	}

	# T4-B defense: 3 Heavy Caste drones + 2 Warrior Drones.
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_heavy_caste_gestalt_add = 200
			job_xenomorph_warrior_drone_gestalt_add = 200
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_heavy_caste_add = 200
			job_xenomorph_warrior_drone_add = 200
		}
	}

	planet_modifier = {
		planet_defense_armies_add = 1400
		army_defense_damage_mult = 0.25
		army_defense_health_mult = 0.20
		planet_orbital_bombardment_damage = -0.15
	}

	resources = {
		category = planet_buildings
		cost = { food = 1200 minerals = 700 alloys = 150 }
		upkeep = { food = 8 alloys = 1 }
	}

	upgrades = { building_xenomorph_apex_caste_warren }
}

building_xenomorph_apex_caste_warren = {
	base_buildtime = @b3_time
	can_build = no
	category = army

	building_sets = {
		government
		urban
		fortress
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
		owner = { has_country_flag = xenomorph_apex_caste_warren_unlocked }
	}

	destroy_trigger = {
		exists = owner
		NOT = { any_owned_pop_group = { is_xenomorph = yes } }
	}

	# T5-B defense: 1 Apex Predator + 2 Heavy Caste + 2 Sentry + 1 Warrior.
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_apex_predator_gestalt_add = 100
			job_xenomorph_heavy_caste_gestalt_add = 200
			job_xenomorph_sentry_drone_gestalt_add = 200
			job_xenomorph_warrior_drone_gestalt_add = 100
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_apex_predator_add = 100
			job_xenomorph_heavy_caste_add = 200
			job_xenomorph_sentry_drone_add = 200
			job_xenomorph_warrior_drone_add = 100
		}
	}

	planet_modifier = {
		planet_defense_armies_add = 2500
		army_defense_damage_mult = 0.40
		army_defense_health_mult = 0.30
		planet_orbital_bombardment_damage = -0.20
	}

	country_modifier = {
		army_damage_mult = 0.10
		army_health = 0.10
		armies_upkeep_mult = -0.05
	}

	resources = {
		category = planet_buildings
		cost = { food = 1600 minerals = 900 alloys = 250 }
		upkeep = { food = 10 alloys = 2 }
	}

	upgrades = { building_xenomorph_xenodragon_nest }
}


###############################################
# DEFENSE BRANCH A (Hybrid path)
# Hybrid Caste Warren -> Royal Guard Warren -> Royal Warren
# Each tier unlocked by a tradition pick.
###############################################

building_xenomorph_hybrid_caste_warren = {
	base_buildtime = @b2_time
	can_build = no
	category = army

	building_sets = {
		government
		urban
		fortress
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
		owner = { has_country_flag = xenomorph_hybrid_caste_warren_unlocked }
	}

	# Mutually exclusive with the Heavy Caste branch.
	possible = {
		NOT = { has_building = building_xenomorph_heavy_caste_warren }
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			has_building = building_xenomorph_heavy_caste_warren
		}
	}

	# T4-A defense: 3 Hostline Hybrid Warriors + 2 Warrior Drones.
	# Hybrid Warriors are only fillable by pops with hostline sub-species traits;
	# building strength scales with empire's hostline-pop count.
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_hostline_hybrid_warrior_gestalt_add = 200
			job_xenomorph_warrior_drone_gestalt_add = 200
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_hostline_hybrid_warrior_add = 200
			job_xenomorph_warrior_drone_add = 200
		}
	}

	planet_modifier = {
		planet_defense_armies_add = 1400
		army_defense_damage_mult = 0.20
		army_defense_health_mult = 0.25
	}

	resources = {
		category = planet_buildings
		cost = { food = 1200 minerals = 700 }
		upkeep = { food = 8 }
	}

	upgrades = { building_xenomorph_royal_guard_warren }
}

building_xenomorph_royal_guard_warren = {
	base_buildtime = @b3_time
	can_build = no
	category = army

	building_sets = {
		government
		urban
		fortress
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
		owner = { has_country_flag = xenomorph_royal_guard_warren_unlocked }
	}

	destroy_trigger = {
		exists = owner
		NOT = { any_owned_pop_group = { is_xenomorph = yes } }
	}

	# T5-A defense: enables Praetorian recruitment + retains Hybrid Warriors.
	# 3 Praetorians + 2 Hostline Hybrid Warriors + 1 Warrior Drone.
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_praetorian_gestalt_add = 200
			job_xenomorph_hostline_hybrid_warrior_gestalt_add = 200
			job_xenomorph_warrior_drone_gestalt_add = 100
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_praetorian_add = 200
			job_xenomorph_hostline_hybrid_warrior_add = 200
			job_xenomorph_warrior_drone_add = 100
		}
	}

	planet_modifier = {
		planet_defense_armies_add = 2200
		army_defense_damage_mult = 0.35
		army_defense_health_mult = 0.35
		planet_orbital_bombardment_damage = -0.15
	}

	country_modifier = {
		army_damage_mult = 0.05
		armies_upkeep_mult = -0.05
	}

	resources = {
		category = planet_buildings
		cost = { food = 1500 minerals = 900 alloys = 200 }
		upkeep = { food = 10 alloys = 1 }
	}

	upgrades = { building_xenomorph_royal_warren }
}

building_xenomorph_royal_warren = {
	base_buildtime = @b3_time
	can_build = no
	category = army

	building_sets = {
		government
		urban
		fortress
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
		owner = { has_country_flag = xenomorph_royal_warren_unlocked }
	}

	# T6-A apex: requires War Matriarch caste on planet (i.e. War Matriarch Hive).
	possible = {
		OR = {
			has_job = xenomorph_war_matriarch
			has_job = xenomorph_war_matriarch_gestalt
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			NOR = {
				has_job = xenomorph_war_matriarch
				has_job = xenomorph_war_matriarch_gestalt
			}
		}
	}

	# T6-A apex: adds extra Queens beyond what the capital grants + Praetorian guard caste.
	# 2 Queens + 4 Praetorians + 2 Hostline Hybrid Warriors.
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_queen_gestalt_add = 50
			job_xenomorph_praetorian_gestalt_add = 200
			job_xenomorph_hostline_hybrid_warrior_gestalt_add = 200
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_queen_add = 50
			job_xenomorph_praetorian_add = 200
			job_xenomorph_hostline_hybrid_warrior_add = 200
		}
	}

	planet_modifier = {
		planet_defense_armies_add = 3200
		army_defense_damage_mult = 0.50
		army_defense_health_mult = 0.45
		planet_orbital_bombardment_damage = -0.25
	}

	country_modifier = {
		army_damage_mult = 0.15
		army_health = 0.10
		armies_upkeep_mult = -0.10
		country_unity_produces_mult = 0.05
	}

	resources = {
		category = planet_buildings
		cost = { food = 2200 minerals = 1300 alloys = 400 }
		upkeep = { food = 14 alloys = 3 }
	}
}


###############################################
# DEFENSE BRANCH B (Apex path) T6-B
# Heavy Caste Warren -> Apex Caste Warren -> Xenodragon Nest
###############################################

building_xenomorph_xenodragon_nest = {
	base_buildtime = @b3_time
	can_build = no
	category = army

	building_sets = {
		government
		urban
		fortress
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
		owner = { has_country_flag = xenomorph_xenodragon_nest_unlocked }
	}

	# T6-B apex: requires War Matriarch on planet (the War Matriarch Hive).
	possible = {
		OR = {
			has_job = xenomorph_war_matriarch
			has_job = xenomorph_war_matriarch_gestalt
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			NOR = {
				has_job = xenomorph_war_matriarch
				has_job = xenomorph_war_matriarch_gestalt
			}
		}
	}

	# T6-B apex: 1 Xenodragon (single elite combat ruler) + 2 Apex Predators + 2 Heavy Caste.
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_xenodragon_gestalt_add = 100
			job_xenomorph_apex_predator_gestalt_add = 200
			job_xenomorph_heavy_caste_gestalt_add = 200
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_xenodragon_add = 100
			job_xenomorph_apex_predator_add = 200
			job_xenomorph_heavy_caste_add = 200
		}
	}

	planet_modifier = {
		planet_defense_armies_add = 3500
		army_defense_damage_mult = 0.60
		army_defense_health_mult = 0.50
		planet_orbital_bombardment_damage = -0.30
	}

	country_modifier = {
		army_damage_mult = 0.20
		army_health = 0.15
		armies_upkeep_mult = -0.10
		ship_weapon_damage = 0.05
	}

	resources = {
		category = planet_buildings
		cost = { food = 2200 minerals = 1300 alloys = 500 }
		upkeep = { food = 14 alloys = 4 }
	}
}

###############################################
# === xenomorph_manufacturing_buildings.txt ===
###############################################
###############################################
# XENOMORPH MANUFACTURING BUILDINGS
# Split from xenomorph_buildings_combined.txt.
###############################################

@b1_time = 360
@b2_time = 720
@b3_time = 1080

building_xenomorph_carapace_forge = {
	base_buildtime = @b1_time
	category = manufacturing

	building_sets = {
		government
		urban
		industrial
		foundry
	}

	potential = {
		exists = owner
		owner = { has_civic = civic_xenomorph_carapace_ships }
		any_owned_pop_group = { is_xenomorph = yes }
	}
	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { owner = { has_civic = civic_xenomorph_carapace_ships } }
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
		}
	}

	# T1 manufacturing: 2 Carapace Weavers.
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_carapace_weaver_gestalt_add = 200
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_carapace_weaver_add = 200
		}
	}

	resources = {
		category = planet_buildings
		cost = { food = 800 alloys = 200 }
		upkeep = { food = 3 }
	}

	upgrades = { building_xenomorph_reinforced_carapace_forge }
}


building_xenomorph_reinforced_carapace_forge = {
	base_buildtime = @b2_time
	can_build = no
	category = manufacturing
	prerequisites = { tech_xenomorph_reinforced_carapace_forge }

	building_sets = {
		government
		urban
		industrial
		foundry
	}

	potential = {
		exists = owner
		owner = { has_civic = civic_xenomorph_carapace_ships }
		any_owned_pop_group = { is_xenomorph = yes }
	}
	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { owner = { has_civic = civic_xenomorph_carapace_ships } }
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
		}
	}

	# T2 manufacturing: 3 Carapace Weavers + production efficiency.
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_carapace_weaver_gestalt_add = 300
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_carapace_weaver_add = 300
		}
	}

	planet_modifier = {
		job_xenomorph_carapace_weaver_alloys_produces_mult = 0.10
		job_xenomorph_carapace_weaver_gestalt_alloys_produces_mult = 0.10
	}

	resources = {
		category = planet_buildings
		cost = { food = 1200 alloys = 400 minerals = 200 }
		upkeep = { food = 5 energy = 1 }
	}

	upgrades = { building_xenomorph_living_carapace_foundry }
}


building_xenomorph_living_carapace_foundry = {
	base_buildtime = @b3_time
	can_build = no
	category = manufacturing
	prerequisites = { tech_xenomorph_living_carapace_foundry }

	building_sets = {
		government
		urban
		industrial
		foundry
	}

	potential = {
		exists = owner
		owner = { has_civic = civic_xenomorph_carapace_ships }
		any_owned_pop_group = { is_xenomorph = yes }
	}

	possible = {
		OR = {
			has_building = building_xenomorph_matriarch_hive
			has_building = building_xenomorph_brood_queen_hive
			has_building = building_xenomorph_empress_hive
			has_building = building_xenomorph_war_matriarch_hive
			has_building = building_xenomorph_queen_mother_hive
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { owner = { has_civic = civic_xenomorph_carapace_ships } }
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			NOR = {
				has_building = building_xenomorph_matriarch_hive
				has_building = building_xenomorph_brood_queen_hive
				has_building = building_xenomorph_empress_hive
				has_building = building_xenomorph_war_matriarch_hive
				has_building = building_xenomorph_queen_mother_hive
			}
		}
	}

	# T3 manufacturing capstone: 4 Carapace Weavers + strong production efficiency
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_carapace_weaver_gestalt_add = 400
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_carapace_weaver_add = 400
		}
	}

	planet_modifier = {
		job_xenomorph_carapace_weaver_alloys_produces_mult = 0.25
		job_xenomorph_carapace_weaver_gestalt_alloys_produces_mult = 0.25
		planet_jobs_alloys_produces_mult = 0.10
	}

	# Empire-wide minor ship build speed bonus from living-carapace component manufacture.
	country_modifier = {
		ship_build_speed_mult = 0.05
	}

	resources = {
		category = planet_buildings
		cost = { food = 1600 alloys = 600 minerals = 400 }
		upkeep = { food = 8 energy = 2 }
	}
}

###############################################
# === xenomorph_other_buildings.txt ===
###############################################
###############################################
# XENOMORPH OTHER / CAPITAL / GOVERNMENT / POP ASSEMBLY BUILDINGS
# Split from xenomorph_buildings_combined.txt.
###############################################

@b1_time = 360
@b2_time = 720
@b3_time = 1080

building_xenomorph_queen_mother_hive = {
	base_buildtime = @b3_time
	base_cap_amount = 1
	empire_limit = { base = 1 }
	can_build = no
	capital = yes
	category = government
	position_priority = 100

	building_sets = {
		government
		urban
		fortress
	}

	# Queen Mother Hive is the capital building for Queen Mother origin empires.
	potential = {
		exists = owner
		is_capital = yes
		owner = { has_origin = origin_xenomorph_queen_mother }
		any_owned_pop_group = { is_xenomorph = yes }
	}
	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { is_capital = yes }
			NOT = { owner = { any_owned_species = { has_trait = trait_xenomorph } } }
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
		}
	}

	# Queen Mother (sole ruler) + Paladin guard caste.
	# No Empress/Queen jobs — on a Queen Mother world she rules alone.
	# Paladins replace the Praetorian role on Queen Mother planets.
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_queen_mother_gestalt_add = 1
			job_xenomorph_paladin_gestalt_add = 4
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_queen_mother_add = 1
			job_xenomorph_paladin_add = 4
		}
	}

	# Capital baseline bonuses plus Queen Mother natural throne-world bonuses.
	planet_modifier = {
		planet_stability_add = 15
		planet_crime_add = -30
		planet_amenities_add = 2000
		planet_housing_add = 1000
		logistic_growth_mult = 0.15
		planet_jobs_produces_mult = 0.05
		planet_defense_armies_add = 1000
		army_defense_damage_mult = 0.20
		army_defense_health_mult = 0.20
	}

	country_modifier = {
		country_unity_produces_mult = 0.15
		country_naval_cap_add = 20
		empire_size_pops_mult = -0.05
	}

	resources = {
		category = planet_buildings
		cost = { food = 3000 }
		upkeep = { food = 10 }
	}
}



building_xenomorph_queens_nest_1 = {
	base_buildtime = @b1_time
	base_cap_amount = 1
	capital = yes
	category = government
	position_priority = 100

	building_sets = {
		government
		urban
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
		OR = {
			NOT = { is_capital = yes }
			owner = { NOT = { has_origin = origin_xenomorph_queen_mother } }
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			AND = {
				is_capital = yes
				owner = { has_origin = origin_xenomorph_queen_mother }
			}
		}
	}

	# T1 capital: 1 Queen ruler job + basic elite-guard defense.
	# When a Queen Mother is on the planet (Queen Mother Hive present), the guard
	# caste is Paladins; otherwise Praetorians. No mixing — one or the other.
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = yes }
			has_building = building_xenomorph_queen_mother_hive
		}
		modifier = {
			job_xenomorph_queen_gestalt_add = 50
		}
	}
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = yes }
			NOT = { has_building = building_xenomorph_queen_mother_hive }
		}
		modifier = {
			job_xenomorph_queen_gestalt_add = 50
			job_xenomorph_praetorian_gestalt_add = 100
		}
	}
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = no }
			has_building = building_xenomorph_queen_mother_hive
		}
		modifier = {
			job_xenomorph_queen_add = 50
		}
	}
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = no }
			NOT = { has_building = building_xenomorph_queen_mother_hive }
		}
		modifier = {
			job_xenomorph_queen_add = 50
			job_xenomorph_praetorian_add = 100
		}
	}

	planet_modifier = {
		planet_stability_add = 3
		planet_crime_add = -10
		planet_amenities_add = 500
		planet_housing_add = 300
		logistic_growth_mult = 0.03
		planet_defense_armies_add = 200
	}

	resources = {
		category = planet_buildings
		cost = { food = 500 minerals = 300 }
		upkeep = { food = 4 }
	}

	upgrades = { building_xenomorph_planetary_hive }
}

building_xenomorph_planetary_hive = {
	base_buildtime = @b2_time
	base_cap_amount = 1
	capital = yes
	category = government
	position_priority = 100
	can_build = no

	building_sets = {
		government
		urban
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
		OR = {
			NOT = { is_capital = yes }
			owner = { NOT = { has_origin = origin_xenomorph_queen_mother } }
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			AND = {
				is_capital = yes
				owner = { has_origin = origin_xenomorph_queen_mother }
			}
		}
	}

	# T2 capital: 2 Queen ruler jobs + stronger elite-guard defense.
	# Paladins if a Queen Mother is on the planet; otherwise Praetorians.
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = yes }
			has_building = building_xenomorph_queen_mother_hive
		}
		modifier = {
			job_xenomorph_queen_gestalt_add = 75
		}
	}
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = yes }
			NOT = { has_building = building_xenomorph_queen_mother_hive }
		}
		modifier = {
			job_xenomorph_queen_gestalt_add = 75
			job_xenomorph_praetorian_gestalt_add = 150
		}
	}
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = no }
			has_building = building_xenomorph_queen_mother_hive
		}
		modifier = {
			job_xenomorph_queen_add = 75
		}
	}
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = no }
			NOT = { has_building = building_xenomorph_queen_mother_hive }
		}
		modifier = {
			job_xenomorph_queen_add = 75
			job_xenomorph_praetorian_add = 150
		}
	}

	planet_modifier = {
		planet_stability_add = 5
		planet_crime_add = -15
		planet_amenities_add = 800
		planet_housing_add = 500
		logistic_growth_mult = 0.05
		planet_jobs_unity_produces_mult = 0.03
		planet_defense_armies_add = 400
	}

	resources = {
		category = planet_buildings
		cost = { food = 900 minerals = 500 }
		upkeep = { food = 6 }
	}

	upgrades = { building_xenomorph_matriarch_hive }
}

building_xenomorph_empress_hive = {
	base_buildtime = @b3_time
	base_cap_amount = 1
	capital = yes
	category = government
	position_priority = 100
	can_build = no
	prerequisites = { tech_xenomorph_empress_hive }

	building_sets = {
		government
		urban
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
		OR = {
			NOT = { is_capital = yes }
			owner = { NOT = { has_origin = origin_xenomorph_queen_mother } }
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			AND = {
				is_capital = yes
				owner = { has_origin = origin_xenomorph_queen_mother }
			}
		}
	}

	# T4-B capital: 1 Empress + 3 Queens
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_empress_gestalt_add = 1
			job_xenomorph_queen_gestalt_add = 100
			job_xenomorph_praetorian_gestalt_add = 200
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_empress_add = 1
			job_xenomorph_queen_add = 100
		}
	}

	planet_modifier = {
		# Production/research/deviancy control focus
		planet_stability_add = 10
		planet_crime_add = -30
		planet_amenities_add = 1800
		planet_housing_add = 900
		logistic_growth_mult = 0.08
		planet_jobs_unity_produces_mult = 0.08
		planet_jobs_produces_mult = 0.05
		planet_jobs_physics_research_produces_mult = 0.10
		planet_jobs_society_research_produces_mult = 0.10
		planet_jobs_engineering_research_produces_mult = 0.10
	}

	resources = {
		category = planet_buildings
		cost = { food = 2200 minerals = 1200 }
		upkeep = { food = 12 }
	}
}

building_xenomorph_brood_queen_hive = {
	base_buildtime = @b3_time
	base_cap_amount = 1
	capital = yes
	category = government
	position_priority = 100
	can_build = no
	prerequisites = { tech_xenomorph_broodmother_hive }

	building_sets = {
		government
		urban
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
		OR = {
			NOT = { is_capital = yes }
			owner = { NOT = { has_origin = origin_xenomorph_queen_mother } }
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			AND = {
				is_capital = yes
				owner = { has_origin = origin_xenomorph_queen_mother }
			}
		}
	}

	# T4-A capital: 4 Brood Queens. No Praetorian/Paladin guard layer at this branch
	# (reproductive focus). Add Paladins if Queen Mother Hive is also present.
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = yes }
			has_building = building_xenomorph_queen_mother_hive
		}
		modifier = {
			job_xenomorph_brood_queen_gestalt_add = 50
			job_xenomorph_praetorian_gestalt_add = 100
		}
	}
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = yes }
			NOT = { has_building = building_xenomorph_queen_mother_hive }
		}
		modifier = {
			job_xenomorph_brood_queen_gestalt_add = 50
			job_xenomorph_praetorian_gestalt_add = 100
		}
	}
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = no }
			has_building = building_xenomorph_queen_mother_hive
		}
		modifier = {
			job_xenomorph_brood_queen_add = 50
		}
	}
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = no }
			NOT = { has_building = building_xenomorph_queen_mother_hive }
		}
		modifier = {
			job_xenomorph_brood_queen_add = 50
		}
	}

	planet_modifier = {
		# High egg output, pop growth/assembly, amenities.
		job_xenomorph_egg_caretaker_xenomorph_eggs_produces_mult = 0.15
		job_xenomorph_egg_caretaker_gestalt_xenomorph_eggs_produces_mult = 0.15
		job_xenomorph_brood_queen_xenomorph_eggs_produces_mult = 0.25
		job_xenomorph_brood_queen_gestalt_xenomorph_eggs_produces_mult = 0.25
		job_xenomorph_broodmother_slave_xenomorph_offspring_produces_mult = 0.25
		job_xenomorph_broodmare_thrall_xenomorph_offspring_produces_mult = 0.25
		logistic_growth_mult = 0.10
		planet_pop_assembly_organic_mult = 0.10
		planet_amenities_add = 1500
		planet_housing_add = 800
		planet_stability_add = 5
		# Reduces slave happiness (vanilla 4.x modifier).
		pop_cat_slave_happiness = -0.10
	}

	resources = {
		category = planet_buildings
		cost = { food = 2200 minerals = 1200 }
		upkeep = { food = 12 }
	}
}

building_xenomorph_matriarch_hive = {
	base_buildtime = @b2_time
	base_cap_amount = 1
	capital = yes
	category = government
	position_priority = 100
	can_build = no
	prerequisites = { tech_xenomorph_matriarch_hive }

	building_sets = {
		government
		urban
		fortress
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
		OR = {
			NOT = { is_capital = yes }
			owner = { NOT = { has_origin = origin_xenomorph_queen_mother } }
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			AND = {
				is_capital = yes
				owner = { has_origin = origin_xenomorph_queen_mother }
			}
		}
	}

	# T3 capital: 1 Matriarch + 3 Queens.
	# Paladins replace Praetorians when a Queen Mother is on the planet.
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = yes }
			has_building = building_xenomorph_queen_mother_hive
		}
		modifier = {
			job_xenomorph_matriarch_gestalt_add = 1
			job_xenomorph_queen_gestalt_add = 100
		}
	}
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = yes }
			NOT = { has_building = building_xenomorph_queen_mother_hive }
		}
		modifier = {
			job_xenomorph_matriarch_gestalt_add = 1
			job_xenomorph_queen_gestalt_add = 100
			job_xenomorph_praetorian_gestalt_add = 200
		}
	}
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = no }
			has_building = building_xenomorph_queen_mother_hive
		}
		modifier = {
			job_xenomorph_matriarch_add = 1
			job_xenomorph_queen_add = 100
		}
	}
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = no }
			NOT = { has_building = building_xenomorph_queen_mother_hive }
		}
		modifier = {
			job_xenomorph_matriarch_add = 1
			job_xenomorph_queen_add = 100
			job_xenomorph_praetorian_add = 200
		}
	}

	planet_modifier = {
		planet_stability_add = 7
		planet_crime_add = -20
		planet_amenities_add = 1200
		planet_housing_add = 700
		logistic_growth_mult = 0.08
		planet_jobs_unity_produces_mult = 0.05
		job_xenomorph_egg_caretaker_xenomorph_eggs_produces_mult = 0.05
		job_xenomorph_egg_caretaker_gestalt_xenomorph_eggs_produces_mult = 0.05
		planet_defense_armies_add = 600
		army_defense_damage_mult = 0.15
	}

	country_modifier = {
		country_naval_cap_add = 10
		starbase_shipyard_build_speed_mult = 0.10
	}

	resources = {
		category = planet_buildings
		cost = { food = 1200 alloys = 300 }
		upkeep = { food = 8 }
	}

	upgrades = { building_xenomorph_brood_queen_hive building_xenomorph_empress_hive building_xenomorph_war_matriarch_hive }
}

building_xenomorph_royal_jelly_pools = {
	base_buildtime = @b2_time
	base_cap_amount = 1
	category = pop_assembly
	position_priority = 80
	can_build = no
	prerequisites = { tech_xenomorph_royal_jelly_pools }

	building_sets = {
		government
		urban
	}

	# T2 royal jelly building. Stronger reproductive bonuses than T1.
	potential = {
		exists = owner
		owner = { any_owned_species = { has_trait = trait_xenomorph } }
		any_owned_pop_group = { is_xenomorph = yes }
	}

	possible = {
		OR = {
			has_building = building_xenomorph_queens_nest_1
			has_building = building_xenomorph_planetary_hive
			has_building = building_xenomorph_matriarch_hive
			has_building = building_xenomorph_brood_queen_hive
			has_building = building_xenomorph_empress_hive
			has_building = building_xenomorph_war_matriarch_hive
			has_building = building_xenomorph_queen_mother_hive
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { owner = { any_owned_species = { has_trait = trait_xenomorph } } }
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			NOR = {
				has_building = building_xenomorph_queens_nest_1
				has_building = building_xenomorph_planetary_hive
				has_building = building_xenomorph_matriarch_hive
				has_building = building_xenomorph_brood_queen_hive
				has_building = building_xenomorph_empress_hive
				has_building = building_xenomorph_war_matriarch_hive
				has_building = building_xenomorph_queen_mother_hive
			}
		}
	}

	# 2 Royal Jelly Tenders + 2 Spawning Drones
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_royal_jelly_tender_gestalt_add = 200
			job_spawning_drone_add = 200
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_royal_jelly_tender_add = 200
		}
	}

	planet_modifier = {
		# Stronger egg + offspring boost
		job_xenomorph_brood_queen_xenomorph_eggs_produces_mult = 0.10
		job_xenomorph_brood_queen_gestalt_xenomorph_eggs_produces_mult = 0.10
		job_xenomorph_broodmother_slave_xenomorph_offspring_produces_mult = 0.10
		job_xenomorph_broodmare_thrall_xenomorph_offspring_produces_mult = 0.10
		planet_pop_assembly_organic_mult = 0.05
	}

	resources = {
		category = planet_xenomorph_growth_buildings
		cost = {
			minerals = 600
			xenomorph_eggs = 10
		}
		upkeep = {
			energy = 2
			xenomorph_eggs = 2
		}
	}

	upgrades = { building_xenomorph_royal_brood_nexus }
}


building_xenomorph_war_matriarch_hive = {
	base_buildtime = @b3_time
	base_cap_amount = 1
	capital = yes
	category = government
	position_priority = 100
	can_build = no
	prerequisites = { tech_xenomorph_war_matriarch_hive }

	building_sets = {
		government
		urban
		fortress
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
		OR = {
			NOT = { is_capital = yes }
			owner = { NOT = { has_origin = origin_xenomorph_queen_mother } }
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			AND = {
				is_capital = yes
				owner = { has_origin = origin_xenomorph_queen_mother }
			}
		}
	}

	# T4-C capital: 1 War Matriarch + 3 Queens + heavy elite-guard presence.
	# Paladins if a Queen Mother is on the planet; otherwise Praetorians.
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = yes }
			has_building = building_xenomorph_queen_mother_hive
		}
		modifier = {
			job_xenomorph_war_matriarch_gestalt_add = 1
			job_xenomorph_queen_gestalt_add = 100
		}
	}
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = yes }
			NOT = { has_building = building_xenomorph_queen_mother_hive }
		}
		modifier = {
			job_xenomorph_war_matriarch_gestalt_add = 1
			job_xenomorph_queen_gestalt_add = 100
			job_xenomorph_praetorian_gestalt_add = 200
		}
	}
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = no }
			has_building = building_xenomorph_queen_mother_hive
		}
		modifier = {
			job_xenomorph_war_matriarch_add = 1
			job_xenomorph_queen_add = 100
		}
	}
	triggered_planet_modifier = {
		potential = {
			owner = { is_gestalt = no }
			NOT = { has_building = building_xenomorph_queen_mother_hive }
		}
		modifier = {
			job_xenomorph_war_matriarch_add = 1
			job_xenomorph_queen_add = 100
			job_xenomorph_praetorian_add = 200
		}
	}

	planet_modifier = {
		planet_stability_add = 8
		planet_crime_add = -15
		planet_amenities_add = 1500
		planet_housing_add = 800
		logistic_growth_mult = 0.05
		planet_defense_armies_add = 2000
		army_defense_damage_mult = 0.25
		army_defense_health_mult = 0.25
	}

	country_modifier = {
		country_naval_cap_add = 30
		armies_upkeep_mult = -0.15
		army_damage_mult = 0.15
		army_health = 0.15
		ship_fire_rate_mult = 0.05
		ship_weapon_damage = 0.05
		starbase_shipyard_build_speed_mult = 0.15
	}

	resources = {
		category = planet_buildings
		cost = { food = 2200 minerals = 1200 alloys = 400 }
		upkeep = { food = 12 alloys = 4 }
	}
}


building_xenomorph_royal_jelly_pods = {
	base_buildtime = @b1_time
	base_cap_amount = 1
	category = pop_assembly
	position_priority = 80

	building_sets = {
		government
		urban
	}

	# T1 entry-tier royal jelly building. Available on any colony with at least
	# a Queen's Nest (the basic capital tier). No prerequisite tech — early-game.
	potential = {
		exists = owner
		owner = { any_owned_species = { has_trait = trait_xenomorph } }
		any_owned_pop_group = { is_xenomorph = yes }
	}

	possible = {
		OR = {
			has_building = building_xenomorph_queens_nest_1
			has_building = building_xenomorph_planetary_hive
			has_building = building_xenomorph_matriarch_hive
			has_building = building_xenomorph_brood_queen_hive
			has_building = building_xenomorph_empress_hive
			has_building = building_xenomorph_war_matriarch_hive
			has_building = building_xenomorph_queen_mother_hive
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { owner = { any_owned_species = { has_trait = trait_xenomorph } } }
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			NOR = {
				has_building = building_xenomorph_queens_nest_1
				has_building = building_xenomorph_planetary_hive
				has_building = building_xenomorph_matriarch_hive
				has_building = building_xenomorph_brood_queen_hive
				has_building = building_xenomorph_empress_hive
				has_building = building_xenomorph_war_matriarch_hive
				has_building = building_xenomorph_queen_mother_hive
			}
		}
	}

	# 1 Royal Jelly Tender + 1 vanilla Spawning Drone (assembly role)
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_royal_jelly_tender_gestalt_add = 100
			job_spawning_drone_add = 100
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_royal_jelly_tender_add = 100
		}
	}

	planet_modifier = {
		# Slight egg + offspring boost (doc: "slight")
		job_xenomorph_broodmother_slave_xenomorph_offspring_produces_mult = 0.05
		job_xenomorph_broodmare_thrall_xenomorph_offspring_produces_mult = 0.05
		planet_pop_assembly_organic_mult = 0.03
	}

	resources = {
		category = planet_xenomorph_growth_buildings
		cost = {
			minerals = 300
			xenomorph_eggs = 5
		}
		upkeep = {
			energy = 1
			xenomorph_eggs = 1
		}
	}

	upgrades = { building_xenomorph_royal_jelly_pools }
}


building_xenomorph_royal_brood_nexus = {
	base_buildtime = @b3_time
	base_cap_amount = 1
	category = pop_assembly
	position_priority = 80
	can_build = no
	prerequisites = { tech_xenomorph_royal_brood_nexus }

	building_sets = {
		government
		urban
	}

	# T3 apex royal jelly building for non-Queen-Mother empires. Strongest
	# reproductive production. Requires an upper-tier capital.
	potential = {
		exists = owner
		owner = { any_owned_species = { has_trait = trait_xenomorph } }
		any_owned_pop_group = { is_xenomorph = yes }
		owner = { NOT = { has_origin = origin_xenomorph_queen_mother } }
	}

	possible = {
		OR = {
			has_building = building_xenomorph_matriarch_hive
			has_building = building_xenomorph_brood_queen_hive
			has_building = building_xenomorph_empress_hive
			has_building = building_xenomorph_war_matriarch_hive
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { owner = { any_owned_species = { has_trait = trait_xenomorph } } }
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			owner = { has_origin = origin_xenomorph_queen_mother }
			NOR = {
				has_building = building_xenomorph_matriarch_hive
				has_building = building_xenomorph_brood_queen_hive
				has_building = building_xenomorph_empress_hive
				has_building = building_xenomorph_war_matriarch_hive
			}
		}
	}

	# 3 Royal Jelly Tenders + 3 Spawning Drones, with royal-caste capable boost
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_royal_jelly_tender_gestalt_add = 300
			job_spawning_drone_add = 300
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_royal_jelly_tender_add = 300
		}
	}

	planet_modifier = {
		# Strongest egg + offspring boost; royal-caste capable
		job_xenomorph_brood_queen_xenomorph_eggs_produces_mult = 0.15
		job_xenomorph_brood_queen_gestalt_xenomorph_eggs_produces_mult = 0.15
		job_xenomorph_queen_xenomorph_eggs_produces_mult = 0.10
		job_xenomorph_queen_gestalt_xenomorph_eggs_produces_mult = 0.10
		job_xenomorph_matriarch_xenomorph_eggs_produces_mult = 0.10
		job_xenomorph_matriarch_gestalt_xenomorph_eggs_produces_mult = 0.10
		job_xenomorph_empress_xenomorph_eggs_produces_mult = 0.10
		job_xenomorph_empress_gestalt_xenomorph_eggs_produces_mult = 0.10
		job_xenomorph_broodmother_slave_xenomorph_offspring_produces_mult = 0.15
		job_xenomorph_broodmare_thrall_xenomorph_offspring_produces_mult = 0.15
		planet_pop_assembly_organic_mult = 0.10
	}

	resources = {
		category = planet_xenomorph_growth_buildings
		cost = {
			minerals = 1000
			alloys = 150
			xenomorph_eggs = 20
		}
		upkeep = {
			energy = 4
			xenomorph_eggs = 3
		}
	}
}


building_xenomorph_queen_mother_royal_jelly_pods = {
	base_buildtime = @b3_time
	base_cap_amount = 1
	empire_limit = { base = 1 }
	category = pop_assembly
	position_priority = 80
	can_build = no

	building_sets = {
		government
		urban
	}

	# Queen Mother origin-only apex royal jelly variant. Strongest version
	# of the chain. Requires Queen Mother Hive present (which only exists on
	# Queen Mother origin capitals).
	potential = {
		exists = owner
		owner = { has_origin = origin_xenomorph_queen_mother }
		owner = { any_owned_species = { has_trait = trait_xenomorph } }
		any_owned_pop_group = { is_xenomorph = yes }
	}

	possible = {
		has_building = building_xenomorph_queen_mother_hive
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { owner = { has_origin = origin_xenomorph_queen_mother } }
			NOT = { owner = { any_owned_species = { has_trait = trait_xenomorph } } }
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			NOT = { has_building = building_xenomorph_queen_mother_hive }
		}
	}

	# 4 Royal Jelly Tenders + 4 Spawning Drones; strongest chain version
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_royal_jelly_tender_gestalt_add = 400
			job_spawning_drone_add = 400
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_royal_jelly_tender_add = 400
		}
	}

	planet_modifier = {
		# Strongest version of the chain, with Queen Mother boost
		job_xenomorph_brood_queen_xenomorph_eggs_produces_mult = 0.20
		job_xenomorph_brood_queen_gestalt_xenomorph_eggs_produces_mult = 0.20
		job_xenomorph_queen_xenomorph_eggs_produces_mult = 0.15
		job_xenomorph_queen_gestalt_xenomorph_eggs_produces_mult = 0.15
		job_xenomorph_matriarch_xenomorph_eggs_produces_mult = 0.15
		job_xenomorph_matriarch_gestalt_xenomorph_eggs_produces_mult = 0.15
		job_xenomorph_empress_xenomorph_eggs_produces_mult = 0.15
		job_xenomorph_empress_gestalt_xenomorph_eggs_produces_mult = 0.15
		job_xenomorph_queen_mother_xenomorph_eggs_produces_mult = 0.15
		job_xenomorph_queen_mother_gestalt_xenomorph_eggs_produces_mult = 0.15
		job_xenomorph_broodmother_slave_xenomorph_offspring_produces_mult = 0.20
		job_xenomorph_broodmare_thrall_xenomorph_offspring_produces_mult = 0.20
		planet_pop_assembly_organic_mult = 0.15
		logistic_growth_mult = 0.05
	}

	resources = {
		category = planet_xenomorph_growth_buildings
		cost = {
			minerals = 1500
			alloys = 200
			xenomorph_eggs = 30
		}
		upkeep = {
			energy = 5
			xenomorph_eggs = 4
		}
	}
}

###############################################
# === xenomorph_research_buildings.txt ===
###############################################
###############################################
# XENOMORPH RESEARCH BUILDINGS
# Pass 18 rebalance: 3 chains x 3 tiers = 9 buildings, all tech-gated.
# Specialist research focus: each chain spawns ONLY its specialist research
# jobs (calculator_biologist/engineer/physicist) plus a multiplier for that
# specific research type.
#
# Tier scaling:
#   T1: +30 specialist jobs, +5% specialist multiplier
#   T2: +60 specialist jobs, +10% specialist multiplier
#   T3: +90 specialist jobs, +15% specialist multiplier
#
# Per user spec: upkeep uses xenomorph_offspring instead of food.
# All tiers require offspring as upkeep — production drives reproduction.
###############################################

@b1_time = 360
@b2_time = 720
@b3_time = 1080

#################################################################
# SOCIETY RESEARCH CHAIN (calculator_biologist)
#################################################################

# T1 Society — Genetic Memory Pit
building_xenomorph_genetic_memory_pit = {
	base_buildtime = @b1_time
	category = research
	base_cap_amount = 1
	prerequisites = { tech_xenomorph_genetic_memory_archives }

	building_sets = {
		government
		urban
		research
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	planet_modifier = {
		job_calculator_biologist_add = 100
		planet_jobs_society_research_produces_mult = 0.05
	}

	resources = {
		category = planet_buildings
		cost = { minerals = 400 energy = 100 }
		upkeep = { xenomorph_offspring = 2 energy = 2 }
	}

	upgrades = { building_xenomorph_hostline_gene_archive }
}


# T2 Society — Hostline Gene Archive
building_xenomorph_hostline_gene_archive = {
	base_buildtime = @b2_time
	category = research
	base_cap_amount = 1
	can_build = no
	prerequisites = { tech_xenomorph_hostline_gene_archive }

	building_sets = {
		government
		urban
		research
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	planet_modifier = {
		job_calculator_biologist_add = 200
		planet_jobs_society_research_produces_mult = 0.10
	}

	resources = {
		category = planet_buildings
		cost = { minerals = 700 exotic_gases = 25 }
		upkeep = { xenomorph_offspring = 4 energy = 3 exotic_gases = 1 }
	}

	upgrades = { building_xenomorph_apex_genetic_codex }
}


# T3 Society — Apex Genetic Codex (NEW)
building_xenomorph_apex_genetic_codex = {
	base_buildtime = @b3_time
	category = research
	base_cap_amount = 1
	can_build = no
	prerequisites = { tech_xenomorph_apex_genetic_codex }

	building_sets = {
		government
		urban
		research
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	planet_modifier = {
		job_calculator_biologist_add = 400
		planet_jobs_society_research_produces_mult = 0.15
	}

	resources = {
		category = planet_buildings
		cost = { minerals = 1000 exotic_gases = 50 rare_crystals = 25 }
		upkeep = { xenomorph_offspring = 6 energy = 4 exotic_gases = 2 rare_crystals = 1 }
	}
}


#################################################################
# ENGINEERING RESEARCH CHAIN (calculator_engineer)
#################################################################

# T1 Engineering — Chitin Engineering Spire
building_xenomorph_chitin_engineering_spire = {
	base_buildtime = @b1_time
	category = research
	base_cap_amount = 1
	prerequisites = { tech_xenomorph_chitin_architecture }

	building_sets = {
		government
		urban
		research
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	planet_modifier = {
		job_calculator_engineer_add = 100
		planet_jobs_engineering_research_produces_mult = 0.05
	}

	resources = {
		category = planet_buildings
		cost = { minerals = 400 energy = 100 }
		upkeep = { xenomorph_offspring = 2 energy = 2 }
	}

	upgrades = { building_xenomorph_resin_structural_crucible }
}


# T2 Engineering — Resin Structural Crucible
building_xenomorph_resin_structural_crucible = {
	base_buildtime = @b2_time
	category = research
	base_cap_amount = 1
	can_build = no
	prerequisites = { tech_xenomorph_resin_structural_crucible }

	building_sets = {
		government
		urban
		research
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	planet_modifier = {
		job_calculator_engineer_add = 200
		planet_jobs_engineering_research_produces_mult = 0.10
	}

	resources = {
		category = planet_buildings
		cost = { minerals = 700 exotic_gases = 25 }
		upkeep = { xenomorph_offspring = 4 energy = 3 exotic_gases = 1 }
	}

	upgrades = { building_xenomorph_apex_resin_forge }
}


# T3 Engineering — Apex Resin Forge (NEW)
building_xenomorph_apex_resin_forge = {
	base_buildtime = @b3_time
	category = research
	base_cap_amount = 1
	can_build = no
	prerequisites = { tech_xenomorph_apex_resin_forge }

	building_sets = {
		government
		urban
		research
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	planet_modifier = {
		job_calculator_engineer_add = 400
		planet_jobs_engineering_research_produces_mult = 0.15
	}

	resources = {
		category = planet_buildings
		cost = { minerals = 1000 exotic_gases = 50 rare_crystals = 25 }
		upkeep = { xenomorph_offspring = 6 energy = 4 exotic_gases = 2 rare_crystals = 1 }
	}
}


#################################################################
# PHYSICS RESEARCH CHAIN (calculator_physicist)
#################################################################

# T1 Physics — Bioelectric Resonance Node
building_xenomorph_bioelectric_resonance_node = {
	base_buildtime = @b1_time
	category = research
	base_cap_amount = 1
	prerequisites = { tech_xenomorph_bioelectric_resonance }

	building_sets = {
		government
		urban
		research
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	planet_modifier = {
		job_calculator_physicist_add = 100
		planet_jobs_physics_research_produces_mult = 0.05
	}

	resources = {
		category = planet_buildings
		cost = { minerals = 400 energy = 100 }
		upkeep = { xenomorph_offspring = 2 energy = 2 }
	}

	upgrades = { building_xenomorph_bioelectric_resonance_cathedral }
}


# T2 Physics — Bioelectric Resonance Cathedral (NEW)
building_xenomorph_bioelectric_resonance_cathedral = {
	base_buildtime = @b2_time
	category = research
	base_cap_amount = 1
	can_build = no
	prerequisites = { tech_xenomorph_bioelectric_cathedral }

	building_sets = {
		government
		urban
		research
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	planet_modifier = {
		job_calculator_physicist_add = 200
		planet_jobs_physics_research_produces_mult = 0.10
	}

	resources = {
		category = planet_buildings
		cost = { minerals = 700 exotic_gases = 25 }
		upkeep = { xenomorph_offspring = 4 energy = 3 exotic_gases = 1 }
	}

	upgrades = { building_xenomorph_apex_bioelectric_singularity }
}


# T3 Physics — Apex Bioelectric Singularity (NEW)
building_xenomorph_apex_bioelectric_singularity = {
	base_buildtime = @b3_time
	category = research
	base_cap_amount = 1
	can_build = no
	prerequisites = { tech_xenomorph_apex_bioelectric_singularity }

	building_sets = {
		government
		urban
		research
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	planet_modifier = {
		job_calculator_physicist_add = 400
		planet_jobs_physics_research_produces_mult = 0.15
	}

	resources = {
		category = planet_buildings
		cost = { minerals = 1000 exotic_gases = 50 rare_crystals = 25 }
		upkeep = { xenomorph_offspring = 6 energy = 4 exotic_gases = 2 rare_crystals = 1 }
	}
}

###############################################
# === xenomorph_resource_buildings.txt ===
###############################################
###############################################
# XENOMORPH RESOURCE BUILDINGS
# Pass 19 redesign: 3 chains x 3 tiers = 9 buildings + Biomass Cultivation Pit.
#
# Egg Chain  (civic-gated to civic_xenomorph_offspring_egg_economy):
#   T1 Egg Chamber -> T2 Ovomorph Chamber -> T3 Royal Brood Vault
#   Without the civic, these buildings are not visible in the build menu.
#
# Food Chain (standard, all Xeno empires):
#   T1 Nutrient Extraction Pit -> T2 Biomass Processing Hive -> T3 Apex Nutrient Sanctum
#
# Energy Chain (standard, all Xeno empires):
#   T1 Acid Gland Refinery -> T2 Acid Reactor Spire -> T3 Apex Acid Conduit
#
# Plus: Biomass Cultivation Pit (untiered basic food, replaces vanilla hydroponics).
#
# Tier scaling:
#   T1: +30 specialist jobs, +5% job production multiplier
#   T2: +60 specialist jobs, +10% job production multiplier (tech-gated, upgrades from T1)
#   T3: +90 specialist jobs, +15% job production multiplier (tech-gated, upgrades from T2)
###############################################

@b1_time = 360
@b2_time = 720
@b3_time = 1080


#################################################################
# EGG CHAIN — civic-gated to civic_xenomorph_offspring_egg_economy
#################################################################

# T1 Egg Chamber
building_xenomorph_egg_chamber = {
	base_buildtime = @b1_time
	category = manufacturing
	base_cap_amount = 1

	building_sets = {
		government
		urban
		farming
	}

	potential = {
		exists = owner
		owner = {
			xeno_is_xenomorph_hive_country = yes
			OR = {
				has_civic = civic_xenomorph_offspring_egg_economy
				has_technology = tech_xenomorph_egg_economy
			}
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
			AND = {
				NOT = { owner = { has_civic = civic_xenomorph_offspring_egg_economy } }
				NOT = { owner = { has_technology = tech_xenomorph_egg_economy } }
			}
		}
	}

	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		job_xenomorph_egg_caretaker_gestalt_add = 100
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		job_xenomorph_egg_caretaker_add = 100
	}

	planet_modifier = {
		planet_xenomorph_egg_storage_jobs_xenomorph_eggs_produces_mult = 0.05
	}

	resources = {
		category = planet_buildings
		cost = { food = 400 minerals = 100 }
		upkeep = { energy = 2 food = 1 }
	}

	upgrades = { building_xenomorph_ovomorph_chamber }
}


# T2 Ovomorph Chamber
building_xenomorph_ovomorph_chamber = {
	base_buildtime = @b2_time
	category = manufacturing
	base_cap_amount = 1
	can_build = no
	prerequisites = { tech_xenomorph_ovomorph_chamber tech_xenomorph_ovomorph_chamber_researched }

	building_sets = {
		government
		urban
		farming
	}

	potential = {
		exists = owner
		owner = {
			xeno_is_xenomorph_hive_country = yes
			OR = {
				has_civic = civic_xenomorph_offspring_egg_economy
				has_technology = tech_xenomorph_egg_economy
			}
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
			AND = {
				NOT = { owner = { has_civic = civic_xenomorph_offspring_egg_economy } }
				NOT = { owner = { has_technology = tech_xenomorph_egg_economy } }
			}
		}
	}

	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		job_xenomorph_egg_caretaker_gestalt_add = 200
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		job_xenomorph_egg_caretaker_add = 200
	}

	planet_modifier = {
		planet_xenomorph_egg_storage_jobs_xenomorph_eggs_produces_mult = 0.10
	}

	resources = {
		category = planet_buildings
		cost = { food = 700 minerals = 200 exotic_gases = 25 }
		upkeep = { energy = 3 food = 2 xenomorph_offspring = 1 }
	}

	upgrades = { building_xenomorph_royal_brood_vault }
}


# T3 Royal Brood Vault (NEW)
building_xenomorph_royal_brood_vault = {
	base_buildtime = @b3_time
	category = manufacturing
	base_cap_amount = 1
	can_build = no
	prerequisites = { tech_xenomorph_royal_brood_vault tech_xenomorph_royal_brood_vault_researched }

	building_sets = {
		government
		urban
		farming
	}

	potential = {
		exists = owner
		owner = {
			xeno_is_xenomorph_hive_country = yes
			OR = {
				has_civic = civic_xenomorph_offspring_egg_economy
				has_technology = tech_xenomorph_egg_economy
			}
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
			AND = {
				NOT = { owner = { has_civic = civic_xenomorph_offspring_egg_economy } }
				NOT = { owner = { has_technology = tech_xenomorph_egg_economy } }
			}
		}
	}

	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		job_xenomorph_egg_caretaker_gestalt_add = 400
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		job_xenomorph_egg_caretaker_add = 400
	}

	planet_modifier = {
		planet_xenomorph_egg_storage_jobs_xenomorph_eggs_produces_mult = 0.15
	}

	resources = {
		category = planet_buildings
		cost = { food = 1000 minerals = 300 exotic_gases = 50 rare_crystals = 25 }
		upkeep = { energy = 4 food = 3 xenomorph_offspring = 2 rare_crystals = 1 }
	}
}


#################################################################
# FOOD CHAIN — standard, all Xeno empires
#################################################################

# T1 Nutrient Extraction Pit
building_xenomorph_nutrient_extraction_pit = {
	base_buildtime = @b1_time
	category = resource
	base_cap_amount = 1

	building_sets = {
		government
		urban
		farming
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		job_xenomorph_extraction_drone_gestalt_add = 100
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		job_xenomorph_extraction_drone_add = 100
	}

	planet_modifier = {
		planet_jobs_food_produces_mult = 0.05
	}

	resources = {
		category = planet_buildings
		cost = { food = 400 minerals = 100 }
		upkeep = { energy = 2 }
	}

	upgrades = { building_xenomorph_biomass_processing_hive }
}


# T2 Biomass Processing Hive (NEW)
building_xenomorph_biomass_processing_hive = {
	base_buildtime = @b2_time
	category = resource
	base_cap_amount = 1
	can_build = no
	prerequisites = { tech_xenomorph_biomass_processing_hive }

	building_sets = {
		government
		urban
		farming
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		job_xenomorph_extraction_drone_gestalt_add = 200
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		job_xenomorph_extraction_drone_add = 200
	}

	planet_modifier = {
		planet_jobs_food_produces_mult = 0.10
	}

	resources = {
		category = planet_buildings
		cost = { food = 700 minerals = 200 exotic_gases = 25 }
		upkeep = { energy = 3 xenomorph_offspring = 1 }
	}

	upgrades = { building_xenomorph_apex_nutrient_sanctum }
}


# T3 Apex Nutrient Sanctum (NEW)
building_xenomorph_apex_nutrient_sanctum = {
	base_buildtime = @b3_time
	category = resource
	base_cap_amount = 1
	can_build = no
	prerequisites = { tech_xenomorph_apex_nutrient_sanctum }

	building_sets = {
		government
		urban
		farming
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		job_xenomorph_extraction_drone_gestalt_add = 400
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		job_xenomorph_extraction_drone_add = 400
	}

	planet_modifier = {
		planet_jobs_food_produces_mult = 0.15
	}

	resources = {
		category = planet_buildings
		cost = { food = 1000 minerals = 300 exotic_gases = 50 rare_crystals = 25 }
		upkeep = { energy = 4 xenomorph_offspring = 2 rare_crystals = 1 }
	}
}


#################################################################
# ENERGY CHAIN — standard, all Xeno empires
#################################################################

# T1 Acid Gland Refinery
building_xenomorph_acid_gland_refinery = {
	base_buildtime = @b1_time
	category = resource
	base_cap_amount = 1

	building_sets = {
		government
		urban
		industrial
		mining
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		job_xenomorph_acid_processor_gestalt_add = 100
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		job_xenomorph_acid_processor_add = 100
	}

	planet_modifier = {
		planet_jobs_energy_produces_mult = 0.05
	}

	resources = {
		category = planet_buildings
		cost = { food = 400 minerals = 100 }
		upkeep = { food = 2 }
	}

	upgrades = { building_xenomorph_acid_reactor_spire }
}


# T2 Acid Reactor Spire (NEW)
building_xenomorph_acid_reactor_spire = {
	base_buildtime = @b2_time
	category = resource
	base_cap_amount = 1
	can_build = no
	prerequisites = { tech_xenomorph_acid_reactor_spire }

	building_sets = {
		government
		urban
		industrial
		mining
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		job_xenomorph_acid_processor_gestalt_add = 200
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		job_xenomorph_acid_processor_add = 200
	}

	planet_modifier = {
		planet_jobs_energy_produces_mult = 0.10
	}

	resources = {
		category = planet_buildings
		cost = { food = 700 minerals = 200 exotic_gases = 25 }
		upkeep = { food = 3 xenomorph_offspring = 1 }
	}

	upgrades = { building_xenomorph_apex_acid_conduit }
}


# T3 Apex Acid Conduit (NEW)
building_xenomorph_apex_acid_conduit = {
	base_buildtime = @b3_time
	category = resource
	base_cap_amount = 1
	can_build = no
	prerequisites = { tech_xenomorph_apex_acid_conduit }

	building_sets = {
		government
		urban
		industrial
		mining
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		job_xenomorph_acid_processor_gestalt_add = 400
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		job_xenomorph_acid_processor_add = 400
	}

	planet_modifier = {
		planet_jobs_energy_produces_mult = 0.15
	}

	resources = {
		category = planet_buildings
		cost = { food = 1000 minerals = 300 exotic_gases = 50 rare_crystals = 25 }
		upkeep = { food = 4 xenomorph_offspring = 2 rare_crystals = 1 }
	}
}


#################################################################
# STANDALONE — Biomass Cultivation Pit (basic food, replaces hydroponics)
#################################################################

building_xenomorph_biomass_cultivation_pit = {
	base_buildtime = @b1_time
	category = resource

	building_sets = {
		government
		urban
		farming
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	# Xenomorph Hydroponics Farm replacement.
	planet_modifier = {
		job_agri_drone_add = 200
	}

	resources = {
		category = planet_buildings
		cost = { minerals = 300 }
		upkeep = { energy = 1 }
	}
}

###############################################
# === xenomorph_unity_buildings.txt ===
###############################################
###############################################
# XENOMORPH UNITY BUILDINGS
# Split from xenomorph_buildings_combined.txt.
###############################################

@b1_time = 360
@b2_time = 720
@b3_time = 1080

building_xenomorph_pheromone_node = {
	base_buildtime = @b1_time
	category = unity

	building_sets = {
		government
		urban
		unity
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
	}
	destroy_trigger = {
		exists = owner
		NOT = { any_owned_pop_group = { is_xenomorph = yes } }
	}

	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_pheromone_drone_gestalt_add = 100
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_pheromone_drone_add = 100
		}
	}

	planet_modifier = {
		planet_crime_add = -10
		planet_stability_add = 3
	}

	resources = {
		category = planet_buildings
		cost = { food = 500 energy = 200 }
		upkeep = { energy = 2 }
	}

	upgrades = { building_xenomorph_pheromone_chorus_chamber }
}



building_xenomorph_pheromone_chorus_chamber = {
	base_buildtime = @b2_time
	category = unity
	can_build = no
	prerequisites = { tech_xenomorph_pheromone_chorus_chamber }

	building_sets = {
		government
		urban
		unity
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
	}
	destroy_trigger = {
		exists = owner
		NOT = { any_owned_pop_group = { is_xenomorph = yes } }
	}

	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_pheromone_drone_gestalt_add = 300
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_pheromone_drone_add = 300
		}
	}

	planet_modifier = {
		planet_stability_add = 8
		planet_crime_add = -30
		planet_amenities_add = 800
	}

	resources = {
		category = planet_buildings
		cost = { food = 1000 energy = 400 }
		upkeep = { food = 6 energy = 2 }
	}

	upgrades = { building_xenomorph_hive_devotion_nexus }
}



building_xenomorph_brood_synapse_node = {
	base_buildtime = @b1_time
	category = government

	building_sets = {
		government
		urban
		unity
	}

	potential = {
		exists = owner
		owner = { xeno_is_xenomorph_hive_country = yes }
	}

	destroy_trigger = {
		exists = owner
		NOT = { owner = { xeno_is_xenomorph_hive_country = yes } }
	}

	# Xenomorph Synaptic Node replacement.
	planet_modifier = {
		job_synapse_drone_add = 200
	}

	resources = {
		category = planet_buildings
		cost = { minerals = 400 }
		upkeep = { energy = 2 }
	}
}


building_xenomorph_hive_devotion_nexus = {
	base_buildtime = @b3_time
	category = unity
	can_build = no
	prerequisites = { tech_xenomorph_hive_devotion_nexus }

	building_sets = {
		government
		urban
		unity
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
	}

	possible = {
		OR = {
			has_building = building_xenomorph_matriarch_hive
			has_building = building_xenomorph_brood_queen_hive
			has_building = building_xenomorph_empress_hive
			has_building = building_xenomorph_war_matriarch_hive
			has_building = building_xenomorph_queen_mother_hive
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			NOR = {
				has_building = building_xenomorph_matriarch_hive
				has_building = building_xenomorph_brood_queen_hive
				has_building = building_xenomorph_empress_hive
				has_building = building_xenomorph_war_matriarch_hive
				has_building = building_xenomorph_queen_mother_hive
			}
		}
	}

	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_pheromone_drone_gestalt_add = 500
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_pheromone_drone_add = 500
		}
	}

	planet_modifier = {
		planet_stability_add = 12
		planet_crime_add = -50
		planet_amenities_add = 1200
		planet_jobs_unity_produces_mult = 0.10
	}

	country_modifier = {
		country_unity_produces_mult = 0.05
	}

	resources = {
		category = planet_buildings
		cost = { food = 1600 energy = 600 minerals = 300 }
		upkeep = { food = 10 energy = 4 }
	}
}


building_xenomorph_tribute_pens = {
	base_buildtime = @b1_time
	category = unity

	building_sets = {
		government
		urban
		unity
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
	}
	destroy_trigger = {
		exists = owner
		NOT = { any_owned_pop_group = { is_xenomorph = yes } }
	}

	# T1 tribute: 1 Tribute Overseer + 4 Tribute Thralls
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_tribute_overseer_gestalt_add = 100
			job_xenomorph_tribute_thrall_add = 400
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_tribute_overseer_add = 100
			job_xenomorph_tribute_thrall_add = 400
		}
	}

	planet_modifier = {
		planet_amenities_add = 200
	}

	resources = {
		category = planet_buildings
		cost = { food = 400 minerals = 200 }
		upkeep = { food = 3 }
	}

	upgrades = { building_xenomorph_royal_tribute_warren }
	prerequisites = { "tech_xenomorph_tribute_pens" }
}


building_xenomorph_royal_tribute_warren = {
	base_buildtime = @b2_time
	category = unity
	can_build = no
	prerequisites = { tech_xenomorph_royal_tribute_warren }

	building_sets = {
		government
		urban
		unity
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
	}
	destroy_trigger = {
		exists = owner
		NOT = { any_owned_pop_group = { is_xenomorph = yes } }
	}

	# T2 tribute: 2 Tribute Overseers + 6 Tribute Thralls
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_tribute_overseer_gestalt_add = 200
			job_xenomorph_tribute_thrall_add = 600
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_tribute_overseer_add = 200
			job_xenomorph_tribute_thrall_add = 600
		}
	}

	planet_modifier = {
		planet_amenities_add = 400
		planet_stability_add = 3
		job_xenomorph_tribute_thrall_unity_produces_mult = 0.15
	}

	resources = {
		category = planet_buildings
		cost = { food = 800 minerals = 400 }
		upkeep = { food = 6 }
	}

	upgrades = { building_xenomorph_royal_pens }
}


building_xenomorph_royal_pens = {
	base_buildtime = @b3_time
	category = unity
	can_build = no
	prerequisites = { tech_xenomorph_royal_pens }

	building_sets = {
		government
		urban
		unity
	}

	potential = {
		exists = owner
		any_owned_pop_group = { is_xenomorph = yes }
	}

	possible = {
		OR = {
			has_building = building_xenomorph_matriarch_hive
			has_building = building_xenomorph_brood_queen_hive
			has_building = building_xenomorph_empress_hive
			has_building = building_xenomorph_war_matriarch_hive
			has_building = building_xenomorph_queen_mother_hive
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			NOT = { any_owned_pop_group = { is_xenomorph = yes } }
			NOR = {
				has_building = building_xenomorph_matriarch_hive
				has_building = building_xenomorph_brood_queen_hive
				has_building = building_xenomorph_empress_hive
				has_building = building_xenomorph_war_matriarch_hive
				has_building = building_xenomorph_queen_mother_hive
			}
		}
	}

	# T3 tribute: 1 Royal Tribute Keeper + 3 Tribute Overseers + 8 Tribute Thralls
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = yes } }
		modifier = {
			job_xenomorph_royal_tribute_keeper_gestalt_add = 100
			job_xenomorph_tribute_overseer_gestalt_add = 300
			job_xenomorph_tribute_thrall_add = 800
		}
	}
	triggered_planet_modifier = {
		potential = { owner = { is_gestalt = no } }
		modifier = {
			job_xenomorph_royal_tribute_keeper_add = 100
			job_xenomorph_tribute_overseer_add = 300
			job_xenomorph_tribute_thrall_add = 800
		}
	}

	planet_modifier = {
		planet_amenities_add = 700
		planet_stability_add = 8
		planet_crime_add = -20
		job_xenomorph_tribute_thrall_unity_produces_mult = 0.25
	}

	country_modifier = {
		country_unity_produces_mult = 0.05
	}

	resources = {
		category = planet_buildings
		cost = { food = 1500 minerals = 700 alloys = 100 }
		upkeep = { food = 10 energy = 2 }
	}
}
