namespace = stellar_manip
event = {
	id = stellar_manip.1
	is_triggered_only = yes
	hide_window = yes
	trigger = {
		NOT = {
			has_global_flag = gigas_stellar_manip_exists
		}
	}
	immediate = {
		set_global_flag = gigas_stellar_manip_exists
	}
}

### MEGASTRUTCTURE CONSTRUCTION NOTIFICATIONS
#site
country_event = {
	id = stellar_manip.101
	title = stellar_manip.101.name
	desc = stellar_manip.101.desc
	picture = GFX_star_manip_02_background
	is_triggered_only = yes
	hide_window = no
	show_sound = event_dyson_sphere_build_start
	location = event_target:star_manip_system
	option = {
		#Good, good.
		name = "stellar_manip.101.a"
	}
}

#full
country_event = {
	id = stellar_manip.102
	title = stellar_manip.102.name
	desc = stellar_manip.102.desc
	picture = GFX_star_manip_02_background
	is_triggered_only = yes
	hide_window = no
	show_sound = event_dyson_sphere_build_complete
	location = event_target:star_manip_system
	option = {
		#Good, good.
		name = "stellar_manip.101.a"
	}
}

#harvester
country_event = {
	id = stellar_manip.103
	title = stellar_manip.103.name
	desc = stellar_manip.103.desc
	picture = GFX_star_manip_01_background
	is_triggered_only = yes
	hide_window = no
	show_sound = event_dyson_sphere_build_complete
	location = event_target:star_manip_system
	option = {
		#Good, good.
		name = "stellar_manip.101.a"
	}
}

#injector
country_event = {
	id = stellar_manip.104
	title = stellar_manip.104.name
	desc = stellar_manip.104.desc
	picture = GFX_star_manip_01_background
	is_triggered_only = yes
	hide_window = no
	show_sound = event_dyson_sphere_build_complete
	location = event_target:star_manip_system
	option = {
		#Good, good.
		name = "stellar_manip.101.a"
	}
}

### MONTHLY EVENT, REPLACE INJECTORS IF NO RESOURCE
country_event = {
	id = stellar_manip.100
	title = stellar_manip.100.title
	desc = stellar_manip.100.desc
	picture = GFX_star_manip_03_background
	is_triggered_only = yes
	trigger = {
		any_owned_megastructure = {
			is_megastructure_type = stellar_manipulator_3
		}
		NOT = {
			has_resource = sr_stellar_plasma
		}
	}
	immediate = {
		every_owned_megastructure = {
			limit = {
				is_megastructure_type = stellar_manipulator_3
			}
			this.planet = {
				save_event_target_as = star_manip_planet
			}
			remove_megastructure = this
			solar_system = {
				spawn_megastructure = {
					type = stellar_manipulator_off
					planet = event_target:star_manip_planet
				}
			}
		}
	}
	option = {
		#Good, good.
		name = "stellar_manip.100.a"
	}
}

