stz_black_hole_siphon_stage_0 = {
	entity = "construction_platform_entity"
	construction_entity = "construction_platform_entity"
	portrait = "GFX_megastructure_construction_background"
	place_entity_on_planet_plane = no
	entity_offset = { x = -20 y = -20 }
	rotate_to_center = no
	scale_offset = yes
	build_time = 1800
	resources = {
		category = megastructures
		cost = {
			alloys = 1000
			stz_sr_caerulenite = 100
		}

		upkeep = {
			energy = 5
		}
	}

	possible = {
		hidden_trigger = {
			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
					}
				}
			}
		}
	}

	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 }
			}
			custom_tooltip = {
				fail_text = "requires_no_existing_megastructure"
				NOR = {
					has_planet_flag = megastructure
					has_planet_flag = has_megastructure
				}
			}
			is_planet_class = pc_black_hole
		}
	}

	# root = system
	# from = country
	ai_weight = {
		factor = 15

		modifier = {
			factor = 0.1
			starbase = { NOT = { has_starbase_size >= starbase_starfortress } }
		}

		modifier = {
			factor = 0.1
			any_neighbor_system = {
				exists = owner
				NOT = {
					owner = { is_same_value = from }
				}
			}
		}
	}

	prerequisites = {
		"stz_tech_black_hole_siphon"
	}

	on_build_start = {}
	on_build_cancel = {}
	on_build_complete = {
		fromfrom.planet = {
			set_planet_flag = has_megastructure
			if = {
				limit = { has_orbital_station = yes }
				orbital_station = {
					dismantle = yes
				}
			}
		}
	}
}

stz_black_hole_siphon_stage_1 = {
	entity = "stz_black_hole_siphon_stage_1"
	construction_entity = "stz_black_hole_siphon_stage_1"
	portrait = "GFX_megastructure_construction_background"
	scales_with_planet = yes
	entity_offset = { x = 0 y = 0 }
	place_entity_on_planet_plane = yes
	build_time = 1800
	resources = {
		category = megastructures
		cost = {
			alloys = 15000
			sr_dark_matter = 5000
			stz_sr_caerulenite = 2500
		}

		produces = {
			sr_dark_matter = 500
			stz_sr_caerulenite = 250
		}

		upkeep = {
			energy = 250
			minerals = 250
			rare_crystals = 50
		}
	}

	upgrade_from = {
		stz_black_hole_siphon_stage_0
	}

	prerequisites = {
		"stz_tech_black_hole_siphon"
	}
	
	on_build_complete = {}
}

stz_black_hole_siphon_stage_2 = {
	entity = "stz_black_hole_siphon_stage_2"
	construction_entity = "stz_black_hole_siphon_stage_2"
	portrait = "GFX_megastructure_construction_background"
	scales_with_planet = yes
	entity_offset = { x = 0 y = 0 }
	place_entity_on_planet_plane = yes
	build_time = 1800
	resources = {
		category = megastructures
		cost = {
			alloys = 15000
			sr_dark_matter = 10000
			stz_sr_caerulenite = 5000
		}

		produces = {
			sr_dark_matter = 1000
			stz_sr_caerulenite = 500
		}

		upkeep = {
			energy = 500
			minerals = 500
			rare_crystals = 50
		}
	}

	prerequisites = {
		"stz_tech_black_hole_siphon"
	}

	upgrade_from = {
		stz_black_hole_siphon_stage_1
	}
}

stz_black_hole_siphon_stage_3 = {
	entity = "stz_black_hole_siphon_stage_3"
	construction_entity = "stz_black_hole_siphon_stage_3"
	portrait = "GFX_megastructure_construction_background"
	scales_with_planet = yes
	entity_offset = { x = 0 y = 0 }
	place_entity_on_planet_plane = yes
	build_time = 1800
	resources = {
		category = megastructures
		cost = {
			alloys = 15000
			stz_sr_caerulenite = 10000
			stz_sr_viridisium = 5000
		}

		produces = {
			sr_dark_matter = 2000
			stz_sr_caerulenite = 1000
			stz_sr_viridisium = 500
		}

		upkeep = {
			energy = 1000
			minerals = 1000
			rare_crystals = 100
		}
	}

	prerequisites = {
		"stz_tech_viridian_black_hole_siphon"
	}

	upgrade_from = {
		stz_black_hole_siphon_stage_2
	}
}