colony_building_specialisation_reset = {
    remove_carrier_flag = researcher_carrier_flag
    remove_carrier_flag = metallurgist_carrier_flag
    remove_carrier_flag = artisan_carrier_flag
    # remove_carrier_flag = bureaucrat_carrier_flag
    remove_carrier_flag = gas_refiner_carrier_flag
    remove_carrier_flag = chemist_carrier_flag
    remove_carrier_flag = translucer_carrier_flag
    remove_carrier_flag = unification_carrier_flag
    remove_carrier_flag = trade_carrier_flag
	remove_carrier_flag = eg_rc_vm_carrier_flag

    remove_modifier = building_notification_research
    remove_modifier = building_notification_alloy
    remove_modifier = building_notification_consumer_goods
    # remove_modifier = building_notification_administrative_cap
    remove_modifier = building_notification_eg_rc_vm
    remove_modifier = building_notification_exotic_gases
    remove_modifier = building_notification_volatile_motes
    remove_modifier = building_notification_rare_crystals
    remove_modifier = building_notification_unity
    remove_modifier = building_notification_trade
}

colony_district_specialisation_reset = {
    remove_carrier_flag = auto_city_carrier_flag
    # remove_carrier_flag = auto_industrial_carrier_flag
    remove_carrier_flag = auto_mining_carrier_flag
    remove_carrier_flag = auto_generator_carrier_flag
    remove_carrier_flag = auto_farming_carrier_flag
    # remove_carrier_flag = auto_amenities_carrier_flag
    remove_carrier_flag = auto_research_d_carrier_flag

    remove_modifier = building_notification_housing
    remove_modifier = building_notification_alloy
    remove_modifier = building_notification_minerals
    remove_modifier = building_notification_energy
    remove_modifier = building_notification_food
    remove_modifier = building_notification_research_d
    # remove_modifier = building_notification_amenities
}

colony_copy_automation_specialisation = {
	switch = {
		trigger = has_carrier_flag

		researcher_carrier_flag = {
			$TO_COLONY$ = {
				set_carrier_flag = researcher_carrier_flag
				add_modifier = {
					modifier = building_notification_research
				}
			}
		}
		metallurgist_carrier_flag = {
			$TO_COLONY$ = {
				set_carrier_flag = metallurgist_carrier_flag
				add_modifier = {
					modifier = building_notification_alloy
				}
			}
		}
		artisan_carrier_flag = {
			$TO_COLONY$ = {
				set_carrier_flag = artisan_carrier_flag
				add_modifier = {
					modifier = building_notification_consumer_goods
				}
			}
		}
		# bureaucrat_carrier_flag = {
		# 	$TO_COLONY$ = {
		# 		set_carrier_flag = bureaucrat_carrier_flag
		# 		add_modifier = {
		# 			modifier = building_notification_administrative_cap
		# 		}
		# 	}
		# }
		gas_refiner_carrier_flag = {
			$TO_COLONY$ = {
				set_carrier_flag = gas_refiner_carrier_flag
				add_modifier = {
					modifier = building_notification_exotic_gases
				}
			}
		}
		chemist_carrier_flag = {
			$TO_COLONY$ = {
				set_carrier_flag = chemist_carrier_flag
				add_modifier = {
					modifier = building_notification_volatile_motes
				}
			}
		}
		translucer_carrier_flag = {
			$TO_COLONY$ = {
				set_carrier_flag = translucer_carrier_flag
				add_modifier = {
					modifier = building_notification_rare_crystals
				}
			}
		}
		unification_carrier_flag = {
			$TO_COLONY$ = {
				set_carrier_flag = unification_carrier_flag
				add_modifier = {
					modifier = building_notification_unity
				}
			}
		}
		trade_carrier_flag = {
			$TO_COLONY$ = {
				set_carrier_flag = trade_carrier_flag
				add_modifier = {
					modifier = building_notification_trade
				}
			}
		}
		eg_rc_vm_carrier_flag = {
			$TO_COLONY$ = {
				set_carrier_flag = eg_rc_vm_carrier_flag
				add_modifier = {
					modifier = building_notification_eg_rc_vm
				}
			}
		}

		switch = {
			trigger = has_carrier_flag

			auto_city_carrier_flag = {
				$TO_COLONY$ = {
					set_carrier_flag = auto_city_carrier_flag
					add_modifier = {
						modifier = building_notification_housing
					}
				}
			}
			# auto_industrial_carrier_flag = {
			# 	$TO_COLONY$ = {
			# 		set_carrier_flag = auto_industrial_carrier_flag
			# 		add_modifier = {
			# 			modifier = building_notification_alloy
			# 		}
			# 	}
			# }
			auto_mining_carrier_flag = {
				$TO_COLONY$ = {
					set_carrier_flag = auto_mining_carrier_flag
					add_modifier = {
						modifier = building_notification_minerals
					}
				}
			}
			auto_generator_carrier_flag = {
				$TO_COLONY$ = {
					set_carrier_flag = auto_generator_carrier_flag
					add_modifier = {
						modifier = building_notification_energy
					}
				}
			}
			auto_farming_carrier_flag = {
				$TO_COLONY$ = {
					set_carrier_flag = auto_farming_carrier_flag
					add_modifier = {
						modifier = building_notification_food
					}
				}
			}
			# auto_amenities_carrier_flag = {
			# 	$TO_COLONY$ = {
			# 		set_carrier_flag = auto_amenities_carrier_flag
			# 		add_modifier = {
			# 			modifier = building_notification_amenities
			# 		}
			# 	}
			# }
			auto_research_d_carrier_flag = {
				$TO_COLONY$ = {
					set_carrier_flag = auto_research_d_carrier_flag
					add_modifier = {
						modifier = building_notification_research_d
					}
				}
			}
		}
	}
}