### MAIN EVENT
#harvester
# planet_event = {
# 	id = stellar_manip.1000
# 	is_triggered_only = yes
# 	hide_window = yes
# 	trigger = {
# 		event_target:star_harvester = {
# 			exists = this
# 		}
# 	}
# 	immediate = {
# 		event_target:star_being_harvested = {
# 			remove_planet_flag = has_megastructure
# 			remove_planet_flag = megastructure
# 			switch = {
# 				trigger = is_planet_class
# 				pc_b_star = { 
# 					change_pc = pc_a_star
# 					solar_system = {
# 						if = {
# 							limit = { giga_is_bitrinary = no }
# 							set_star_class = sc_a
# 						}
# 					}
# 				}
# 				pc_m_giant_star = { 
# 					change_pc = pc_m_star
# 					solar_system = {
# 						if = {
# 							limit = { giga_is_bitrinary = no }
# 							set_star_class = sc_m
# 						}
# 					}
# 				}
# 				pc_a_star = { 
# 					change_pc = pc_f_star
# 					solar_system = {
# 						if = {
# 							limit = { giga_is_bitrinary = no }
# 							set_star_class = sc_f
# 						}
# 					}
# 				}
# 				pc_f_star = { 
# 					change_pc = pc_g_star
# 					solar_system = {
# 						if = {
# 							limit = { giga_is_bitrinary = no }
# 							set_star_class = sc_g
# 						}
# 					}
# 				}
# 				pc_g_star = { 
# 					change_pc = pc_k_star
# 					solar_system = {
# 						if = {
# 							limit = { giga_is_bitrinary = no }
# 							set_star_class = sc_k
# 						}
# 					}
# 				}
# 				pc_k_star = { 
# 					change_pc = pc_m_star
# 					solar_system = {
# 						if = {
# 							limit = { giga_is_bitrinary = no }
# 							set_star_class = sc_m
# 						}
# 					}
# 				}
# 				pc_m_star = { 
# 					change_pc = pc_t_star
# 					solar_system = {
# 						if = {
# 							limit = { giga_is_bitrinary = no }
# 							set_star_class = sc_t
# 						}
# 					}
# 				}
# 				pc_gigaignited_star = { 
# 					change_pc = pc_t_star
# 				}
# 			}
# 			save_event_target_as = star_manip_planet
# 			owner = { country_event = { id = stellar_manip.1001 } }
# 		}
# 		if = { #automatic harvesting
# 			limit = {
# 				event_target:star_harvester = {
# 					owner = {
# 						has_policy_flag = policy_automatic_harvest
# 					}
# 				}
# 			}
# 			if = { #harvested down to class T
# 				limit = { is_planet_class = pc_t_star }
# 				space_owner = {
# 					country_event = { id = stellar_manip.2002 }
# 				}
# 				remove_megastructure = event_target:star_harvester
# 			} else = {
# 				if = { #check for energy
# 					limit = {
# 						space_owner = {
# 							has_resource = { type = energy amount > 5000 }
# 						}
# 					}
# 					space_owner = {
# 						add_resource = {
# 							energy = -5000
# 						}
# 						set_country_flag = auto_harvester
# 					}
# 					remove_megastructure = event_target:star_harvester
# 					solar_system = {
# 						spawn_megastructure = {
# 							type = stellar_manipulator_2
# 							owner = ROOT.space_owner
# 							planet = ROOT
# 						}
# 					}
# 				} else = { #no energy
# 					remove_megastructure = event_target:star_harvester
# 					solar_system = {
# 						save_event_target_as = star_being_harvested
# 						spawn_megastructure = {
# 							type = stellar_harvester_off
# 							owner = ROOT.space_owner
# 							planet = ROOT
# 							init_effect = {
# 								save_event_target_as = star_harvester
# 							}
# 						}
# 					}
# 					space_owner = {
# 						country_event = { id = stellar_manip.2003 }
# 					}
# 				}
# 			}
# 		} else = { #manual harvesting
# 			space_owner = {
# 				country_event = { id = stellar_manip.2001 }
# 			}
# 			remove_megastructure = event_target:star_harvester
# 		}
# 	}
# }
#harvester
planet_event = {
	id = stellar_manip.2000
	is_triggered_only = yes
	hide_window = yes
	trigger = {
		is_scope_valid = yes
	}
	immediate = {
		remove_planet_flag = has_megastructure
		remove_planet_flag = megastructure
		switch = {
			trigger = is_planet_class
			pc_o_star = {
				change_pc = pc_b_star
				remove_modifier = giga_o_star_modifier
				clear_deposits = yes
				solar_system = {
					if = {
						limit = {
							has_star_flag = giga_o_star_system
						}
						set_star_class = sc_b
						every_ambient_object = {
							limit = {
								is_ambient_object_type = giga_o_star_nebula_1
							}
							destroy_ambient_object = this
						}
					}
				}
			}
			pc_giga_o_star = {
				change_pc = pc_b_star
				remove_modifier = giga_o_star_modifier
				clear_deposits = yes
				solar_system = {
					if = {
						limit = {
							has_star_flag = giga_o_star_system
						}
						set_star_class = sc_b
						every_ambient_object = {
							limit = {
								is_ambient_object_type = giga_o_star_nebula_1
							}
							destroy_ambient_object = this
						}
					}
				}
			}
		pc_o_super_star = {
			change_pc = pc_b_star
			remove_modifier = giga_o_star_modifier
			clear_deposits = yes
			solar_system = {
				if = {
					limit = {
						has_star_flag = giga_o_star_system
					}
					set_star_class = sc_b
					every_ambient_object = {
						limit = {
							is_ambient_object_type = giga_o_star_nebula_1
						}
						destroy_ambient_object = this
					}
				}
			}
		}
		pc_o_hyper_star = {
			change_pc = pc_b_star
			remove_modifier = giga_o_star_modifier
			clear_deposits = yes
			solar_system = {
				if = {
					limit = {
						has_star_flag = giga_o_star_system
					}
					set_star_class = sc_b
					every_ambient_object = {
						limit = {
							is_ambient_object_type = giga_o_star_nebula_1
						}
						destroy_ambient_object = this
					}
				}
			}
		}
			pc_b_star = {
				change_pc = pc_a_star
				solar_system = {
					if = {
						limit = {
							giga_is_bitrinary = no
						}
						set_star_class = sc_a
					}
				}
			}
			pc_m_giant_star = {
				change_pc = pc_m_star
				solar_system = {
					if = {
						limit = {
							giga_is_bitrinary = no
						}
						set_star_class = sc_m
					}
				}
			}
			pc_a_star = {
				change_pc = pc_f_star
				solar_system = {
					if = {
						limit = {
							giga_is_bitrinary = no
						}
						set_star_class = sc_f
					}
				}
			}
			pc_f_star = {
				change_pc = pc_g_star
				solar_system = {
					if = {
						limit = {
							giga_is_bitrinary = no
						}
						set_star_class = sc_g
					}
				}
			}
			pc_g_star = {
				change_pc = pc_k_star
				solar_system = {
					if = {
						limit = {
							giga_is_bitrinary = no
						}
						set_star_class = sc_k
					}
				}
			}
			pc_k_star = {
				change_pc = pc_m_star
				solar_system = {
					if = {
						limit = {
							giga_is_bitrinary = no
						}
						set_star_class = sc_m
					}
				}
			}
			pc_m_star = {
				change_pc = pc_t_star
				solar_system = {
					if = {
						limit = {
							giga_is_bitrinary = no
						}
						set_star_class = sc_t
					}
				}
			}
			pc_gigaignited_star = {
				change_pc = pc_t_star
			}
		}
		save_event_target_as = star_manip_planet
		from.owner = {
			stellarm_set_if_not_set = {
				variable = stellarm_star_resource_value
				value = 1
				CHANGE = yes
			}
		}
		if = {
			#automatic harvesting
			limit = {
				from.owner = {
					has_policy_flag = policy_automatic_harvest
					# any_situation = {
					# 	stellarm_is_an_infusion_situation = yes
					# }
				}
			}
			if = {
				#harvested down to class T
				limit = {
					is_planet_class = pc_t_star
				}
				space_owner = {
					country_event = {
						id = stellar_manip.2002
					}
				}
				stellarm_remove_applicable_harvester_mega = yes
				# stellarm_unset_if_set = {
				# 	variable = stellarm_harvester_progress
				# }
				destroy_situation = from
			}
			else = {
				if = {
					#check for energy
					limit = {
						space_owner = {
							has_resource = {
								type = energy
								amount >= 5000
							}
						}
					}
					space_owner = {
						add_resource = {
							energy = -5000
						}
						set_country_flag = auto_harvester
					}
					stellarm_remove_applicable_harvester_mega = yes
					solar_system = {
						spawn_megastructure = {
							type = stellar_manipulator_2
							owner = ROOT.space_owner
							planet = ROOT
						}
					}
					
					# if = {
					# 	limit = {
					# 		space_owner = {
					# 			not = {
					# 				any_situation = {
					# 				is_situation_type = situation_stellar_extraction
					# 				target = {
					# 					is_same_value = root
					# 				}
					# 			}
					# 		}

					# 		}
					# 	}
						from.owner = {
							start_situation = {
								type = situation_stellar_extraction
								target = root
							}
						}
						destroy_situation = from
						# log = "Situation does not exist"
					# }
					# else = {
					# 	log = "Situation still exists"
					# }
					# stellarm_unset_if_set = {
					# 	variable = stellarm_harvester_progress
					# }
				}
				else = {
					#no energy
					stellarm_remove_applicable_harvester_mega = yes
					solar_system = {
						save_event_target_as = star_being_harvested
						set_star_flag = stellarm_tempt_dont_abort
						spawn_megastructure = {
							type = stellar_harvester_off
							owner = ROOT.space_owner
							planet = ROOT
							init_effect = {
								save_event_target_as = star_harvester
							}
						}
						remove_star_flag = stellarm_tempt_dont_abort
					}
					space_owner = {
						country_event = {
							id = stellar_manip.2003
						}
					}
					destroy_situation = from
				}

			}
		}
		else = {
			#manual harvesting
			space_owner = {
				country_event = {
					id = stellar_manip.2001
				}
			}
			stellarm_remove_applicable_harvester_mega = yes
			destroy_situation = from
		}
		
	}
}

