###############################################
# XENOMORPH VANILLA HIVE BUILDING OVERRIDES
# Pass 34: Hides vanilla hive buildings from Xenomorph empires' build menu.
#
# These are full overrides of the vanilla definitions with one change:
# the blocker trigger
#   xeno_vanilla_building_not_available_to_xenomorph_hive
# is added to each potential block. This makes the vanilla building
# unavailable to Xenomorph empires (which have their own equivalents),
# while remaining fully functional for normal hive empires.
#
# Mechanism mirrors how vanilla restricts buildings by authority
# (is_hive_empire / is_machine_empire / is_regular_empire in potential).
###############################################

# Hidden for Xeno empires. Replaced by: building_xenomorph_royal_jelly_pods (Offspring Nest, growth).
building_spawning_pool = {
	base_buildtime = @b1_time
	planet_limit = 1

	category = pop_assembly

	building_sets = {
		government
		urban
	}

	potential = {
		xeno_vanilla_building_not_available_to_xenomorph_hive = yes
		exists = owner
		owner = {
			is_hive_empire = yes
			is_wilderness_empire = no
			NOT = { has_origin = origin_progenitor_hive }
		}
	}

	destroy_trigger = {
		exists = owner
		owner = {
			OR = {
				is_hive_empire = no
				has_origin = origin_progenitor_hive
			}
		}
	}

	inline_script = {
		script = jobs/spawning_drone_add
		AMOUNT = @building_static_jobs_low
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				has_technology = tech_gene_tailoring
			}
			any_owned_pop_group = {
				has_auto_modding_trait = yes
			}
		}
		modifier = {
			auto_mod_monthly_add = 200
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				game_start_auto_mod_empire = yes
			}
			any_owned_pop_group = {
				has_auto_modding_trait = yes
			}
		}
		modifier = {
			auto_mod_monthly_add = 200
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_active_tradition = tr_cybernetics_synaptic_sub_processing }
		}
		modifier = {
			job_augmentor_drone_add = 200
		}
	}

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

	convert_to = {
		building_offspring_nest
	}

	triggered_desc = {
		text = spawning_pool_tooltip
	}
}

# Hidden for Xeno empires. Replaced by: building_xenomorph_royal_jelly_pods (Offspring Nest, growth).
building_offspring_nest = {
	base_buildtime = @b1_time
	planet_limit = 1

	category = pop_assembly

	building_sets = {
		government
		urban
	}

	potential = {
		xeno_vanilla_building_not_available_to_xenomorph_hive = yes
		exists = owner
		owner = {
			has_origin = origin_progenitor_hive
		}

	allow = {
		NOT = {
			fleet.starbase? = {
				has_starbase_building = arkship_offspring_outlook
			}
		}
	}
	}

	destroy_trigger = {
		OR = {
			owner? = {
				NOT = { has_origin = origin_progenitor_hive }
			}
			fleet.starbase? = {
				has_starbase_building = arkship_offspring_outlook
			}
		}
	}

	#ruined_trigger = {
	#	has_planet_flag = offspring_defeated
	#}

	inline_script = {
		script = jobs/spawning_drone_add
		AMOUNT = @building_static_jobs_low
	}

	convert_to = {
		building_spawning_pool
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_active_tradition = tr_cybernetics_synaptic_sub_processing }
		}
		modifier = {
			job_augmentor_drone_add = 200
		}
	}

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

	triggered_desc = {
		text = offspring_nest_tooltip
	}
}

# Hidden for Xeno empires. Replaced by: building_xenomorph_resin_spire (amenity/housing).
building_hive_warren = {
	base_buildtime = @b1_time

	category = amenity

	building_sets = {
		government
		urban
	}

	potential = {
		xeno_vanilla_building_not_available_to_xenomorph_hive = yes
		exists = owner
		owner = {
			is_hive_empire = yes
			is_wilderness_empire = no
		}
		OR = {
			has_carrier_flag = ignore_ai_building_limitations
			owner = { is_ai = no }
			free_amenities < @amenity_ai_limit
			days_passed = 0 #To avoid errors at game start
		}
	}

	destroy_trigger = {
		exists = owner
		owner = { is_hive_empire = no }
	}

	convert_to = {
		building_luxury_residence
		building_drone_storage
		building_communal_housing
	}

	planet_modifier = {
		planet_housing_add = 1500
		planet_amenities_no_happiness_add = 1500
	}

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

	upgrades = {
		"building_expanded_warren"
	}

	ai_weight_coefficient = 1.25
}

