@hab_cost = 150
@hab_maintenance = 2
@low_hab_maintenance = 0.25
@hab_time = 360

# NOTE: district_hab_energy_max_add, district_hab_mining_max_add and district_hab_science_max_add
# are provided by habitat_modifiers on orbital deposits
# These modifiers are equal to 1 + FLOOR(n/2), where n is the deposit size.

district_hab_housing = {
	base_buildtime = @hab_time

	exempt_from_ai_planet_specialization = yes
	overlay_icon = GFX_district_government

	zone_slots = {
		slot_city_government
		slot_habitat_01
		slot_habitat_02
	}

	show_on_uncolonized = {
		uses_district_set = habitat
	}

	potential = {
		uses_district_set = habitat
		NAND = {
			is_capital = yes
			owner = {
				has_menace_perk = menp_behemoth_mind_meld
			}
		}
	}

	convert_to = {
		district_mindlink
		district_ark_city
	}

	resources = {
		category = planet_districts_hab
		cost = {
			alloys = @hab_cost
		}
		upkeep = {
			energy = @hab_maintenance
			alloys = @low_hab_maintenance
		}
	}

	planet_modifier = {
		planet_housing_add = 1000
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_active_tradition = tr_prosperity_void_works }
		}
		modifier = {
			planet_housing_add = 100
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = {
				is_tankbound_empire = yes
			}
		}
		modifier = {
			job_production_overseer_add = 100
		}
		mult = owner.value:hab_void_dweller_jobs
	}

	inline_script = {
		script = districts/ai_urban_district_extra_weighting
	}
	
	#### plentiful traditions
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_tradition = tr_plentiful_kleptocracy_finish }
			owner = { is_hive_empire = yes }
		}
		modifier = {
			planet_housing_add = 100
			job_technician_drone_add = 100
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_tradition = tr_plentiful_kleptocracy_finish }
			owner = { is_machine_empire = yes }
		}
		modifier = {
			planet_housing_add = 100
			job_technician_drone_add = 100
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_tradition = tr_plentiful_kleptocracy_finish }
			owner = { 
				is_gestalt = no
				is_fallen_empire_spiritualist = no
			}
		}
		modifier = {
			planet_housing_add = 100
			job_technician_add = 100
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_tradition = tr_plentiful_kleptocracy_finish }
			owner = { is_fallen_empire_spiritualist = yes }
		}
		modifier = {
			planet_housing_add = 100
			job_fe_acolyte_generator_add = 100
		}
	}
#### plentiful traditions

#### plentiful traditions
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_tradition = tr_plentiful_affinity_finish }
			owner = { is_hive_empire = yes }
		}
		modifier = {
			planet_housing_add = 100
			job_alloy_drone_add = 100
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_tradition = tr_plentiful_affinity_finish }
			owner = { is_machine_empire = yes }
			owner = { country_uses_consumer_goods = no }
		}
		modifier = {
			planet_housing_add = 100
			job_fabricator_add = 100
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_tradition = tr_plentiful_affinity_finish }
			owner = { is_machine_empire = yes }
			owner = { country_uses_consumer_goods = yes }
		}
		modifier = {
			planet_housing_add = 100
			job_artisan_drone_add = 100
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_tradition = tr_plentiful_affinity_finish }
			owner = { is_regular_empire = yes }
		}
		modifier = {
			planet_housing_add = 100
			job_artisan_add = 100
		}
	}
#### plentiful traditions

#### plentiful traditions
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_tradition = tr_plentiful_industry_3 }
			owner = { is_hive_empire = yes }
		}
		modifier = {
			planet_housing_add = 100
			job_alloy_drone_add = 100
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_tradition = tr_plentiful_industry_3 }
			owner = { is_machine_empire = yes }
		}
		modifier = {
			planet_housing_add = 100
			job_fabricator_add = 100
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_tradition = tr_plentiful_industry_3 }
			owner = { is_regular_empire = yes }
		}
		modifier = {
			planet_housing_add = 100
			job_foundry_add = 100
		}
	}
#### plentiful traditions
}