# #injector
# planet_event = {
# 	id = stellar_manip.1001
# 	is_triggered_only = yes
# 	hide_window = yes
# 	trigger = {
# 		event_target:star_injector = {
# 			exists = this
# 		}
# 	}
# 	immediate = {
# 		event_target:star_being_injected = {
# 			remove_planet_flag = has_megastructure
# 			remove_planet_flag = megastructure
# 			switch = {
# 				trigger = is_planet_class
# 				pc_b_star = {
# 					solar_system = {
# 						giga_create_o_star = yes
# 					}
# 				}
# 				pc_m_giant_star = {
# 					change_pc = pc_b_star
# 					solar_system = {
# 						if = {
# 							limit = { giga_is_bitrinary = no }
# 							set_star_class = sc_b
# 						}
# 					}
# 				}
# 				pc_a_star = {
# 					change_pc = pc_b_star
# 					solar_system = {
# 						if = {
# 							limit = { giga_is_bitrinary = no }
# 							set_star_class = sc_b
# 						}
# 					}
# 				}
# 				pc_f_star = {
# 					change_pc = pc_a_star
# 					solar_system = {
# 						if = {
# 							limit = { giga_is_bitrinary = no }
# 							set_star_class = sc_a
# 						}
# 					}
# 				}
# 				pc_g_star = {
# 					change_pc = pc_f_star
# 					solar_system = {
# 						if = {
# 							limit = { giga_is_bitrinary = no }
# 							set_star_class = sc_f
# 						}
# 					}
# 				}
# 				pc_k_star = {
# 					change_pc = pc_g_star
# 					solar_system = {
# 						if = {
# 							limit = { giga_is_bitrinary = no }
# 							set_star_class = sc_g
# 						}
# 					}
# 				}
# 				pc_m_star = {
# 					change_pc = pc_k_star
# 					solar_system = {
# 						if = {
# 						limit = { giga_is_bitrinary = no }
# 						set_star_class = sc_k
# 						}
# 					}
# 				}
# 				pc_gigaignited_star = {
# 					change_pc = pc_m_star
# 					solar_system = {
# 						if = {
# 						limit = { giga_is_bitrinary = no }
# 						set_star_class = sc_m
# 						}
# 					}
# 				}
# 			}
# 			save_event_target_as = star_manip_planet
# 			owner = { country_event = { id = stellar_manip.1002 } }
# 		}
# 		if = { #automatic injection
# 			limit = {
# 				event_target:star_injector = {
# 					owner = {
# 						has_policy_flag = policy_automatic_injection
# 					}
# 				}
# 			}
# 			if = { #injected up to class O
# 				limit = { is_planet_class = pc_giga_o_star }
# 				space_owner = {
# 					country_event = { id = stellar_manip.2005 }
# 				}
# 				remove_megastructure = event_target:star_injector
# 			} else = {
# 				if = { #check for energy
# 					limit = {
# 						space_owner = {
# 							has_resource = { type = energy amount > 5000 }
# 						}
# 					}
# 					space_owner = {
# 						add_resource = {
# 							energy = -5000
# 						}
# 						set_country_flag = auto_injector
# 					}
# 					remove_megastructure = event_target:star_injector
# 					solar_system = {
# 						spawn_megastructure = {
# 							type = stellar_manipulator_3
# 							owner = ROOT.space_owner
# 							planet = ROOT
# 						}
# 					}
# 				} else = { #no energy
# 					remove_megastructure = event_target:star_injector
# 					solar_system = {
# 						save_event_target_as = star_being_injected
# 						spawn_megastructure = {
# 							type = stellar_manipulator_off
# 							owner = ROOT.space_owner
# 							planet = ROOT
# 							init_effect = {
# 								save_event_target_as = star_injector
# 							}
# 						}
# 					}
# 					space_owner = {
# 						country_event = { id = stellar_manip.2006 }
# 					}
# 				}
# 			}
# 		} else = { #manual injection
# 			space_owner = {
# 				country_event = { id = stellar_manip.2004 }
# 			}
# 			remove_megastructure = event_target:star_injector
# 		}
# 	}
# }
#injector
planet_event = {
	id = stellar_manip.1999
	is_triggered_only = yes
	hide_window = yes
	trigger = {
		is_scope_valid = yes
	}
	immediate = {
		remove_planet_flag = has_megastructure
		remove_planet_flag = megastructure
		switch = {
			trigger = is_planet_class
			pc_b_star = {
				solar_system = {
					giga_create_o_star = yes
				}
			}
			pc_m_giant_star = {
				change_pc = pc_b_star
				solar_system = {
					if = {
						limit = {
							giga_is_bitrinary = no
						}
						set_star_class = sc_b
					}
				}
			}
			pc_a_star = {
				change_pc = pc_b_star
				solar_system = {
					if = {
						limit = {
							giga_is_bitrinary = no
						}
						set_star_class = sc_b
					}
				}
			}
			pc_f_star = {
				change_pc = pc_a_star
				solar_system = {
					if = {
						limit = {
							giga_is_bitrinary = no
						}
						set_star_class = sc_a
					}
				}
			}
			pc_g_star = {
				change_pc = pc_f_star
				solar_system = {
					if = {
						limit = {
							giga_is_bitrinary = no
						}
						set_star_class = sc_f
					}
				}
			}
			pc_k_star = {
				change_pc = pc_g_star
				solar_system = {
					if = {
						limit = {
							giga_is_bitrinary = no
						}
						set_star_class = sc_g
					}
				}
			}
			pc_m_star = {
				change_pc = pc_k_star
				solar_system = {
					if = {
						limit = {
							giga_is_bitrinary = no
						}
						set_star_class = sc_k
					}
				}
			}
			pc_gigaignited_star = {
				change_pc = pc_m_star
				solar_system = {
					if = {
						limit = {
							giga_is_bitrinary = no
						}
						set_star_class = sc_m
					}
				}
			}
		}
		save_event_target_as = star_manip_planet
		# from.owner = {
		# planet_event = {
		# 	id = stellar_manip.1002
		# }
		# }
		if = {
			#automatic injection
			limit = {
				from.owner = {
					has_policy_flag = policy_automatic_injection
				}
			}
			if = {
				#injected up to class O
				limit = {
					giga_is_o_star_for_megas = yes
				}
				space_owner = {
					country_event = {
						id = stellar_manip.2005
					}
				}
				stellarm_remove_applicable_injecter_mega = yes
			}
			else = {
				if = {
					#check for energy
					limit = {
						space_owner = {
							has_resource = {
								type = energy
								amount > 5000
							}
						}
					}
					space_owner = {
						add_resource = {
							energy = -5000
						}
						set_country_flag = auto_injector
					}
					stellarm_remove_applicable_injecter_mega = yes
					solar_system = {
						spawn_megastructure = {
							type = stellar_manipulator_3
							owner = ROOT.space_owner
							planet = ROOT
						}
					}
					from.owner = {
						start_situation = {
							type = situation_stellar_infusion
							target = root
						}
					}

				}
				else = {
					#no energy
					stellarm_remove_applicable_injecter_mega = yes
					solar_system = {
						save_event_target_as = star_being_injected
						
							set_star_flag = stellarm_tempt_dont_abort
						
						spawn_megastructure = {
							type = stellar_manipulator_off
							owner = ROOT.space_owner
							planet = ROOT
							init_effect = {
								save_event_target_as = star_injector
							}
						}
						
							remove_star_flag = stellarm_tempt_dont_abort
						
					}
					space_owner = {
						country_event = {
							id = stellar_manip.2006
						}
					}
				}
			}
		}
		else = {
			#manual injection
			space_owner = {
				country_event = {
					id = stellar_manip.2004
				}
			}
			stellarm_remove_applicable_injecter_mega = yes
		}
		destroy_situation = from
	}
}