# Hidden for Xeno empires. Replaced by: building_xenomorph_queens_nest_1 (Queen Nest, capital).
building_hive_capital = {
	capital = yes
	can_build = no
	can_demolish = no
	can_be_ruined = no
	can_be_disabled = no
	position_priority = 0
	capital_tier = 2

	category = government

	building_sets = {
		government
	}

	potential = {
		xeno_vanilla_building_not_available_to_xenomorph_hive = yes
		exists = owner
		owner = {
			OR = {
				is_hive_empire = yes
				is_country_type = swarm
			}
			is_fallen_empire = no
			is_wilderness_empire = no
		}
		uses_habitat_capitals = no
		NOT = { is_planet_class = pc_cosmogenesis_world }
	}

	destroy_trigger = { # destroys and/or triggers conversion if true
		exists = owner
		owner = {
			OR = {
				is_hive_empire = no
				is_wilderness_empire = yes
			}
		}
	}

	convert_to = {
		building_machine_capital
		building_capital
		building_ancient_control_center
		building_ancient_palace
		building_capital_wilderness
	}

	upgrades = {
		"building_hive_major_capital"
	}

	prerequisites = {
		"tech_planetary_government"
	}

	show_tech_unlock_if = {
		is_hive_empire = yes
		is_wilderness_empire = no
	}

	planet_modifier = {
		planet_housing_add = 1000
		planet_amenities_add = 800
		job_logistics_drone_add = 200
		job_coordinator_add = 200
		job_patrol_drone_add = 100
		planet_defense_armies_add = @tier_2_capital_defense_armies
	}

	inline_script = {
		script = buildings/on_all_capital_buildings
	}

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = alloys
			COST = 1000
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		upkeep = {
			energy = 2
		}
	}
}

# Hidden for Xeno empires. Replaced by: building_xenomorph_planetary_hive (Queen Nest upgrade, capital).
building_hive_major_capital = {
	base_buildtime = @b2_time
	capital = yes
	can_build = no
	can_demolish = no
	can_be_ruined = no
	can_be_disabled = no
	position_priority = 0
	capital_tier = 3

	category = government

	building_sets = {
		government
	}

	potential = {
		xeno_vanilla_building_not_available_to_xenomorph_hive = yes
		exists = owner
		owner = {
			OR = {
				is_hive_empire = yes
				is_country_type = swarm
			}
			is_fallen_empire = no
			is_wilderness_empire = no
		}
	}

	convert_to = {
		building_machine_major_capital
		building_major_capital
		building_ancient_control_center
		building_ancient_palace
		building_major_capital_wilderness
	}

	upgrades = {
		"building_imperial_hive_capital"
	}

	allow = {
		sapient_pop_amount >= 2500
	}

	prerequisites = {
		"tech_colonial_centralization"
	}

	show_tech_unlock_if = {
		is_hive_empire = yes
		is_wilderness_empire = no
	}

	planet_modifier = {
		planet_housing_add = 2000
		planet_amenities_add = 2000
		job_coordinator_add = 300
		job_logistics_drone_add = 500
		job_patrol_drone_add = 200
		planet_defense_armies_add = @tier_3_capital_defense_armies
	}

	inline_script = {
		script = buildings/on_all_capital_buildings
	}

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

	additional_ai_weight = 100
}

