
orbital_ring_restored = {
	entity = ""
	construction_entity = "orbital_ring_construction_entity"
	portrait = "GFX_megastructure_construction_background"
	place_entity_on_planet_plane = yes
	entity_offset = { x = 0 y = 0 }
	scales_with_planet = yes
	show_galactic_map_icon = no
	show_in_outliner = no
	build_time = 720

	resources = {
		category = megastructures
		cost = {
			influence = 50
		}
		cost = {
			trigger = {
				country_uses_bio_ships = no
			}
			alloys = 500
		}
		cost = {
			trigger = {
				country_uses_bio_ships = yes
			}
			alloys = 500
			mult = 0.5
		}
		cost = {
			trigger = {
				country_uses_bio_ships = yes
			}
			food = 500
			mult = @halved_alloy_to_food_cost_ratio
		}
	}

	upgrade_from = { orbital_ring_ruined }

	construction_blocks_and_blocked_by = none

	possible = {
		from = { has_technology = tech_orbital_ring_tier_1 }
		custom_tooltip = {
			fail_text = "requires_outpost"
			exists = starbase
		}
		custom_tooltip = {
			fail_text = "requires_inside_border"
			is_inside_border = from
		}
		custom_tooltip = {
			fail_text = "requires_no_anomaly"
			any_system_planet = {
				#has_planet_flag = ruined_orbital_ring_planet
				NOT = { has_anomaly = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_colonized_planet_orbital_ring"
			any_system_colony = {
				#has_planet_flag = ruined_orbital_ring_planet
				is_colony = yes
				exists = owner
				exists = controller
				owner = { is_same_value = from }
				controller = { is_same_value = from }
			}
		}
	}

	on_build_start = {}
	on_build_cancel = {}

	on_build_complete = {
		fromfrom.planet = {
			set_planet_flag = has_megastructure
			remove_planet_flag = ruined_orbital_ring_planet
			save_event_target_as = orbital_ring_planet
			if = {
				limit = { has_orbital_station = yes }
				orbital_station = {
					dismantle = yes
				}
			}
			create_starbase = {
				size = orbital_ring_tier_1
				owner = FROM
				#module = <starbase_module>
				#building = <starbase_building>
				effect = {}
			}
		}
		every_system_ambient_object = {
			limit = {
				OR = {
					is_ambient_object_type = medium_debris_01_object
					is_ambient_object_type = medium_debris_02_object
				}
				distance = {
					source = fromfrom
					max_distance <= 100
					same_solar_system = yes
				}
			}
			destroy_ambient_object = this
		}
		remove_megastructure = fromfrom
		from = {
			country_event = { id = tutorial.2121 }
		}
	}
}