#o harvester
planet_event = {
	id = stellar_manip.1002
	is_triggered_only = yes
	hide_window = yes
	trigger = {
		is_scope_valid = yes
	}
	immediate = {
		remove_planet_flag = has_megastructure
		remove_planet_flag = megastructure
		change_pc = pc_b_star
		remove_modifier = giga_o_star_modifier
		clear_deposits = yes
		solar_system = {
			if = {
				limit = {
					has_star_flag = giga_o_star_system
				}
				set_star_class = sc_b
				every_ambient_object = {
					limit = {
						is_ambient_object_type = giga_o_star_nebula_1
					}
					destroy_ambient_object = this
				}
			}
		}
		save_event_target_as = star_manip_planet
		# from.owner = { country_event = { id = stellar_manip.1999 } }
		if = {
			#automatic harvesting
			limit = {
				from.owner = {
					has_policy_flag = policy_automatic_harvest
				}
			}
			if = {
				#check for energy
				limit = {
					space_owner = {
						has_resource = {
							type = energy
							amount > 5000
						}
					}
				}
				space_owner = {
					add_resource = {
						energy = -5000
					}
					set_country_flag = auto_harvester
				}
				stellarm_remove_applicable_harvester_mega = yes
				solar_system = {
					spawn_megastructure = {
						type = stellar_manipulator_2
						owner = ROOT.space_owner
						planet = ROOT
					}
				}
			}
			else = {
				#no energy
				stellarm_remove_applicable_harvester_mega = yes
				solar_system = {
					save_event_target_as = star_being_harvested
					spawn_megastructure = {
						type = stellar_harvester_off
						owner = ROOT.space_owner
						planet = ROOT
						init_effect = {
							save_event_target_as = star_harvester
						}
					}
				}
				space_owner = {
					country_event = {
						id = stellar_manip.2003
					}
				}
			}
		}
		else = {
			#manual harvesting
			space_owner = {
				country_event = {
					id = stellar_manip.2001
				}
			}
			stellarm_remove_applicable_harvester_mega = yes
		}
	}
}