# Hidden for Xeno empires. Replaced by Xeno unity buildings (Pheromone Node, Brood Synapse Node).
building_hive_cluster = {
	base_buildtime = @b2_time
	planet_limit = 1
	exempt_from_ai_planet_specialization = no

	category = unity

	building_sets = {
		unity
	}

	potential = {
		xeno_vanilla_building_not_available_to_xenomorph_hive = yes
		exists = owner
		owner = {
			is_hive_empire = yes
			is_wilderness_empire = no
		}
	}
	allow = {
		has_upgraded_capital = yes
	}
	destroy_trigger = {
		exists = owner
		owner = {
			OR = {
				is_hive_empire = no
				is_wilderness_empire = yes
			}
		}
	}
	convert_to = {
		building_bureaucratic_2
		building_holotemple
		building_commensal_clearing_3
		building_network_junction
	}

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

	planet_modifier = {}

	triggered_planet_modifier = {
		potential = {
			exists = owner
		}
		job_coordinator_add = @b2_jobs
	}

	planet_modifier = {
		planet_bureaucrats_upkeep_mult = -0.10
	}

	prerequisites = {
		"tech_hive_cluster"
	}
}

# Hidden for Xeno empires. Replaced by Xeno unity buildings (Brood Synapse Node, Tribute Pens).
building_hive_node = {
	base_buildtime = @b1_time

	exempt_from_ai_planet_specialization = no

	category = unity

	building_sets = {
		unity
	}

	potential = {
		xeno_vanilla_building_not_available_to_xenomorph_hive = yes
		exists = owner
		owner = {
			is_hive_empire = yes
			is_wilderness_empire = no
		}
		OR = {
			has_carrier_flag = ignore_ai_building_limitations
			owner = { is_ai = no }
			# AI is allowed to build up to two of these.
			num_buildings = { type = building_hive_node value < 2 }
		}
	}
	destroy_trigger = {
		exists = owner
		owner = {
			OR = {
				is_hive_empire = no
				is_wilderness_empire = yes
			}
		}
	}
	convert_to = {
		building_bureaucratic_1
		building_temple
		building_uplink_node
		building_commensal_clearing_1
	}

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

	ai_weight_coefficient = @static_jobs_ai_weight_coefficient

	resources = {
		category = planet_buildings
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = rare_crystals
			COST = @b1_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		upkeep = {
			energy = @b1_upkeep
		}
		upkeep = {
			trigger = {
				exists = owner
				owner = {
					has_edict = synaptic_reinforcement
				}
			}
			energy = 2
		}
	}

	prerequisites = {
		"tech_hive_node"
	}
}

# Hidden for Xeno empires. Replaced by Xeno unity buildings.
building_hive_confluence = {
	base_buildtime = @b3_time
	planet_limit = 1
	category = unity

	building_sets = {
		unity
	}

	potential = {
		xeno_vanilla_building_not_available_to_xenomorph_hive = yes
		exists = owner
		owner = {
			is_hive_empire = yes
			is_wilderness_empire = no
		}
	}
	allow = {
		has_major_upgraded_capital = yes
	}
	destroy_trigger = {
		exists = owner
		owner = {
			OR = {
				is_hive_empire = no
				is_wilderness_empire = yes
			}
		}
	}
	convert_to = {
		building_bureaucratic_3
		building_sacred_nexus
		building_commensal_clearing_4
		building_system_conflux
	}

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

	planet_modifier = {}

	planet_modifier = {
		pop_coordinator_bonus_workforce_mult = 0.10

	}

	prerequisites = {
		"tech_hive_confluence"
	}
	show_tech_unlock_if = {
		is_wilderness_empire = no
	}
}