colony_auto_spec_buildings_check = {
	switch = {
		trigger = has_carrier_flag

		researcher_carrier_flag = {
			if = {
				limit = {
					owner = {
						has_origin = origin_wilderness
					}
				}
				colony_auto_construct = {
					ZONE = zone_research_wilderness
					DISTRICT_TYPE = district_craglands
					DISTRICT_CATEGORY = @category_city
					BUILDING = building_brain_node_1
					MINERALS = @b1_minerals
					BIOMASS = 100
					DAYS = 240
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_hive_mind
					}
				}
				colony_auto_construct = {
					ZONE = zone_research_hive
					DISTRICT_TYPE = district_hive
					DISTRICT_CATEGORY = @category_city
					BUILDING = building_research_lab_1
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_machine_intelligence
					}
				}
				colony_auto_construct = {
					ZONE = zone_research_nexus
					DISTRICT_TYPE = district_nexus
					DISTRICT_CATEGORY = @category_city
					BUILDING = building_research_lab_1
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
			else = {
				colony_auto_construct = {
					ZONE = zone_research
					DISTRICT_TYPE = district_city
					DISTRICT_CATEGORY = @category_city
					BUILDING = building_research_lab_1
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
		}
		unification_carrier_flag = {
			if = {
				limit = {
					owner = {
						has_origin = origin_wilderness
					}
				}
				colony_auto_construct = {
					ZONE = zone_unity_wilderness
					DISTRICT_TYPE = district_craglands
					DISTRICT_CATEGORY = @category_city
					BUILDING = building_commensal_clearing_1
					MINERALS = @b1_minerals
					BIOMASS = 100
					DAYS = 240
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_hive_mind
					}
				}
				colony_auto_construct = {
					ZONE = zone_unity_hive
					DISTRICT_TYPE = district_hive
					DISTRICT_CATEGORY = @category_city
					BUILDING = building_hive_node
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_machine_intelligence
					}
				}
				colony_auto_construct = {
					ZONE = zone_unity_nexus
					DISTRICT_TYPE = district_nexus
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_cultural_heritage
					BUILDING = building_uplink_node
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
			else_if = {
				limit = {
					owner = {
						is_regular_empire = yes
						OR = {
							has_ethic = ethic_spiritualist
							has_ethic = ethic_fanatic_spiritualist
						}
					}
				}
				colony_auto_construct = {
					ZONE = zone_unity
					DISTRICT_TYPE = district_city
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_cultural_heritage
					BUILDING = building_temple
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_corporate
					}
				}
				colony_auto_construct = {
					ZONE = zone_unity
					DISTRICT_TYPE = district_city
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_cultural_heritage
					BUILDING = building_corporate_monument
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
			else = {
				colony_auto_construct = {
					ZONE = zone_unity
					DISTRICT_TYPE = district_city
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_cultural_heritage
					BUILDING = building_autochthon_monument
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
		}
		eg_rc_vm_carrier_flag = {
			if = {
				limit = {
					has_carrier_flag = gas_refiner_carrier_flag
					has_carrier_flag = chemist_carrier_flag
					has_carrier_flag = translucer_carrier_flag
				}
				remove_carrier_flag = gas_refiner_carrier_flag
				if = {
					limit = {
						owner = {
							has_origin = origin_wilderness
						}
					}
					colony_auto_construct = {
						ZONE = zone_foundry_wilderness
						DISTRICT_TYPE = district_craglands
						DISTRICT_CATEGORY = @category_city
						TECH_1 = tech_exotic_gases
						BUILDING = building_churning_stomach
						MINERALS = @b2_minerals
						BIOMASS = 400
						DAYS = 480
					}
				}
				else_if = {
					limit = {
						owner = {
							has_authority = auth_hive_mind
						}
					}
					colony_auto_construct = {
						ZONE = zone_foundry_hive
						DISTRICT_TYPE = district_hive
						DISTRICT_CATEGORY = @category_city
						TECH_1 = tech_exotic_gases
						BUILDING = building_refinery
						MINERALS = @b1_minerals
						DAYS = @b1_time
					}
				}
				else_if = {
					limit = {
						owner = {
							has_authority = auth_machine_intelligence
						}
					}
					colony_auto_construct = {
						ZONE = zone_foundry_nexus
						DISTRICT_TYPE = district_nexus
						DISTRICT_CATEGORY = @category_city
						TECH_1 = tech_exotic_gases
						BUILDING = building_refinery
						MINERALS = @b1_minerals
						DAYS = @b1_time
					}
				}
				else = {
					colony_auto_construct = {
						ZONE = zone_foundry
						DISTRICT_TYPE = district_city
						DISTRICT_CATEGORY = @category_city
						TECH_1 = tech_exotic_gases
						BUILDING = building_refinery
						MINERALS = @b1_minerals
						DAYS = @b1_time
					}
				}
			}
			else_if = {
				limit = {
					has_carrier_flag = chemist_carrier_flag
					has_carrier_flag = translucer_carrier_flag
				}
				remove_carrier_flag = chemist_carrier_flag
				if = {
					limit = {
						owner = {
							has_origin = origin_wilderness
						}
					}
					colony_auto_construct = {
						ZONE = zone_foundry_wilderness
						DISTRICT_TYPE = district_craglands
						DISTRICT_CATEGORY = @category_city
						TECH_1 = tech_volatile_motes
						BUILDING = building_mote_aggravator
						MINERALS = @b2_minerals
						BIOMASS = 400
						DAYS = 480
					}
				}
				else_if = {
					limit = {
						owner = {
							has_authority = auth_hive_mind
						}
					}
					colony_auto_construct = {
						ZONE = zone_foundry_hive
						DISTRICT_TYPE = district_hive
						DISTRICT_CATEGORY = @category_city
						TECH_1 = tech_volatile_motes
						BUILDING = building_chemical_plant
						MINERALS = @b1_minerals
						DAYS = @b1_time
					}
				}
				else_if = {
					limit = {
						owner = {
							has_authority = auth_machine_intelligence
						}
					}
					colony_auto_construct = {
						ZONE = zone_foundry_nexus
						DISTRICT_TYPE = district_nexus
						DISTRICT_CATEGORY = @category_city
						TECH_1 = tech_volatile_motes
						BUILDING = building_chemical_plant
						MINERALS = @b1_minerals
						DAYS = @b1_time
					}
				}
				else = {
					colony_auto_construct = {
						ZONE = zone_foundry
						DISTRICT_TYPE = district_city
						DISTRICT_CATEGORY = @category_city
						TECH_1 = tech_volatile_motes
						BUILDING = building_chemical_plant
						MINERALS = @b1_minerals
						DAYS = @b1_time
					}
				}
			}
			else = {
				remove_carrier_flag = translucer_carrier_flag
				remove_carrier_flag = eg_rc_vm_carrier_flag
				set_carrier_flag = metallurgist_carrier_flag

				if = {
					limit = {
						owner = {
							has_origin = origin_wilderness
						}
					}
					colony_auto_construct = {
						ZONE = zone_foundry_wilderness
						DISTRICT_TYPE = district_craglands
						DISTRICT_CATEGORY = @category_city
						TECH_1 = tech_rare_crystals
						BUILDING = building_crystal_growth
						MINERALS = @b2_minerals
						BIOMASS = 400
						DAYS = 480
					}
				}
				else_if = {
					limit = {
						owner = {
							has_authority = auth_hive_mind
						}
					}
					colony_auto_construct = {
						ZONE = zone_foundry_hive
						DISTRICT_TYPE = district_hive
						DISTRICT_CATEGORY = @category_city
						TECH_1 = tech_rare_crystals
						BUILDING = building_crystal_plant
						MINERALS = @b1_minerals
						DAYS = @b1_time
					}
				}
				else_if = {
					limit = {
						owner = {
							has_authority = auth_machine_intelligence
						}
					}
					colony_auto_construct = {
						ZONE = zone_foundry_nexus
						DISTRICT_TYPE = district_nexus
						DISTRICT_CATEGORY = @category_city
						TECH_1 = tech_rare_crystals
						BUILDING = building_crystal_plant
						MINERALS = @b1_minerals
						DAYS = @b1_time
					}
				}
				else = {
					colony_auto_construct = {
						ZONE = zone_foundry
						DISTRICT_TYPE = district_city
						DISTRICT_CATEGORY = @category_city
						TECH_1 = tech_rare_crystals
						BUILDING = building_crystal_plant
						MINERALS = @b1_minerals
						DAYS = @b1_time
					}
				}
			}
		}
		gas_refiner_carrier_flag = {
			set_carrier_flag = metallurgist_carrier_flag
			remove_carrier_flag = gas_refiner_carrier_flag

			if = {
				limit = {
					owner = {
						has_origin = origin_wilderness
					}
				}
				colony_auto_construct = {
					ZONE = zone_foundry_wilderness
					DISTRICT_TYPE = district_craglands
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_exotic_gases
					BUILDING = building_churning_stomach
					MINERALS = @b2_minerals
					BIOMASS = 400
					DAYS = 480
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_hive_mind
					}
				}
				colony_auto_construct = {
					ZONE = zone_foundry_hive
					DISTRICT_TYPE = district_hive
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_exotic_gases
					BUILDING = building_refinery
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_machine_intelligence
					}
				}
				colony_auto_construct = {
					ZONE = zone_foundry_nexus
					DISTRICT_TYPE = district_nexus
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_exotic_gases
					BUILDING = building_refinery
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
			else = {
				colony_auto_construct = {
					ZONE = zone_foundry
					DISTRICT_TYPE = district_city
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_exotic_gases
					BUILDING = building_refinery
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
		}
		chemist_carrier_flag = {
			set_carrier_flag = metallurgist_carrier_flag
			remove_carrier_flag = chemist_carrier_flag

			if = {
				limit = {
					owner = {
						has_origin = origin_wilderness
					}
				}
				colony_auto_construct = {
					ZONE = zone_foundry_wilderness
					DISTRICT_TYPE = district_craglands
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_volatile_motes
					BUILDING = building_mote_aggravator
					MINERALS = @b2_minerals
					BIOMASS = 400
					DAYS = 480
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_hive_mind
					}
				}
				colony_auto_construct = {
					ZONE = zone_foundry_hive
					DISTRICT_TYPE = district_hive
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_volatile_motes
					BUILDING = building_chemical_plant
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_machine_intelligence
					}
				}
				colony_auto_construct = {
					ZONE = zone_foundry_nexus
					DISTRICT_TYPE = district_nexus
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_volatile_motes
					BUILDING = building_chemical_plant
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
			else = {
				colony_auto_construct = {
					ZONE = zone_foundry
					DISTRICT_TYPE = district_city
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_volatile_motes
					BUILDING = building_chemical_plant
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
		}
		translucer_carrier_flag = {
			set_carrier_flag = metallurgist_carrier_flag
			remove_carrier_flag = translucer_carrier_flag

			if = {
				limit = {
					owner = {
						has_origin = origin_wilderness
					}
				}
				colony_auto_construct = {
					ZONE = zone_foundry_wilderness
					DISTRICT_TYPE = district_craglands
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_rare_crystals
					BUILDING = building_crystal_growth
					MINERALS = @b2_minerals
					BIOMASS = 400
					DAYS = 480
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_hive_mind
					}
				}
				colony_auto_construct = {
					ZONE = zone_foundry_hive
					DISTRICT_TYPE = district_hive
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_rare_crystals
					BUILDING = building_crystal_plant
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_machine_intelligence
					}
				}
				colony_auto_construct = {
					ZONE = zone_foundry_nexus
					DISTRICT_TYPE = district_nexus
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_rare_crystals
					BUILDING = building_crystal_plant
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
			else = {
				colony_auto_construct = {
					ZONE = zone_foundry
					DISTRICT_TYPE = district_city
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_rare_crystals
					BUILDING = building_crystal_plant
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
		}
		trade_carrier_flag = {
			if = {
				limit = {
					owner = {
						has_origin = origin_wilderness
					}
				}
				colony_auto_construct = {
					ZONE = zone_trade_wilderness
					DISTRICT_TYPE = district_craglands
					DISTRICT_CATEGORY = @category_city
					BUILDING = building_tendril_cradle_1
					MINERALS = @b1_minerals
					BIOMASS = 100
					DAYS = 360
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_hive_mind
					}
				}
				colony_auto_construct = {
					ZONE = zone_trade_hive
					DISTRICT_TYPE = district_hive
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_interplanetary_commerce
					BUILDING = building_commercial_zone
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_machine_intelligence
					}
				}
				colony_auto_construct = {
					ZONE = zone_trade_nexus
					DISTRICT_TYPE = district_nexus
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_interplanetary_commerce
					BUILDING = building_commercial_zone
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
			else = {
				colony_auto_construct = {
					ZONE = zone_trade
					DISTRICT_TYPE = district_city
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_interplanetary_commerce
					BUILDING = building_commercial_zone
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
		}
		artisan_carrier_flag = {
			colony_auto_construct = {
				ZONE = zone_factory
				DISTRICT_TYPE = district_city
				DISTRICT_CATEGORY = @category_city
				TECH_1 = tech_basic_industry
				BUILDING = building_factory_1
				MINERALS = @b1_minerals
				DAYS = @b1_time
			}
		}
		metallurgist_carrier_flag = {
			if = {
				limit = {
					owner = {
						has_origin = origin_wilderness
					}
				}
				colony_auto_construct = {
					ZONE = zone_foundry_wilderness
					DISTRICT_TYPE = district_craglands
					DISTRICT_CATEGORY = @category_city
					BUILDING = building_natural_furnace_0
					MINERALS = @b1_minerals
					BIOMASS = 100
					DAYS = 180
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_hive_mind
					}
				}
				colony_auto_construct = {
					ZONE = zone_foundry_hive
					DISTRICT_TYPE = district_hive
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_basic_industry
					BUILDING = building_foundry_1
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_machine_intelligence
					}
				}
				colony_auto_construct = {
					ZONE = zone_foundry_nexus
					DISTRICT_TYPE = district_nexus
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_basic_industry
					BUILDING = building_foundry_1
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
			else = {
				colony_auto_construct = {
					ZONE = zone_foundry
					DISTRICT_TYPE = district_city
					DISTRICT_CATEGORY = @category_city
					TECH_1 = tech_basic_industry
					BUILDING = building_foundry_1
					MINERALS = @b1_minerals
					DAYS = @b1_time
				}
			}
		}
	}
}

colony_auto_spec_districts_check = {
	switch = {
		trigger = has_carrier_flag

		auto_city_carrier_flag = {
			if = {
				limit = {
					owner = {
						has_origin = origin_wilderness
					}
				}
				colony_auto_construct = {
					DISTRICT = district_craglands
					MINERALS = 500
					BIOMASS = 50
					DAYS = 480
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_machine_intelligence
					}
				}
				colony_auto_construct = {
					DISTRICT = district_nexus
					DISTRICT_HAB = district_hab_housing
					MINERALS = 500
					DAYS = 480
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_hive_mind
					}
				}
				colony_auto_construct = {
					DISTRICT = district_hive
					DISTRICT_HAB = district_hab_housing
					MINERALS = 500
					DAYS = 480
				}
			}
			else = {
				colony_auto_construct = {
					DISTRICT = district_city
					DISTRICT_HAB = district_hab_housing
					MINERALS = 500
					DAYS = 480
				}
			}
		}
		auto_generator_carrier_flag = {
			if = {
				limit = {
					owner = {
						has_origin = origin_wilderness
					}
				}
				colony_auto_construct = {
					ZONE = zone_energy_wilderness
					ZONE_TECH = tech_power_hub_1
					DISTRICT_CHECK = yes
					DISTRICT_TYPE = district_photosynthesis_fields
					DISTRICT_CATEGORY = @category_generator
					BUILDING = building_bioelectric_stimulator_1
					MINERALS = @b1_minerals
					BIOMASS = 100
					DAYS = 240
				}

				colony_auto_construct = {
					DISTRICT = district_photosynthesis_fields
					MINERALS = 300
					BIOMASS = 50
					DAYS = 240
				}
			}
			else = {
				colony_auto_construct = {
					ZONE = zone_energy
					ZONE_TECH = tech_power_hub_1
					DISTRICT_CHECK = yes
					DISTRICT_TYPE = district_generator
					DISTRICT_CATEGORY = @category_generator
					BUILDING = building_generator_generic
					MINERALS = @b1_minerals
					DAYS = 240
				}

				colony_auto_construct = {
					DISTRICT = district_generator
					DISTRICT_HAB = district_hab_energy
					MINERALS = 300
					DAYS = 240
				}
			}
		}
		auto_mining_carrier_flag = {
			if = {
				limit = {
					owner = {
						has_origin = origin_wilderness
					}
				}
				colony_auto_construct = {
					ZONE = zone_minerals_wilderness
					ZONE_TECH = tech_mineral_purification_1
					DISTRICT_CHECK = yes
					DISTRICT_TYPE = district_hollow_mountains
					DISTRICT_CATEGORY = @category_mining
					BUILDING = building_churning_tunnels_1
					MINERALS = @b1_minerals
					BIOMASS = 100
					DAYS = 240
				}

				colony_auto_construct = {
					DISTRICT = district_hollow_mountains
					MINERALS = 300
					BIOMASS = 50
					DAYS = 240
				}
			}
			else = {
				colony_auto_construct = {
					ZONE = zone_minerals
					ZONE_TECH = tech_mineral_purification_1
					DISTRICT_CHECK = yes
					DISTRICT_TYPE = district_mining
					DISTRICT_CATEGORY = @category_mining
					BUILDING = building_mine_generic
					MINERALS = @b1_minerals
					DAYS = 240
				}

				colony_auto_construct = {
					DISTRICT = district_mining
					DISTRICT_HAB = district_hab_mining
					MINERALS = 300
					DAYS = 240
				}
			}
		}
		auto_farming_carrier_flag = {
			if = {
				limit = {
					owner = {
						has_origin = origin_wilderness
					}
				}
				colony_auto_construct = {
					ZONE = zone_food_wilderness
					ZONE_TECH = tech_food_processing_1
					DISTRICT_CHECK = yes
					DISTRICT_TYPE = district_orchard_forests
					DISTRICT_CATEGORY = @category_farming
					BUILDING = building_massive_growth_1
					MINERALS = @b1_minerals
					BIOMASS = 100
					DAYS = 240
				}

				colony_auto_construct = {
					DISTRICT = district_orchard_forests
					BIOMASS = 50
					MINERALS = 300
					DAYS = 240
				}
			}
			else = {
				colony_auto_construct = {
					ZONE = zone_food
					ZONE_TECH = tech_food_processing_1
					DISTRICT_TYPE = district_farming
					DISTRICT_CHECK = yes
					DISTRICT_CATEGORY = @category_farming
					BUILDING = building_hydroponics_farm
					MINERALS = @b1_minerals
					DAYS = 240
				}

				colony_auto_construct = {
					DISTRICT = district_farming
					MINERALS = 300
					DAYS = 240
				}
			}
		}
		# auto_industrial_carrier_flag = {
		# 	colony_auto_construct = {
		# 		TECH_1 = tech_basic_industry
		# 		BUILDING = building_foundry_1
		# 		MINERALS = @b1_minerals
		# 		DAYS = @b1_time
		# 	}
		# }
		auto_research_d_carrier_flag = {
			colony_auto_construct = {
				DISTRICT_HAB = district_hab_science
				MINERALS = 400
				DAYS = 240
			}
		}
		# auto_amenities_carrier_flag = {
		# 	colony_auto_construct = {
		# 		DISTRICT_HAB = district_hab_cultural
		# 		MINERALS = 400
		# 		DAYS = 240
		# 	}
		# }
	}
}

colony_auto_construct_reset = {
	set_variable = {
		which = carrier_district_category
		value = 0
	}
	set_variable = {
		which = carrier_current_city_building_count
		value = 1
	}
	set_variable = {
		which = carrier_current_generator_building_count
		value = 0
	}
	set_variable = {
		which = carrier_current_mining_building_count
		value = 0
	}
	set_variable = {
		which = carrier_current_farming_building_count
		value = 0
	}

	add_modifier = {
		modifier = building_notification days = 360
		time_multiplier = value:time_modifier_mult|MODIFIER|planet_building_build_speed_mult|
	}
}

colony_auto_construct = {
	if = {
		limit = {
			NOR = {
				is_variable_set = carrier_district_category
				is_variable_set = carrier_current_city_building_count
				is_variable_set = carrier_current_generator_building_count
				is_variable_set = carrier_current_mining_building_count
				is_variable_set = carrier_current_farming_building_count
			}
		}
		colony_auto_construct_reset = yes
	}

	[[BUILDING]
		set_variable = {
			which = carrier_district_category
			value = $DISTRICT_CATEGORY$
		}
	]

	if = {
		limit = {
			[[!BUILDING]
				always = no
			]
			[[BUILDING]
				free_amenities < 0
				check_variable = {
					which = carrier_district_category
					value = @category_city
				}
				num_buildings = {
					type = $BUILDING$
					value > 3
				}
			]
		}
		[[BUILDING]
			remove_building = $BUILDING$

			if = {
				limit = {
					owner = {
						has_origin = origin_wilderness
					}
				}
				add_building = {
					building = building_avatar_chamber_1
					district = $DISTRICT_TYPE$
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_hive_mind
					}
				}
				add_building = {
					building = building_drone_storage
					district = $DISTRICT_TYPE$
				}
			}
			else_if = {
				limit = {
					owner = {
						has_authority = auth_machine_intelligence
					}
				}
				add_building = {
					building = building_drone_storage
					district = $DISTRICT_TYPE$
				}
			}
			else = {
				add_building = {
					building = building_holo_theatres
					district = $DISTRICT_TYPE$
				}
			}

			add_modifier = {
				modifier = building_notification days = 360
				time_multiplier = value:time_modifier_mult|MODIFIER|planet_building_build_speed_mult|
			}
		]
	}

	if = {
		limit = {
			NOT = {
				has_modifier = building_notification
			}
			[[DISTRICT_CHECK]
				num_districts = {
					type = $DISTRICT_TYPE$
					value > 0
				}
				root = {
					has_technology = $ZONE_TECH$
				}
			]
		}
		if = {
			limit = {
				[[!BUILDING]
					always = no
				]
				[[BUILDING]
					num_zones = {
						type = $ZONE$
						value < 1
					}
				]
				root = {
					resource_stockpile_compare = {
						resource = minerals
						value >= 1000
						mult = value:positive_modifier_mult|MODIFIER|planet_structures_cost_mult|
					}
				}
			}
			if = {
				limit = {
					[[DISTRICT_CHECK]
						always = yes
					]
					[[!DISTRICT_CHECK]
						always = no
					]
				}
				add_zone = {
					district = $DISTRICT_TYPE$
					zone = $ZONE$
					replace = yes
				}
			}
			else_if = {
				limit = {
					[[BUILDING]
						always = yes
					]
					[[!BUILDING]
						always = no
					]
				}
				add_zone = {
					district = $DISTRICT_TYPE$
					zone_slot = 1
					zone = $ZONE$
					replace = yes
				}
			}
			add_modifier = {
				modifier = building_notification days = 360
				time_multiplier = value:time_modifier_mult|MODIFIER|planet_building_build_speed_mult|
			}
			root = {
				add_resource = {
					minerals = 1000
					mult = value:negative_modifier_mult|MODIFIER|planet_structures_cost_mult|
				}
			}
		}
		else_if = {
			limit = {
				[[!BUILDING]
					always = no
				]
				[[DISTRICT_CHECK]
					always = no
				]
				has_upgraded_capital = yes
				[[BUILDING]
					num_zones = {
						type = $ZONE$
						value < 2
					}
				]
				root = {
					resource_stockpile_compare = {
						resource = minerals
						value >= 1000
						mult = value:positive_modifier_mult|MODIFIER|planet_structures_cost_mult|
					}
				}
			}
			[[BUILDING]
				add_zone = {
					district = $DISTRICT_TYPE$
					zone_slot = 2
					zone = $ZONE$
					replace = yes
				}
			]
			add_modifier = {
				modifier = building_notification days = 360
				time_multiplier = value:time_modifier_mult|MODIFIER|planet_building_build_speed_mult|
			}
			root = {
				add_resource = {
					minerals = 1000
					mult = value:negative_modifier_mult|MODIFIER|planet_structures_cost_mult|
				}
			}
		}

		if = {
			limit = {
				NOT = {
					has_modifier = building_notification
				}
				[[BUILDING]
					has_building_construction = no
					if = {
						limit = {
							check_variable = {
								which = carrier_district_category
								value = @category_city
							}
						}
						check_variable = {
							which = carrier_current_city_building_count
							value < @max_city_building_slots
						}
					}
					else_if = {
						limit = {
							check_variable = {
								which = carrier_district_category
								value = @category_generator
							}
						}
						check_variable = {
							which = carrier_current_generator_building_count
							value < @max_generator_building_slots
						}
					}
					else_if = {
						limit = {
							check_variable = {
								which = carrier_district_category
								value = @category_mining
							}
						}
						check_variable = {
							which = carrier_current_mining_building_count
							value < @max_mining_building_slots
						}
					}
					else = {
						check_variable = {
							which = carrier_current_farming_building_count
							value < @max_farming_building_slots
						}
					}
				]
				[[DISTRICT]
					if = {
						limit = {
							NOT = {
								is_planet_class = pc_habitat
							}
						}
						num_free_districts = {
							type = $DISTRICT$
							value > 0
						}
					}
				]
				[[DISTRICT_HAB]
					if = {
						limit = {
							is_planet_class = pc_habitat
						}
						num_free_districts = {
							type = $DISTRICT_HAB$
							value > 0
						}
					}
				]
				[[UPGRADED_CAPITAL]
					has_upgraded_capital = $UPGRADED_CAPITAL$
				]
				[[UPGRADED_MAJOR_CAPITAL]
					has_major_upgraded_capital = $UPGRADED_MAJOR_CAPITAL$
				]
				root = {
					[[TECH_1]
						has_technology = $TECH_1$
					]
					[[MINERALS]
						resource_stockpile_compare = {
							resource = minerals
							value >= $MINERALS$
							mult = value:positive_modifier_mult|MODIFIER|planet_structures_cost_mult|
						}
					]
					[[ENERGY]
						resource_stockpile_compare = {
							resource = energy
							value >= $ENERGY$
							mult = value:positive_modifier_mult|MODIFIER|planet_structures_cost_mult|
						}
					]
					[[EXOTIC_GASES]
						resource_stockpile_compare = {
							resource = exotic_gases
							value >= $EXOTIC_GASES$
							mult = value:positive_modifier_mult|MODIFIER|planet_structures_cost_mult|
						}
					]
					[[RARE_CRYSTALS]
						resource_stockpile_compare = {
							resource = rare_crystals
							value >= $RARE_CRYSTALS$
							mult = value:positive_modifier_mult|MODIFIER|planet_structures_cost_mult|
						}
					]
					[[VOLATILE_MOTES]
						resource_stockpile_compare = {
							resource = volatile_motes
							value >= $VOLATILE_MOTES$
							mult = value:positive_modifier_mult|MODIFIER|planet_structures_cost_mult|
						}
					]
					[[BIOMASS]
						resource_stockpile_compare = {
							resource = biomass
							value >= $BIOMASS$
							mult = value:positive_modifier_mult|MODIFIER|planet_structures_cost_mult|
						}
					]
				}
			}

			add_modifier = {
				modifier = building_notification days = $DAYS$
				time_multiplier = value:time_modifier_mult|MODIFIER|carrier_building_build_speed_mult|
			}
			
			[[BUILDING]
				add_building = {
					building = $BUILDING$
					district = $DISTRICT_TYPE$
				}
				
				if = {
					limit = {
						check_variable = {
							which = carrier_district_category
							value = @category_city
						}
					}
					add_variable = {
						which = carrier_current_city_building_count
						value = 1
					}
				}
				else_if = {
					limit = {
						check_variable = {
							which = carrier_district_category
							value = @category_generator
						}
					}
					add_variable = {
						which = carrier_current_generator_building_count
						value = 1
					}
				}
				else_if = {
					limit = {
						check_variable = {
							which = carrier_district_category
							value = @category_mining
						}
					}
					add_variable = {
						which = carrier_current_mining_building_count
						value = 1
					}
				}
				else = {
					add_variable = {
						which = carrier_current_farming_building_count
						value = 1
					}
				}
			]
			[[DISTRICT]
				if = {
					limit = {
						NOT = {
							is_planet_class = pc_habitat
						}
					}
					add_district = $DISTRICT$
				}
			]
			[[DISTRICT_HAB]
				if = {
					limit = {
						is_planet_class = pc_habitat
					}
					add_district = $DISTRICT_HAB$
				}
			]

			root = {
				[[MINERALS]
					add_resource = {
						minerals = $MINERALS$
						mult = value:negative_modifier_mult|MODIFIER|planet_structures_cost_mult|
					}
				]
				[[ENERGY]
					add_resource = {
						energy = $ENERGY$
						mult = value:negative_modifier_mult|MODIFIER|planet_structures_cost_mult|
					}
				]
				[[EXOTIC_GASES]
					add_resource = {
						exotic_gases = $EXOTIC_GASES$
						mult = value:negative_modifier_mult|MODIFIER|planet_structures_cost_mult|
					}
				]
				[[RARE_CRYSTALS]
					add_resource = {
						rare_crystals = $RARE_CRYSTALS$
						mult = value:negative_modifier_mult|MODIFIER|planet_structures_cost_mult|
					}
				]
				[[VOLATILE_MOTES]
					add_resource = {
						volatile_motes = $VOLATILE_MOTES$
						mult = value:negative_modifier_mult|MODIFIER|planet_structures_cost_mult|
					}
				]
				[[BIOMASS]
					add_resource = {
						biomass = $BIOMASS$
						mult = value:negative_modifier_mult|MODIFIER|planet_structures_cost_mult|
					}
				]
			}
			break = yes
		}
	}
}