#harvester finished
country_event = {
	id = stellar_manip.2001
	title = stellar_manip.2001.name
	desc = stellar_manip.2001.desc
	picture = GFX_star_manip_02_background
	is_triggered_only = yes
	hide_window = no
	show_sound = event_dyson_sphere_build_complete
	location = event_target:star_manip_planet
	option = {
		#Good, good.
		name = "stellar_manip.101.a"
		if = {
			limit = {
				event_target:star_manip_planet = {
					is_planet_class = pc_b_star
				}
			}
			add_resource = {
				alloys = @manip_alloy_cost_o_star
			}
		}
		else_if = {
			limit = {
				event_target:star_manip_planet = {
					is_planet_class = pc_a_star
				}
			}
			add_resource = {
				alloys = @manip_alloy_cost_b_star
			}
		}
		else_if = {
			limit = {
				event_target:star_manip_planet = {
					is_planet_class = pc_f_star
				}
			}
			add_resource = {
				alloys = @manip_alloy_cost_a_star
			}
		}
		else_if = {
			limit = {
				event_target:star_manip_planet = {
					is_planet_class = pc_g_star
				}
			}
			add_resource = {
				alloys = @manip_alloy_cost_f_star
			}
		}
		else_if = {
			limit = {
				event_target:star_manip_planet = {
					is_planet_class = pc_k_star
				}
			}
			add_resource = {
				alloys = @manip_alloy_cost_g_star
			}
		}
		else_if = {
			limit = {
				event_target:star_manip_planet = {
					is_planet_class = pc_m_star
				}
			}
			add_resource = {
				alloys = @manip_alloy_cost_k_star
			}
		}
		else_if = {
			limit = {
				event_target:star_manip_planet = {
					is_planet_class = pc_t_star
				}
			}
			add_resource = {
				alloys = @manip_alloy_cost_m_star
			}
		}
	}
}