# Carapace Bastion: offer Drone's Nest as a researched upgrade (vanilla stronghold + xeno upgrade)
building_stronghold = {
	base_buildtime = 240
	position_priority = 100
	can_be_ruined = no
	exempt_from_ai_planet_specialization = no

	category = army

	building_sets = {
		government
		fortress
	}

	potential = {
		exists = owner
		NOT = { has_modifier = resort_colony }
		owner = { is_wilderness_empire = no } # see 'building_planetary_carapace'
	}
	
	allow = {
		exists = owner
		OR = {
			has_carrier_flag = ignore_ai_building_limitations
			owner = {
				is_ai = no
			}

			# AI is allowed to build up to two of these unless they have a fortress zone. (This can result in three under certain upgrade sequences.)
			has_any_fortress_zone = yes
			AND = {
				num_buildings = { type = building_stronghold value < 2 }
				num_buildings = { type = building_fortress value < 2 }
			}
		}
	}

	resources = {
		category = planet_buildings_strongholds
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b1_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		upkeep = {
			energy = 1
		}
	}

	prerequisites = {
		"tech_planetary_defenses"
	}
	show_tech_unlock_if = {
		is_wilderness_empire = no
	}

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

	upgrades = {
		building_fortress
		building_xenomorph_drones_nest
	}
}


###############################################
# Pass 36: Hide vanilla fortress + research labs from Xenomorph hive empires.
# Hive empires already have equivalents (caste garrison buildings add
# defense armies; the mod's own tiered research buildings add calculator_biologist
# jobs). These are 1:1 copies of the vanilla v4.3 definitions with ONLY the
# xeno_vanilla_building_not_available_to_xenomorph_hive blocker added to potential,
# so non-hive behaviour is identical to vanilla.
###############################################

building_fortress = {
	base_buildtime = @b1_time
	can_build = no
	planetary_ftl_inhibitor = yes
	position_priority = 100
	can_be_ruined = no
	category = army

	building_sets = {
		government
		fortress
	}

	potential = {
		xeno_vanilla_building_not_available_to_xenomorph_hive = yes
		exists = owner
		owner = { is_wilderness_empire = no } # see 'building_planetary_carapace_2'
	}
	allow = {
		has_upgraded_capital = yes
	}

	resources = {
		category = planet_buildings_strongholds
		inline_script = {
			script = buildings/nomadic_cost_switcher
			REGULAR_RESOURCE = minerals
			NOMADIC_RESOURCE = volatile_motes
			COST = @b2_minerals
			NOMADIC_COST_MULT = @nomadic_minerals_to_strategic_ratio
		}
		cost = {
			volatile_motes = @b2_rare_cost
		}
		upkeep = {
			energy = 1
			volatile_motes = @b2_rare_upkeep
		}
	}

	prerequisites = {
		"tech_global_defense_grid"
	}
	show_tech_unlock_if = {
		is_wilderness_empire = no
	}

	inline_script = {
		script = jobs/soldiers_add
		AMOUNT = @building_static_jobs_high
	}
}

building_research_lab_1 = {
	can_build = yes
	base_buildtime = @b1_time
	exempt_from_ai_planet_specialization = no

	category = research

	building_sets = {
		research
	}

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

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

			# AI is allowed to build one of these.
			AND = {
				has_any_research_zone = yes
				NOR = {
					has_building = building_research_lab_1
					has_building = building_research_lab_2
					has_building = building_research_lab_3
				}
			}

			# Nomadic AI is allowed to build up to 3 of these total across all tiers.
			AND = {
				owner = { is_nomadic = yes }
				tiered_building_below_cap = {
					BUILDING = research_lab
				}
			}
		}
	}

	allow = {
	}

	ai_weight_coefficient = @static_jobs_ai_weight_coefficient

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

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

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

	prerequisites = {
		"tech_basic_science_lab_1"
	}

	upgrades = {
		"building_research_lab_2"
	}
}

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

	building_sets = {
		research
	}

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

	allow = {
	}

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

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

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

	prerequisites = {
		"tech_basic_science_lab_2"
	}

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

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

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

	allow = {
	}

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

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

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

	prerequisites = {
		"tech_basic_science_lab_3"
	}

	show_tech_unlock_if = {
		is_wilderness_empire = no
	}
}