district_hab_energy = {
	base_buildtime = @hab_time
	is_uncapped = {	always = no }
	overlay_icon = GFX_district_energy
	shared_capacity_modifier = district_hab_energy

	zone_slots = {
		slot_habitat_energy
	}

	show_on_uncolonized = {
		uses_district_set = habitat
	}

	potential = {
		uses_district_set = habitat
	}

	convert_to = {
		district_ark_generator
	}

	planet_modifier = {
		planet_housing_add = 300
	}

	resources = {
		category = planet_districts_hab_energy
		cost = {
			alloys = @hab_cost
		}
		upkeep = {
			energy = @hab_maintenance
			alloys = @low_hab_maintenance
		}
	}

	planet_modifier = {
		planet_housing_add = 300
	}

	inline_script = {
		script = jobs/habitat_technicians_add
		AMOUNT = @habitat_rural_district_jobs
	}

	on_built = {
		carrier_event = {
			id = megastructures.200		# Spawn an energy orbital
		}
	}

	inline_script = {
		script = districts/district_triggered_name_generator
	}

	prerequisites = {
		tech_power_plant_1
	}

	show_tech_unlock_if = {
		is_nomadic = no
		is_wilderness_empire = no
	}
}

district_hab_mining = {
	base_buildtime = @hab_time
	is_uncapped = {	always = no }
	overlay_icon = GFX_district_minerals
	shared_capacity_modifier = district_hab_mining

	zone_slots = {
		slot_habitat_minerals
	}

	show_on_uncolonized = {
		uses_district_set = habitat
	}

	convert_to = {
		district_ark_military
		district_ark_forever_cruise
	}

	potential = {
		uses_district_set = habitat
	}

	resources = {
		category = planet_districts_hab_mining
		cost = {
			alloys = @hab_cost
		}
		upkeep = {
			energy = @hab_maintenance
			alloys = @low_hab_maintenance
		}
	}

	planet_modifier = {
		planet_housing_add = 300
	}

	inline_script = {
		script = jobs/habitat_miners_add
		AMOUNT = @habitat_rural_district_jobs
	}

	on_built = {
		carrier_event = {
			id = megastructures.210		# Spawn a mining orbital
		}
	}

	inline_script = {
		script = districts/district_triggered_name_mining
	}

	prerequisites = {
		tech_mechanized_mining
	}

	show_tech_unlock_if = {
		is_nomadic = no
		is_wilderness_empire = no
	}
	
#### plentiful traditions
	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_tradition = tr_plentiful_industry_3 }
			owner = { is_hive_empire = yes }
		}
		modifier = {
			planet_housing_add = 100
			job_mining_drone_add = 100
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_tradition = tr_plentiful_industry_3 }
			owner = { is_machine_empire = yes }
		}
		modifier = {
			planet_housing_add = 100
			job_mining_drone_add = 100
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_tradition = tr_plentiful_industry_3 }
			owner = { 
				is_gestalt = no
				is_fallen_empire_spiritualist = no
			}
		}
		modifier = {
			planet_housing_add = 100
			job_miner_add = 100
		}
	}

	triggered_planet_modifier = {
		potential = {
			exists = owner
			owner = { has_tradition = tr_plentiful_industry_3 }
			owner = { is_fallen_empire_spiritualist = yes }
		}
		modifier = {
			planet_housing_add = 100
			job_fe_acolyte_mine_add = 100
		}
	}
#### plentiful traditions
}

district_hab_science = {
	base_buildtime = @hab_time
	is_uncapped = {	always = no }
	overlay_icon = GFX_district_research
	shared_capacity_modifier = district_hab_science

	zone_slots = {
		slot_habitat_research
	}

	show_on_uncolonized = {
		uses_district_set = habitat
	}

	potential = {
		uses_district_set = habitat
	}

	prerequisites = {
		tech_basic_science_lab_1
	}

	show_tech_unlock_if = {
		is_nomadic = no
		is_wilderness_empire = no
	}

	allow = {
		hidden_trigger = {
			OR = {
				NOT = { exists = owner }
				owner = {
					has_technology = tech_basic_science_lab_1
				}
				has_deposit = d_payback_habitat_research
			}
		}
	}

	resources = {
		category = planet_districts_hab
		cost = {
			alloys = @hab_cost
		}
		upkeep = {
			energy = @hab_maintenance
			alloys = @low_hab_maintenance
		}
	}

	planet_modifier = {
		planet_housing_add = 300
	}

	inline_script = {
		script = jobs/habitat_researchers_add
		AMOUNT = @habitat_research_district_jobs
	}

	on_built = {
		carrier_event = {
			id = megastructures.220		# Spawn a research orbital
		}
	}

	triggered_name = {
		text = city_research_1
	}
}