#harvester fully finished
country_event = {
	id = stellar_manip.2002
	title = stellar_manip.2002.name
	desc = stellar_manip.2002.desc
	picture = GFX_star_manip_02_background
	is_triggered_only = yes
	hide_window = no
	show_sound = event_dyson_sphere_build_complete
	location = event_target:star_manip_planet
	option = {
		#Good, good.
		name = "stellar_manip.101.a"
		add_resource = {
			alloys = 1500
		}
	}
}

#auto harvester no energy
country_event = {
	id = stellar_manip.2003
	title = stellar_manip.2003.name
	desc = stellar_manip.2003.desc
	picture = GFX_star_manip_02_background
	is_triggered_only = yes
	hide_window = no
	show_sound = event_dyson_sphere_build_complete
	location = event_target:star_manip_planet
	option = {
		name = "stellar_manip.2003.a"
	}
}

#injector finished
country_event = {
	id = stellar_manip.2004
	title = stellar_manip.2004.name
	desc = stellar_manip.2004.desc
	picture = GFX_star_manip_02_background
	is_triggered_only = yes
	hide_window = no
	show_sound = event_dyson_sphere_build_complete
	location = event_target:star_manip_planet
	option = {
		#Good, good.
		name = "stellar_manip.101.a"
		if = {
			limit = {
				event_target:star_manip_planet = {
					giga_is_o_star_for_megas = yes
				}
			}
			add_resource = {
				alloys = @manip_alloy_cost_b_star
			}
		}
		else_if = {
			limit = {
				event_target:star_manip_planet = {
					is_planet_class = pc_b_star
				}
			}
			add_resource = {
				alloys = @manip_alloy_cost_a_star
			}
		}
		else_if = {
			limit = {
				event_target:star_manip_planet = {
					is_planet_class = pc_a_star
				}
			}
			add_resource = {
				alloys = @manip_alloy_cost_f_star
			}
		}
		else_if = {
			limit = {
				event_target:star_manip_planet = {
					is_planet_class = pc_f_star
				}
			}
			add_resource = {
				alloys = @manip_alloy_cost_g_star
			}
		}
		else_if = {
			limit = {
				event_target:star_manip_planet = {
					is_planet_class = pc_g_star
				}
			}
			add_resource = {
				alloys = @manip_alloy_cost_k_star
			}
		}
		else_if = {
			limit = {
				event_target:star_manip_planet = {
					is_planet_class = pc_k_star
				}
			}
			add_resource = {
				alloys = @manip_alloy_cost_m_star
			}
		}
		else_if = {
			limit = {
				event_target:star_manip_planet = {
					is_planet_class = pc_m_star
				}
			}
			add_resource = {
				alloys = @manip_alloy_cost_ignited_star
			}
		}
	}
}

