elec_artificial_quasar_0 = {
	entity = "construction_platform_entity"
	construction_entity = "construction_platform_entity"
	portrait = "GFX_megastructure_construction_background"
	place_entity_on_planet_plane = no
	entity_offset = { x = -7 y = -7 }
	build_time = 1800
	resources = {
		category = megastructures
		cost = {
			alloys = 5000
			unity = 1000
		}
		upkeep = { energy = 5 }
	}
	prerequisites = { "tech_elec_quasar" }
	potential = {
		NOR = {
			is_ai = yes
			has_country_flag = built_elec_artificial_quasar
		}
	}
	possible = {
		exists = starbase
		custom_tooltip = {
			fail_text = "requires_inside_border"
			is_inside_border = from
		}
		custom_tooltip = {
			fail_text = "requires_surveyed_system"
			NOT = {
				any_system_planet = {
					is_surveyed = {
						who = prev.from
						status = no
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_no_black_hole_neutron_star_pulsar"
			NOT = {
				is_star_class = sc_black_hole
				is_star_class = sc_neutron_star
				is_star_class = sc_pulsar
			}
		}
		custom_tooltip = {
			fail_text = "requires_no_binary_trinary"
			NOR = {
				is_star_class = sc_binary_1
				is_star_class = sc_binary_2
				is_star_class = sc_binary_3
				is_star_class = sc_binary_4
				is_star_class = sc_binary_5
				is_star_class = sc_binary_6
				is_star_class = sc_binary_7
				is_star_class = sc_binary_8
				is_star_class = sc_binary_9
				is_star_class = sc_binary_10
				is_star_class = sc_trinary_1
				is_star_class = sc_trinary_2
				is_star_class = sc_trinary_3
				is_star_class = sc_trinary_4
			}
		}
		custom_tooltip = {
			fail_text = "requires_no_existing_megastructure"
			#NOT = { has_any_megastructure = yes }
			has_no_non_gate_megastructure = yes
		}
	}
	placement_rules = {
		planet_possible = {
			custom_tooltip = {
				fail_text = "must_build_around_star"
				is_star = yes
			}
			custom_tooltip = {
				fail_text = "requires_no_anomaly"
				NOT = { has_anomaly = yes }
			}
		}
	}
	on_build_start = {}
	on_build_cancel = {}
	on_build_complete = {
		fromfrom.planet = {
			set_planet_flag = megastructure
			set_planet_flag = has_megastructure
		}
		remove_system_terraforming_candidates = yes
		from = { set_country_flag = built_elec_artificial_quasar }
		fromfrom.planet = {
			if = {
				limit = { has_orbital_station = yes }
				orbital_station = { dismantle = yes }
			}
		}
	}
	show_in_outliner = no
	show_prereqs = yes
}

elec_artificial_quasar_1 = {
	entity = "dyson_sphere_frame_entity"
	construction_entity = "dyson_sphere_frame_entity"
	portrait = "GFX_megastructure_elec_artificial_quasar_bg"
	build_time = 1800
	resources = {
		category = megastructures
		cost = {
			alloys = 10000
			unity = 2500
		}
		upkeep = { energy = 25 }
	}
	upgrade_from = { elec_artificial_quasar_0 }
	show_in_outliner = no
	show_prereqs = no
}

elec_artificial_quasar_2 = {
	entity = "dyson_sphere_frame_entity"
	construction_entity = ""
	portrait = "GFX_megastructure_elec_artificial_quasar_bg"
	build_time = 1800
	resources = {
		category = megastructures
		cost = {
			alloys = 10000
			unity = 5000
		}
		upkeep = { energy = 25 }
	}
	upgrade_from = { elec_artificial_quasar_1 }
	show_in_outliner = no
	show_prereqs = no
}

elec_artificial_quasar_3 = {
	entity = "elec_artificial_quasar_01_entity"
	construction_entity = "elec_artificial_quasar_01_entity"
	portrait = "GFX_megastructure_elec_artificial_quasar_bg"
	build_time = 1800
	resources = {
		category = megastructures
		cost = {
			alloys = 10000
			unity = 5000
		}
	}
	upgrade_from = { elec_artificial_quasar_2 }
	on_build_complete = {
		fromfrom.planet = { set_planet_flag = elec_artificial_quasar_star }
		set_star_flag = elec_artificial_quasar_star
		from = {
			set_country_flag = has_built_or_repaired_megastructure
			country_event = { id = elec.30 }
		}
		spawn_planet = {
			class = "pc_elec_artificial_quasar"
			location = fromfrom.planet
			orbit_location = yes
			orbit_angle_offset = 0
			orbit_distance_offset = 0
			size = 50
			has_ring = no
			init_effect = {
				set_name = "Artificial Quasar"
				set_surveyed = {
					surveyed = yes
					surveyor = FROM
				}
				set_all_comms_surveyed = yes
				clear_blockers = yes
				set_planet_flag = megastructure
				set_planet_flag = elec_aurora_pc_blackhole # For tech & unity job district.
				set_planet_flag = elec_artificial_quasar_star
				set_planet_flag = elec_artificial_quasar
			}
		}
		fromfrom.planet = {
			set_planet_flag = megastructure
			set_planet_flag = has_megastructure
			set_planet_size = 5 # So the entity always fits.
			create_ambient_object = {
				type = "star_explosion"
				play_animation_once = yes
				location = this
			}
			last_created_ambient_object = { set_location = { target = prev distance = 0 angle = random } }
		}
		remove_megastructure = fromfrom
	}
	show_in_outliner = no
	show_prereqs = no
}