crisis_sphere_0 = {
	entity = "dyson_sphere_phase_01_entity"
	portrait = "GFX_megastructure_construction_background"
	build_time = 3600
	resources = {
		category = megastructures
		cost = {
			sr_dark_matter = 20000
		}
		produces = {
			minerals = 250
			energy = 100
		}
	}

	country_modifier = {
		country_naval_cap_add = 200
	}

	upgrade_from = {
		crisis_sphere_ruined
	}

	potential = { #you may upgrade a ruined one if you have lost yours
		has_crisis_level = crisis_level_5
		NOT = {
			any_owned_megastructure = {
				OR = {
					has_megastructure_flag = crisis_sphere
					AND = {
						is_megastructure_type = crisis_sphere_ruined
						is_upgrading = yes
					}
				}
			}
		}
	}

	on_build_complete = {
		fromfrom = {
			solar_system.star = {
				create_ambient_object = {
					type = "crisis_sphere_1"
					location = this
				}
				last_created_ambient_object = {
					set_ambient_object_flag = crisis_sphere_1_system_effect
					set_location = {
						target = prev
						distance = 0
						angle = random
					}
				}
			}
			set_megastructure_flag = crisis_sphere
		}
	}
}

crisis_sphere_1 = {
	entity = "dyson_sphere_phase_02_entity"
	construction_entity = "dyson_sphere_part_1_entity"
	portrait = "GFX_megastructure_construction_background"
	build_time = 3600
	victory_score = 1000
	resources = {
		category = megastructures
		cost = {
			sr_dark_matter = 20000
		}
		produces = {
			minerals = 500
			energy = 200
		}
	}

	country_modifier = {
		country_naval_cap_add = 300
	}

	upgrade_from = {
		crisis_sphere_0
	}

	on_build_complete = {
		fromfrom = { set_megastructure_flag = crisis_sphere }
		from = {
			country_event = { id = crisis.6005 }
		}
	}
}

crisis_sphere_2 = {
	entity = "dyson_sphere_phase_03_entity"
	construction_entity = "dyson_sphere_part_2_entity"
	portrait = "GFX_megastructure_construction_background"
	build_time = 3600
	victory_score = 2500
	resources = {
		category = megastructures
		cost = {
			sr_dark_matter = 30000
		}
		produces = {
			minerals = 1000
			energy = 400
		}
	}

	country_modifier = {
		country_naval_cap_add = 400
	}

	upgrade_from = {
		crisis_sphere_1
	}

	on_build_complete = {
		fromfrom = { set_megastructure_flag = crisis_sphere }
		from = {
			country_event = { id = crisis.6006 }
			country_event = { id = crisis.6150 days = 180 random = 480 }
		}
	}
}

crisis_sphere_3 = {
	entity = "dyson_sphere_phase_04_entity"
	construction_entity = "dyson_sphere_part_3_entity"
	portrait = "GFX_megastructure_construction_background"
	build_time = 3600
	victory_score = 5000
	resources = {
		category = megastructures
		cost = {
			sr_dark_matter = 40000
		}
		produces = {
			minerals = 2000
			energy = 800
		}
	}

	country_modifier = {
		country_naval_cap_add = 500
	}

	upgrade_from = {
		crisis_sphere_2
	}

	on_build_complete = {
		fromfrom = { set_megastructure_flag = crisis_sphere }
		from = {
			country_event = { id = crisis.6007 }
			country_event = { id = crisis.6160 days = 180 random = 480 }
			country_event = { id = crisis.6170 days = 60 random = 1260 }
		}
	}
}

crisis_sphere_4 = {
	entity = "dyson_sphere_phase_05_entity"
	construction_entity = "dyson_sphere_part_4_entity"
	portrait = "GFX_megastructure_construction_background"
	build_time = 3600
	victory_score = 10000
	resources = {
		category = megastructures
		cost = {
			sr_dark_matter = 50000
		}
	}

	upgrade_from = {
		crisis_sphere_3
	}

	on_build_complete = {
		fromfrom = { set_megastructure_flag = crisis_sphere }
		from = {
			country_event = { id = crisis.6050 }
		}
	}
}

# Ruined Crisis Engine
crisis_sphere_ruined = {
	entity = "dyson_sphere_destroyed_entity"
	portrait = "GFX_megastructure_construction_background"

	potential = {
		always = no
	}
}