#injector fully finished
country_event = {
	id = stellar_manip.2005
	title = stellar_manip.2005.name
	desc = stellar_manip.2005.desc
	picture = GFX_star_manip_02_background
	is_triggered_only = yes
	hide_window = no
	show_sound = event_dyson_sphere_build_complete
	location = event_target:star_manip_planet
	option = {
		#Good, good.
		name = "stellar_manip.101.a"
		add_resource = {
			alloys = 5000
		}
	}
}

#auto injector no energy
country_event = {
	id = stellar_manip.2006
	title = stellar_manip.2006.name
	desc = stellar_manip.2006.desc
	picture = GFX_star_manip_02_background
	is_triggered_only = yes
	hide_window = no
	show_sound = event_dyson_sphere_build_complete
	location = event_target:star_manip_planet
	option = {
		name = "stellar_manip.2003.a"
	}
}

situation_event = {
	id = stellar_manip.8000
	is_triggered_only = yes
	hide_window = yes
	trigger = {
		target = {
			OR = {
				is_variable_set = stellarm_harvester_progress
				is_variable_set = stellarm_injecter_progress
			}
		}
	}
	immediate = {
		add_situation_progress = target.value:stellarm_harvester_progress_initializer
		target = {
			stellarm_unset_if_set = {
				variable = stellarm_harvester_progress
			}
			stellarm_unset_if_set = {
				variable = stellarm_injecter_progress
			}
		}
	}
}

situation_event = {
	id = stellar_manip.8001
	is_triggered_only = yes
	hide_window = yes
	trigger = {
		target = {
			OR = {
				is_variable_set = stellarm_harvester_progress
				is_variable_set = stellarm_injecter_progress
			}
		}
	}
	immediate = {
		add_situation_progress = target.value:stellarm_injecter_progress_initializer
		target = {
			stellarm_unset_if_set = {
				variable = stellarm_harvester_progress
			}
			stellarm_unset_if_set = {
				variable = stellarm_injecter_progress
			}
		}
	}
}

