##########################################################################
# Machine Age Planet Decisions
##########################################################################

decision_rebuild_genesis_preserve = {
	important = yes
	owned_planets_only = yes
	sound = event_administrative_work
	icon = decision_animal_wildlife
	enactment_time = 900

	resources = {
		category = decisions
		cost = {
			minerals = 1000
			unity = 250
		}
	}

	potential = {
		exists = owner
		owner = {
			is_guided_sapience_empire = yes
		}
		NOR = {
			has_deposit = d_genesis_preserve
			has_deposit = d_genesis_monument
		}
		NOT = { has_designation = col_nanotech_world }
	}

	allow = {
		free_district_slots > 1
	}

	effect = {
		if = {
			limit = {
				any_owned_species = {
					has_genesis_preserve_trait = yes
				}
			}
			custom_tooltip = d_genesis_preserve_old_species_tooltip
			hidden_effect = {
				add_deposit = d_genesis_preserve
			}
		}
		else_if = {
			custom_tooltip = d_genesis_preserve_new_speices_tooltip
			hidden_effect = {
				add_deposit = d_genesis_preserve
				owner = {
					change_variable = {
						which = presapients_guided
						value = 1
					}
				}
				spawn_presapient_species_randomizer_homeworld_effect = yes
				set_planet_flag = pre_sapient_planet
			}
		}
	}

	ai_weight = {
		weight = 10
	}
}
### Virtual Server Reduction
#decision_reduce_server_load = {
#	owned_planets_only = yes
#	sound = event_administrative_work
#	icon = decision_animal_wildlife
#	enactment_time = 30
#
#	resources = {
#		category = decisions
#		cost = {
#			unity = 100
#		}
#	}
#
#	potential = {
#		exists = owner
#		owner = {
#			has_tradition = tr_virtuality_finish
#		}
#	}
#
#	allow = {
#		custom_tooltip = {
#			text = decision_reduce_server_load_allow
#			any_owned_pop_group = {
#				is_unemployed = yes
#				has_virtual_species_trait = yes
#			}
#		}
#	}
#
#	effect = {
#		custom_tooltip = decision_reduce_server_load_effect
#		hidden_effect = {
#			every_owned_pop_group = {
#				limit = {
#					is_unemployed = yes
#					is_robotic_species = yes
#					has_virtual_species_trait = yes
#				}
#				kill_all_pop = yes
#			}
#		}
#	}
#
#	ai_weight = {
#		weight = 1
#		modifier = {
#			factor = 100
#			any_owned_pop_group = {
#				is_robotic_species = yes
#				is_unemployed = yes
#			}
#		}
#	}
#}

### turn off the lights
decision_server_shut_down = {
	owned_planets_only = yes
	sound = event_administrative_work
	icon = decision_glitchy_matrix
	enactment_time = 30

	resources = {
		category = decisions
		cost = {
			unity = 200
		}
	}

	potential = {
		exists = owner
		owner = {
			has_tradition = tr_virtuality_finish
		}
	}

	allow = {
		is_capital = no
	}

	effect = {
		destroy_colony = yes
	}

	ai_weight = {
		weight = 0
	}
}

### Nanotech Slushify Planet
decision_nanotech_swarm_consume_world = {
	icon = decision_tidal_lock_planet
	sound = event_structural_collapse
	important = yes
	#enactment_time = 360
	resources = {
		category = decisions
	}
	owned_planets_only = yes

	potential = {
		exists = owner
		owner = {
			has_tradition = tr_nanotech_3
		}
		can_have_habitable_deposits = yes
		is_capital = no
		NOT = {
			has_planet_flag = being_devoured
		}
		NOT = { has_designation = col_nanotech_world }
	}

	effect = {
		custom_tooltip = decision_nanotech_swarm_consume_world_effect_desc
		set_timed_planet_flag = {
			days = 360
			flag = recently_eaten_planet
		}
		hidden_effect = {
			set_carrier_flag = colony_event
			set_planet_flag = being_devoured
			add_modifier = {
				modifier = being_devoured_modifier_nanotech
				days = -1
			}
			export_trigger_value_to_variable = {
				trigger = planet_size
				variable = num_districts_terravore
			}
			export_trigger_value_to_variable = {
				trigger = count_deposits
				parameters = {
					type = d_nanotech_devastation
				}
				variable = num_lithoid_blockers
			}
			if = {
				limit = {
					is_variable_set = num_lithoid_blockers
				}
				subtract_variable = {
					which = num_districts_terravore
					value = num_lithoid_blockers
				}
			}
		}
		owner = {
			start_situation = {
				type = situation_nanotech_consume_planet
				target = root
			}
		}
	}

	ai_weight = {
		weight = 5

		# don't wreck worlds you want to keep
		modifier = {
			factor = 0
			is_lithoid_devouring_swarm_consumption_world = no
		}
	}
}