# === OVERRIDE: vanilla Logistics Hub suppressed for Xenomorph hives (replaced by building_xenomorph_resin_conduit_nexus) ===
building_maintenance_depot = {
	base_buildtime = 240

	category = trade

	building_sets = {
		urban
		trade
	}

	potential = {
		xeno_vanilla_building_not_available_to_xenomorph_hive = yes
		exists = owner
		owner = { is_gestalt = yes }
		owner = { is_wilderness_empire = no }
		OR = {
			has_carrier_flag = ignore_ai_building_limitations
			owner = { is_ai = no }
			has_any_trade_zone = yes
			NOT = { has_building = building_maintenance_depot }
		}
	}

	destroy_trigger = {
		exists = owner
		OR = {
			owner = { is_gestalt = no }
			owner = { is_wilderness_empire = yes }
		}
	}

	convert_to = {
		building_commercial_zone
	}

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

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

# === OVERRIDE: Lustful Void Masturbation Node suppressed for Xenomorph hives (replaced by building_xenomorph_self_seeding_brood_hive) ===
building_lv_masturbation_node = {
	base_buildtime = @b1_time

	category = trade

	building_sets = {
		lv_sex_set
	}

	potential = {
		xeno_vanilla_building_not_available_to_xenomorph_hive = yes
		exists = owner
		owner = {
			is_regular_empire = no
			OR = {
				NOT = { has_authority = auth_machine_intelligence }
				has_civic = civic_machine_assimilator
				has_civic = civic_machine_servitor
			}
		}
	}

	destroy_trigger = {
		exists = owner
		owner = {
			OR = {
				AND = {
					has_authority = auth_machine_intelligence
					NOR = {
						has_civic = civic_machine_assimilator
						has_civic = civic_machine_servitor
					}
				}
				is_regular_empire = yes
			}
		}
	}

	resources = {
		category = planet_buildings
		cost = {
			minerals = @b1_minerals
		}
		upkeep = {
			energy = @b1_upkeep
		}
	}

	upgrades = {
		building_lv_masturbation_network
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				is_hive_empire = yes
				NOT = { has_ascension_perk = ap_mind_over_matter }
			}
		}
		modifier = {
			job_lv_pleasure_drone_add = 100
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				is_hive_empire = yes
				has_ascension_perk = ap_mind_over_matter
			}
		}
		modifier = {
			job_lv_pleasure_drone_add = 50
			job_lv_psi_pleasure_drone_add = 50
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { is_machine_empire = yes }
		}
		modifier = {
			job_lv_sexbot_drone_add = 100
		}
	}

	triggered_desc = {
		trigger = {
			exists = owner
			owner = {
				is_hive_empire = yes
				NOT = { has_ascension_perk = ap_mind_over_matter }
			}
		}
		text = job_lv_pleasure_drone_effect_desc
	}

	triggered_desc = {
		trigger = {
			exists = owner
			owner = {
				is_hive_empire = yes
				has_ascension_perk = ap_mind_over_matter
			}
		}
		text = job_lv_psi_pleasure_drone_effect_desc
	}

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

# Hidden for Xeno empires. Replaced by: building_xenomorph_brood_nurturing_hollow (Nurture Zones, amenities).
building_lv_nurture_zone = {
	base_buildtime = @b1_time
	category = amenity
	building_sets = {
		lv_city_set
		urban
	}
	potential = {
		exists = owner
		owner = { is_gestalt = yes }
		xeno_vanilla_building_not_available_to_xenomorph_hive = yes
	}
	destroy_trigger = {
		exists = owner
		OR = {
			AND = {
				free_building_slots = 0
				free_jobs < 100
				free_housing > 1000
				owner = { is_ai = yes }
			}
			NOR = { owner = { is_gestalt = yes } }
		}
	}
	convert_to = {
		building_lv_comfort_zone
	}
	resources = {
		category = planet_buildings
		cost = { minerals = @b1_minerals }
		upkeep = { energy = @b1_upkeep }
	}
	inline_script = {
		script = jobs/lv_comfort_worker_add
		AMOUNT = @building_static_jobs
	}
	upgrades = {
		building_lv_nurture_megaplex
	}
}
