deep_shroud_summoning_threshold_0 = {
	entity = "construction_platform_entity"
	construction_entity = "construction_platform_entity"
	portrait = GFX_megastructure_construction_background
	place_entity_on_planet_plane = no
	prerequisites = {
		tech_sm_summon_gateway
	}
	show_prereqs = yes
	prereq_name = tech_sm_summon_gateway

	build_time = 3600
	resources = {
		category = megastructures
		cost = {
			alloys = 750000
			sr_dark_matter = 50000
			acot_sr_dark_energy = 50000
			influence = 500
		}
		upkeep = { energy = 5 }
	}

	potential = {
		has_technology = tech_sm_summon_gateway
	}
	possible = {
		exists = starbase
		custom_tooltip = {
			fail_text = "requires_inside_border"
			is_inside_border = from
		}
		custom_tooltip = {
			fail_text = "requires_no_existing_dsst"
			from = { NOT = { has_country_flag = built_dsst } }
		}
		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
		}

		custom_tooltip = {
			fail_text = "sm_dsst_requires_no_colonized_planets"
			NOT = {
				any_system_planet = {
					is_colony = 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 }
			}
		}
	}
	ai_weight = {
		weight = 0
	}
	on_build_complete = {
		from = {
			country_event = {
				id = shroud_master.21
			}
		}
		fromfrom = {
			save_event_target_as = sm_dsst
		}
		save_event_target_as = dsst_system
		set_star_flag = sm_dsst_explosion_source
		from = { set_country_flag = built_dsst }
		fromfrom.planet = {
			if = {
				limit = { has_orbital_station = yes }
				orbital_station = {
					dismantle = yes
				}
			}
		}
	}
}

deep_shroud_summoning_threshold_1 = {
	entity = "deep_shroud_dsst_phase_01_entity"
	construction_entity = "deep_shroud_dsst_phase_01_entity"
	portrait = "GFX_evt_sm_dsst_megaplans_background"
	build_time = 14400
	resources = {
		category = megastructures
		cost = {
			alloys = 1500000
			sr_dark_matter = 10000
			acot_sr_dark_energy = 10000
			influence = 500
		}
		upkeep = {
			physics_research = 1000
			society_research = 1000
			engineering_research = 1000
			sr_dark_matter = 50
			acot_sr_dark_energy = 50
			influence = 1
		}
	}

	upgrade_from = {
		deep_shroud_summoning_threshold_0
	}

	prerequisites = { "tech_sm_summon_gateway" }

	on_build_complete = {
		every_system_planet = {
			if = {
				limit = { is_star = no }
				remove_planet = yes
			}
			else = {
				change_pc = pc_sm_empty_space
				save_global_event_target_as = theta_dsst_star
			}
		}
		from = {
			country_event = {
				id = shroud_master.22
			}
		}
	}
}

deep_shroud_summoning_threshold_2 = {
	entity = "deep_shroud_dsst_part_02_entity"
	construction_entity = "deep_shroud_dsst_phase_02_entity"
	portrait = "GFX_evt_sm_dsst_megaplans_background"
	build_time = 7200
	resources = {
		category = megastructures
		cost = {
			alloys = 1500000
			sr_dark_matter = 10000
			acot_sr_dark_energy = 10000
			influence = 500
		}
		upkeep = {
			physics_research = 2500
			society_research = 2500
			engineering_research = 2500
			sr_dark_matter = 100
			acot_sr_dark_energy = 100
			influence = 2
		}
	}

	upgrade_from = {
		deep_shroud_summoning_threshold_1
	}

	prerequisites = { "tech_sm_summon_gateway" }

	on_build_complete = {
		from = {
			country_event = {
				id = shroud_master.23
			}
		}
	}
}

deep_shroud_summoning_threshold_3 = {
	entity = "deep_shroud_dsst_part_03_entity"
	construction_entity = "deep_shroud_dsst_phase_03_entity"
	portrait = "GFX_evt_sm_dsst_megaplans_background"
	build_time = 3600
	resources = {
		category = megastructures
		cost = {
			alloys = 1500000
			sr_dark_matter = 10000
			acot_sr_dark_energy = 10000
			influence = 500
		}
		upkeep = {
			physics_research = 5000
			society_research = 5000
			engineering_research = 5000
			sr_dark_matter = 250
			acot_sr_dark_energy = 250
			influence = 3
		}
	}

	upgrade_from = {
		deep_shroud_summoning_threshold_2
	}

	prerequisites = { "tech_sm_summon_gateway" }

	on_build_complete = {
		from = {
			country_event = {
				id = shroud_master.24
			}
		}
	}
}

deep_shroud_summoning_threshold_4 = {
	entity = "deep_shroud_dsst_part_04_entity"
	construction_entity = "deep_shroud_dsst_phase_04_entity"
	portrait = "GFX_evt_sm_dsst_megaplans_background"
	build_time = 1800
	resources = {
		category = megastructures
		cost = {
			alloys = 1500000
			sr_dark_matter = 10000
			acot_sr_dark_energy = 10000
			influence = 500
		}
		upkeep = {
			physics_research = 10000
			society_research = 10000
			engineering_research = 10000
			sr_dark_matter = 1000
			acot_sr_dark_energy = 1000
			influence = 4
		}
	}

	upgrade_from = {
		deep_shroud_summoning_threshold_3
	}

	prerequisites = { "tech_sm_summon_gateway" }

	on_build_complete = {
		from = {
			country_event = {
				id = shroud_master.25
			}
		}
	}
}

deep_shroud_summoning_threshold_5 = {
	entity = "deep_shroud_dsst_part_05_entity"
	portrait = "GFX_evt_sm_dsst_megacomplete_background"
	build_time = 30
	resources = {
		category = megastructures
		cost = {
			energy = 2000000
			unity = 1000000
			influence = 1000
		}
		produces = {
			trigger = {
				exists = owner
				owner = {
					has_technology = tech_dark_matter_power_core_theta
				}
			}
			sm_sr_perfect_runic_energy = 20
		}
		upkeep = {
			sr_dark_matter = 2500
			acot_sr_dark_energy = 2500
			influence = 5
		}
	}

	upgrade_from = {
		deep_shroud_summoning_threshold_4
	}

	prerequisites = { "tech_sm_summon_gateway" }

	on_build_complete = {
		from = {
			country_event = {
				id = shroud_master.26
			}
		}
	}
}