situation_event = {
	id = stellar_manip.9000
	is_triggered_only = yes
	hide_window = yes
	trigger = {
		or = {
			current_situation_approach = approach_stellarm_faster_extraction
			current_situation_approach = approach_stellarm_more_efficient_extraction
			current_situation_approach = approach_stellarm_standard
		}
	}
	immediate = {
		if = {
			limit = {
				current_situation_approach = approach_stellarm_faster_extraction
			}
			target = {
				stellarm_set_if_not_set = {
					variable = stellarm_harvest_yield_multiplier
					value = 0.045
					CHANGE = yes
					change_value = 0.045
				}
			}
		}
		else_if = {
			limit = {
				current_situation_approach = approach_stellarm_more_efficient_extraction
			}
			target = {
				stellarm_set_if_not_set = {
					variable = stellarm_harvest_yield_multiplier
					value = 0.025
					CHANGE = yes
					change_value = 0.025
				}
			}
		}
		else = {
			target = {
				stellarm_set_if_not_set = {
					variable = stellarm_harvest_yield_multiplier
				}
				if = {
					limit = {
						check_variable = {
							which = stellarm_harvest_yield_multiplier
							value > 0
						}
					}
					set_variable = {
						which = stellarm_harvest_yield_multiplier
						value = value:stellarm_harvest_yield_decrement_calculation
					}
				}
				else_if = {
					limit = {
						check_variable = {
							which = stellarm_harvest_yield_multiplier
							value < 0
						}
					}
					set_variable = {
						which = stellarm_harvest_yield_multiplier
						value = value:stellarm_harvest_yield_increment_calculation
					}
				}
			}
		}
	}
}

situation_event = {
	id = stellar_manip.9001
	is_triggered_only = yes
	hide_window = yes
	trigger = {
		or = {
			current_situation_approach = approach_stellarm_faster_infusion
			current_situation_approach = approach_stellarm_more_efficient_infusion
			current_situation_approach = approach_stellarm_standard_infusion
		}
	}
	immediate = {
		if = {
			limit = {
				current_situation_approach = approach_stellarm_faster_infusion
			}
			target = {
				stellarm_set_if_not_set = {
					variable = stellarm_infusion_upkeep_multiplier
					value = 0.05
					CHANGE = yes
					change_value = 0.05
				}
			}
		}
		else_if = {
			limit = {
				current_situation_approach = approach_stellarm_more_efficient_infusion
			}
			target = {
				stellarm_set_if_not_set = {
					variable = stellarm_infusion_upkeep_multiplier
					value = -0.03
					CHANGE = yes
					change_value = -0.03
				}
			}
		}
		else = {
			target = {
				stellarm_set_if_not_set = {
					variable = stellarm_infusion_upkeep_multiplier
				}
				if = {
					limit = {
						check_variable = {
							which = stellarm_infusion_upkeep_multiplier
							value > 0
						}
					}
					set_variable = {
						which = stellarm_infusion_upkeep_multiplier
						value = value:stellarm_infusion_upkeep_decrement_calculation
					}
				}
				else_if = {
					limit = {
						check_variable = {
							which = stellarm_infusion_upkeep_multiplier
							value < 0
						}
					}
					set_variable = {
						which = stellarm_infusion_upkeep_multiplier
						value = value:stellarm_infusion_upkeep_increment_calculation
					}
				}
			}
		}
	}
}

# situation_event = {
# 	id = stellar_manip.9005
# 	is_triggered_only = yes
# 	hide_window = yes
# 	trigger = {
# 	}
# 	immediate = {
# 		if = {
# 			limit = {
# 				current_situation_approach = approach_stellarm_faster_extraction
# 			}
# 			target = {
# 				stellarm_set_if_not_set = {
# 					variable = stellarm_harvest_yield_multiplier
# 					value = 0.005
# 					CHANGE = yes
# 					change_value = 0.005
# 				}
# 			}
# 		}
# 		else_if = {
# 			limit = {
# 				current_situation_approach = approach_stellarm_more_efficient_extraction
# 			}
# 			target = {
# 				stellarm_set_if_not_set = {
# 					variable = stellarm_harvest_yield_multiplier
# 					value = 0.045
# 					CHANGE = yes
# 					change_value = 0.045
# 				}
# 			}
# 		}
# 		else_if = {
# 		limit = {
# 			current_situation_approach = approach_stellarm_standard
# 		}
# 		target = {
# 			stellarm_set_if_not_set = {
# 				variable = stellarm_harvest_yield_multiplier
# 				value = 0.022
# 				CHANGE = yes
# 				change_value = 0.022
# 			}
# 		}
# 		}
# 	}
# }
situation_event = {
	id = stellar_manip.9010
	is_triggered_only = yes
	hide_window = yes
	trigger = {
		current_situation_approach = approach_stellarm_removal
	}
	immediate = {
		abort_situation = this
	}
}
