auto_upgrade_megastructures_check = {
	if = {
		limit = {
			prev = {
				has_global_flag = giga_game_started
			}
		}
		switch = {
			trigger = is_megastructure_type
			# giga_titan_ruined = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = giga_titan_scrap
			# 		ENERGY = 1500
			# 	}
			# }
			# giga_titan_ruined = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = giga_titan_restored
			# 		ALLOYS = 1500
			# 		TECH_1 = tech_titans
			# 	}
			# }
			# giga_juggernaut_ruined = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = giga_juggernaut_scrap
			# 		ENERGY = 1500
			# 	}
			# }
			# giga_juggernaut_ruined = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = giga_juggernaut_restored
			# 		ALLOYS = 5000
			# 		TECH_1 = tech_juggernaut
			# 	}
			# }
			# giga_battleship_ruined = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = giga_battleship_scrap
			# 		ENERGY = 1000
			# 	}
			# }
			# giga_battleship_ruined = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = giga_battleship_restored
			# 		ALLOYS = 1750
			# 		TECH_1 = tech_battleships
			# 	}
			# }
			# giga_colossus_ruined = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = giga_colossus_scrap
			# 		ENERGY = 3000
			# 	}
			# }
			# giga_colossus_ruined = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = giga_colossus_restored
			# 		ALLOYS = 7500
			# 		TECH_1 = tech_colossus
			# 	}
			# }
			relic_penrose_sphere_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = relic_penrose_sphere_2
					ALLOYS = 5000
					TECH_1 = giga_tech_penrose_sphere_2
				}
			}
			# aeternum_planetcraft_ruined = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = aeternum_planetcraft_scrap
			# 		ENERGY = 35000
			# 		TECH_1 = tech_mega_engineering
			# 	}
			# }
			aeternum_planetcraft_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = aeternum_planetcraft_restored
					ALLOYS = 50000
					ENERGY = 100000
					RARE_CRYSTALS = 2500
					VOLATILE_MOTES = 2500
					EXOTIC_GASES = 2500
					TECH_1 = giga_tech_aeternite_planetcraft
				}
			}
			# matrioshka_brain_5_o_star = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = pouchkinn_engine_1
			# 	}
			# }
			pouchkinn_engine_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = pouchkinn_engine_2
				}
			}
			frameworld_penrose_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = frameworld_penrose_1
					ALLOYS = 5000
					TECH_1 = giga_tech_penrose_sphere_2
				}
			}
			frameworld_penrose_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = frameworld_penrose_2
					ALLOYS = 7500
					TECH_1 = giga_tech_penrose_sphere_2
				}
			}
			frameworld_decompressor_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = frameworld_decompressor_1
					ALLOYS = 5000
					TECH_1 = tech_matter_decompressor
				}
			}
			frameworld_decompressor_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = frameworld_decompressor_2
					ALLOYS = 7500
					TECH_1 = tech_matter_decompressor
				}
			}
			gateway_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = gateway_final
					ENERGY = 6000
					ALLOYS = 2500
					TECH_1 = tech_gateway_activation
					TECH_2 = tech_gateway_construction
				}
			}
			gateway_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = gateway_restored
					ENERGY = 6000
					ALLOYS = 2500
					TECH_1 = tech_gateway_activation
				}
			}
			habitat_central_complex_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = habitat_central_complex_restored
					INFLUENCE = 200
					ALLOYS = 1500
					TECH_1 = tech_habitat_1
				}
			}
			hyper_relay_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = hyper_relay_restored
					ENERGY = 500
					ALLOYS = 500
					RARE_CRYSTALS = 100
					TECH_1 = tech_hyper_relays
					TECH_2 = tech_hyper_drive_2
				}
			}
			orbital_elysium_origin_platform_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = orbital_elysium_origin_platform_1
					INFLUENCE = 150
					ALLOYS = 1500
					TECH_1 = giga_tech_orbital_elysium
				}
			}
			orbital_ring_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = orbital_ring_restored
					INFLUENCE = 50
					ALLOYS = 500
					TECH_1 = tech_orbital_ring_tier_1
				}
			}
			asteroid_artillery_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = asteroid_artillery_1_fake
					UNITY = @giga_kilo_unity_cost
					ALLOYS = 5000
					TECH_1 = giga_tech_asteroid_artillery
				}
			}
			asteroid_artillery_config = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = asteroid_artillery_1
					UNITY = @giga_kilo_unity_cost
					ALLOYS = 5000
					TECH_1 = giga_tech_asteroid_artillery
				}
			}
			asteroid_artillery_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = asteroid_artillery_config
					TECH_1 = giga_tech_asteroid_artillery
				}
			}
			asteroid_artillery_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = asteroid_artillery_repaired
					UNITY = @giga_kilo_repair_unity_cost
					ALLOYS = 2500
					TECH_1 = giga_tech_asteroid_artillery
				}
			}
			asteroid_manufactory_ai_consumer_goods = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = asteroid_manufactory_platform_consumer_goods
				}
			}
			asteroid_manufactory_ai_alloys = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = asteroid_manufactory_platform_alloys
				}
			}
			asteroid_manufactory_ai_food = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = asteroid_manufactory_platform_food
				}
			}
			asteroid_manufactory_ai_energy = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = asteroid_manufactory_platform_energy
				}
			}
			asteroid_manufactory_ai_supertensiles = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = asteroid_manufactory_platform_supertensiles
				}
			}
			atmosphere_shredder_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = atmosphere_shredder_1
					UNITY = @science_kilo_cost_2
					ALLOYS = @science_kilo_cost_2
					ENERGY = 1000
					TECH_1 = giga_tech_macro_scale_weather_manipulation
				}
			}
			atmosphere_shredder_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = atmosphere_shredder_2
					UNITY = @science_kilo_unity_3
					ALLOYS = @science_kilo_alloys_3
					ENERGY = 1500
					TECH_1 = giga_tech_macro_scale_weather_manipulation
				}
			}
			atmosphere_shredder_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = atmosphere_shredder_3
					UNITY = @science_kilo_unity_4
					ALLOYS = @science_kilo_alloys_4
					ENERGY = 2000
					TECH_1 = giga_tech_macro_scale_weather_manipulation
				}
			}
			atmosphere_shredder_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = atmosphere_shredder_restored
					UNITY = @giga_kilo_repair_unity_cost
					ALLOYS = 5000
					ENERGY = 2000
					TECH_1 = giga_tech_macro_scale_weather_manipulation
				}
			}
			automated_stripmine_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = automated_stripmine_1
					UNITY = @giga_mega_unity_cost
					ALLOYS = 7500
					TECH_1 = giga_tech_automated_stripmine_2
				}
			}
			crystal_megabore_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = crystal_megabore_1
					UNITY = @giga_small_mega_unity_cost
					ALLOYS = 7500
					TECH_1 = giga_tech_crystal_megabore
				}
			}
			dyson_swarm_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = dyson_swarm_2
					UNITY = 2500
					ALLOYS = 1000
					ENERGY = 1000
					TECH_1 = tech_dyson_swarm
				}
			}
			dyson_swarm_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = dyson_swarm_3
					ENERGY = 1500
					UNITY = 5000
					ALLOYS = 1500
					TECH_1 = tech_dyson_swarm
				}
			}
			kugelblitz_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = kugelblitz_1
					ENERGY = 25000
					UNITY = @giga_small_mega_unity_cost
					ALLOYS = 1000
					TECH_1 = giga_tech_kugelblitz
				}
			}
			kugelblitz_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = kugelblitz_2
					ENERGY = 37500
					UNITY = @giga_mega_unity_cost
					ALLOYS = 2500
					TECH_1 = giga_tech_kugelblitz
					TECH_2 = tech_mega_engineering
				}
			}
			kugelblitz_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = kugelblitz_3
					ENERGY = 75000
					UNITY = @giga_big_mega_unity_cost
					ALLOYS = 5000
					TECH_1 = giga_tech_kugelblitz
					TECH_2 = giga_tech_tetradimensional_engineering
				}
			}
			kugelblitz_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = kugelblitz_restored
					ENERGY = 25000
					UNITY = @giga_small_mega_repair_unity_cost
					ALLOYS = 2500
					TECH_1 = giga_tech_kugelblitz
				}
			}
			macro_test_site_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = macro_test_site_1
					UNITY = @science_kilo_cost_2
					ALLOYS = @science_kilo_cost_2
					ENERGY = 1000
					TECH_1 = giga_tech_engineering_test_site
				}
			}
			macro_test_site_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = macro_test_site_2
					UNITY = @science_kilo_unity_3
					ALLOYS = @science_kilo_alloys_3
					ENERGY = 1500
					TECH_1 = giga_tech_engineering_test_site
				}
			}
			macro_test_site_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = macro_test_site_3
					UNITY = @science_kilo_unity_4
					ALLOYS = @science_kilo_alloys_4
					ENERGY = 2000
					TECH_1 = giga_tech_engineering_test_site
				}
			}
			macro_test_site_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = macro_test_site_restored
					UNITY = @giga_kilo_repair_unity_cost
					ALLOYS = 5000
					ENERGY = 2000
					TECH_1 = giga_tech_engineering_test_site
				}
			}
			orbital_arc_furnace_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = orbital_arc_furnace_2
					UNITY = 1000
					ALLOYS = 1000
					ENERGY = 1000
					TECH_1 = tech_orbital_arc_furnace
				}
			}
			orbital_arc_furnace_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = orbital_arc_furnace_3
					UNITY = 2000
					ALLOYS = 1500
					ENERGY = 1500
					TECH_1 = tech_orbital_arc_furnace
				}
			}
			orbital_arc_furnace_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = orbital_arc_furnace_4
					UNITY = 4000
					ALLOYS = 2000
					ENERGY = 2000
					TECH_1 = tech_orbital_arc_furnace
				}
			}
			orbital_arc_furnace_destroyed = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = orbital_arc_furnace_restored
					UNITY = 2000
					ALLOYS = 3000
					ENERGY = 2000
					TECH_1 = tech_orbital_arc_furnace
				}
			}
			orbital_artificial_eco_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = orbital_artificial_eco_1
					UNITY = @science_kilo_cost_2
					ALLOYS = @science_kilo_cost_2
					ENERGY = 1000
					TECH_1 = giga_tech_orbital_artificial_eco
				}
			}
			orbital_artificial_eco_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = orbital_artificial_eco_2
					UNITY = @science_kilo_unity_3
					ALLOYS = @science_kilo_alloys_3
					ENERGY = 1500
					TECH_1 = giga_tech_orbital_artificial_eco
				}
			}
			orbital_artificial_eco_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = orbital_artificial_eco_3
					UNITY = @science_kilo_unity_4
					ALLOYS = @science_kilo_alloys_4
					ENERGY = 2000
					TECH_1 = giga_tech_orbital_artificial_eco
				}
			}
			orbital_artificial_eco_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = orbital_artificial_eco_restored
					UNITY = @giga_kilo_repair_unity_cost
					ALLOYS = 5000
					ENERGY = 2000
					TECH_1 = giga_tech_orbital_artificial_eco
				}
			}
			succ_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = succ_1
					UNITY = @giga_mega_unity_cost
					ALLOYS = 7500
					TECH_1 = giga_tech_succ
				}
			}
			anti_sirens_shield = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = anti_sirens_shield_dismantle
					ENERGY = 1000
					ALLOYS = -10000
				}
			}
			war_moon_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_moon_1
					UNITY = @giga_mega_unity_cost
					ALLOYS = 7000
					TECH_1 = giga_tech_war_moon_2
				}
			}
			war_moon_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_moon_2
					UNITY = @giga_mega_unity_cost
					ALLOYS = 11000
					TECH_1 = giga_tech_war_moon_2
				}
			}
			war_moon_debris_cold_barren = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_moon_restored_cold_barren
					UNITY = @giga_mega_repair_unity_cost
					ALLOYS = 11000
					TECH_1 = giga_tech_war_moon_2
				}
			}
			war_moon_debris_barren = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_moon_restored_barren
					UNITY = @giga_mega_repair_unity_cost
					ALLOYS = 11000
					TECH_1 = giga_tech_war_moon_2
				}
			}
			war_moon_debris_frozen = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_moon_restored_frozen
					UNITY = @giga_mega_repair_unity_cost
					ALLOYS = 11000
					TECH_1 = giga_tech_war_moon_2
				}
			}
			war_moon_debris_disco = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_moon_restored_disco
					UNITY = @giga_mega_repair_unity_cost
					ALLOYS = 11000
					TECH_1 = giga_tech_war_moon_2
				}
			}
			war_moon_debris_luna = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_moon_restored_luna
					UNITY = @giga_mega_repair_unity_cost
					ALLOYS = 11000
					TECH_1 = giga_tech_war_moon_2
				}
			}
			war_moon_debris_molten = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_moon_restored_molten
					UNITY = @giga_mega_repair_unity_cost
					ALLOYS = 11000
					TECH_1 = giga_tech_war_moon_2
				}
			}
			the_vat_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = the_vat_1
					UNITY = @giga_mega_unity_cost
					ALLOYS = 10000
					TECH_1 = giga_tech_the_vat
				}
			}
			the_vat_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = the_vat_2
					UNITY = @giga_mega_unity_cost
					ALLOYS = 7500
					TECH_1 = giga_tech_the_vat
				}
			}
			the_vat_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = the_vat_3
					UNITY = @giga_mega_unity_cost
					ALLOYS = 7500
					TECH_1 = giga_tech_the_vat
				}
			}
			the_vat_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = the_vat_4
					UNITY = @giga_mega_unity_cost
					ALLOYS = 7500
					TECH_1 = giga_tech_the_vat
				}
			}
			dyson_sphere_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = dyson_sphere_1
					UNITY = @dyson_cost_unity_g_star
					ALLOYS = @dyson_p1_cost_alloys_g_star
					TECH_1 = tech_dyson_sphere
				}
			}
			dyson_sphere_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = dyson_sphere_2
					UNITY = @dyson_cost_unity_g_star
					ALLOYS = @dyson_p2_cost_alloys_g_star
					TECH_1 = tech_dyson_sphere
				}
			}
			dyson_sphere_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = dyson_sphere_3
					UNITY = @dyson_cost_unity_g_star
					ALLOYS = @dyson_p3_cost_alloys_g_star
					TECH_1 = tech_dyson_sphere
				}
			}
			dyson_sphere_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = dyson_sphere_4
					UNITY = @dyson_cost_unity_g_star
					ALLOYS = @dyson_p4_cost_alloys_g_star
					TECH_1 = tech_dyson_sphere
				}
			}
			dyson_sphere_4 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = dyson_sphere_5
					UNITY = @dyson_cost_unity_g_star
					ALLOYS = @dyson_p5_cost_alloys_g_star
					TECH_1 = tech_dyson_sphere
				}
			}
			dyson_sphere_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = dyson_sphere_restored
					UNITY = @dyson_cost_unity_g_star
					ALLOYS = @dyson_r_cost_alloys_g_star
					TECH_1 = tech_mega_engineering
				}
			}
			dyson_sphere_0_o_star = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = dyson_sphere_1_o_star
					UNITY = @dyson_cost_unity_o_star
					ALLOYS = @dyson_p1_cost_alloys_o_star
					TECH_1 = tech_dyson_sphere
				}
			}
			dyson_sphere_1_o_star = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = dyson_sphere_2_o_star
					UNITY = @dyson_cost_unity_o_star
					ALLOYS = @dyson_p2_cost_alloys_o_star
					TECH_1 = tech_dyson_sphere
				}
			}
			dyson_sphere_2_o_star = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = dyson_sphere_3_o_star
					UNITY = @dyson_cost_unity_o_star
					ALLOYS = @dyson_p3_cost_alloys_o_star
					TECH_1 = tech_dyson_sphere
				}
			}
			dyson_sphere_3_o_star = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = dyson_sphere_4_o_star
					UNITY = @dyson_cost_unity_o_star
					ALLOYS = @dyson_p4_cost_alloys_o_star
					TECH_1 = tech_dyson_sphere
				}
			}
			dyson_sphere_4_o_star = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = dyson_sphere_5_o_star
					UNITY = @dyson_cost_unity_o_star
					ALLOYS = @dyson_p5_cost_alloys_o_star
					TECH_1 = tech_dyson_sphere
				}
			}
			eq_shipyard_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = eq_shipyard_1
					UNITY = @giga_mega_unity_cost
					ALLOYS = 5000
					TECH_1 = giga_tech_equatorial_shipyard
				}
			}
			eq_shipyard_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = eq_shipyard_2
					UNITY = @giga_mega_unity_cost
					ALLOYS = 5000
					TECH_1 = giga_tech_equatorial_shipyard
				}
			}
			ehof_megastructure_phase0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ehof_megastructure_phase1
					UNITY = @giga_mega_unity_cost
					ALLOYS = @phase_1_alloy_cost
					TECH_1 = tech_ehof_phase_01
				}
			}
			ehof_megastructure_phase1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ehof_megastructure_phase2
					INFLUENCE = @phase_2_influence_cost
					UNITY = @giga_mega_unity_cost
					ALLOYS = @phase_2_alloy_cost
					TECH_1 = tech_ehof_phase_02
				}
			}
			ehof_megastructure_phase2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ehof_megastructure_phase3
					INFLUENCE = @phase_3_influence_cost
					UNITY = @giga_mega_unity_cost
					ALLOYS = @phase_3_alloy_cost
					TECH_1 = tech_ehof_phase_03
				}
			}
			ehof_megastructure_phase3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ehof_megastructure_phase4
					UNITY = @giga_mega_unity_cost
					ALLOYS = @phase_4_alloy_cost
					TECH_1 = tech_ehof_phase_04
				}
			}
			ehof_megastructure_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ehof_megastructure_restored
					INFLUENCE = @ruined_ehof_influence_cost
					UNITY = @giga_mega_repair_unity_cost
					ALLOYS = @ruined_ehof_alloy_cost
					TECH_1 = tech_ehof_phase_01
				}
			}
			ehof_megastructure_ruined_origin = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ehof_megastructure_restored_origin
					INFLUENCE = 50
					ALLOYS = 4000
					TECH_1 = tech_abstract_1
				}
			}
			fusion_suppressor_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = fusion_suppressor_1
					UNITY = @giga_big_mega_unity_cost
					ALLOYS = 11000
					TECH_1 = giga_tech_fusion_suppressor
				}
			}
			fusion_suppressor_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = fusion_suppressor_2
					UNITY = @giga_big_mega_unity_cost
					ALLOYS = 8000
					TECH_1 = giga_tech_fusion_suppressor
				}
			}
			fusion_suppressor_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = fusion_suppressor_3
					ENERGY = 10000
					UNITY = @giga_big_mega_unity_cost
					ALLOYS = 8000
					TECH_1 = giga_tech_fusion_suppressor
				}
			}
			fusion_suppressor_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = fusion_suppressor_4
					ENERGY = 20000
					UNITY = @giga_big_mega_unity_cost
					TECH_1 = giga_tech_fusion_suppressor
				}
			}
			fusion_suppressor_4 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = fusion_suppressor_5
					ENERGY = 20000
					UNITY = @giga_big_mega_unity_cost
					TECH_1 = giga_tech_fusion_suppressor
				}
			}
			# fusion_suppressor_5 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = fusion_suppressor_6b
			# 		ENERGY = 7500
			# 		UNITY = @giga_big_mega_unity_cost
			# 		TECH_1 = giga_tech_fusion_suppressor
			# 	}
			# }
			# fusion_suppressor_5 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = fusion_suppressor_6
			# 		ENERGY = 7500
			# 		UNITY = @giga_big_mega_unity_cost
			# 		TECH_1 = giga_tech_fusion_suppressor
			# 	}
			# }
			fusion_suppressor_6 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = fusion_suppressor_7
					ENERGY = 1000
					ALLOYS = -7500
					TECH_1 = giga_tech_fusion_suppressor
				}
			}
			terraform_shattered_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = terraform_shattered_1
					UNITY = @giga_kilo_unity_cost
					ALLOYS = 2000
					TECH_1 = giga_tech_terraform_shattered
				}
			}
			terraform_shattered_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = terraform_shattered_2
					UNITY = @giga_kilo_unity_cost
					ALLOYS = 2000
					TECH_1 = giga_tech_terraform_shattered
				}
			}
			terraform_shattered_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = terraform_shattered_3
					UNITY = @giga_kilo_unity_cost
					ALLOYS = 2000
					TECH_1 = giga_tech_terraform_shattered
				}
			}
			terraform_shattered_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = terraform_shattered_4
					ENERGY = 7500
					TECH_1 = giga_tech_terraform_shattered
				}
			}
			interstellar_assembly_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = interstellar_assembly_1
					UNITY = @giga_mega_unity_cost
					ALLOYS = 10000
					TECH_1 = tech_interstellar_assembly
				}
			}
			interstellar_assembly_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = interstellar_assembly_2
					UNITY = @giga_mega_unity_cost
					ALLOYS = 10000
					TECH_1 = tech_interstellar_assembly
				}
			}
			interstellar_assembly_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = interstellar_assembly_3
					UNITY = @giga_mega_unity_cost
					ALLOYS = 10000
					TECH_1 = tech_interstellar_assembly
				}
			}
			interstellar_assembly_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = interstellar_assembly_4
					UNITY = @giga_mega_unity_cost
					ALLOYS = 10000
					TECH_1 = tech_interstellar_assembly
				}
			}
			interstellar_assembly_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = interstellar_assembly_restored
					UNITY = @giga_mega_repair_unity_cost
					ALLOYS = 10000
					TECH_1 = tech_mega_engineering
				}
			}
			interstellar_habitat_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = interstellar_habitat_1
					ENERGY = 5000
					UNITY = @giga_mega_unity_cost
					ALLOYS = 5000
					TECH_1 = giga_tech_interstellar_habitat
				}
			}
			interstellar_habitat_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = interstellar_habitat_3
					INFLUENCE = 300
					ALLOYS = 6000
					TECH_1 = giga_tech_interstellar_ringworld
				}
			}
			interstellar_habitat_4 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = interstellar_habitat_5
					ALLOYS = 10000
					TECH_1 = giga_tech_interstellar_ringworld
				}
			}
			kaiser_moon_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = kaiser_moon_1
					ALLOYS = 10000
					TECH_1 = giga_tech_kaiser_moon
				}
			}
			kaiser_moon_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = kaiser_moon_2
					ALLOYS = 15000
					TECH_1 = giga_tech_kaiser_moon
				}
			}
			lunar_disco_ball_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = lunar_disco_ball_1
					ENERGY = 5000
					UNITY = @giga_small_mega_unity_cost
					ALLOYS = 2500
					TECH_1 = giga_tech_disco_moon
				}
			}
			lunar_disco_ball_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = lunar_disco_ball_2
					RARE_CRYSTALS = 1500
					ENERGY = 10000
					UNITY = @giga_small_mega_unity_cost
					ALLOYS = 2000
					TECH_1 = giga_tech_disco_moon
				}
			}
			macro_stabilizer_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = macro_stabilizer_1
					UNITY = @giga_kilo_unity_cost
					ALLOYS = 2500
					TECH_1 = giga_tech_terraform_gas
				}
			}
			macro_stabilizer_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = macro_stabilizer_2
					UNITY = @giga_kilo_unity_cost
					ALLOYS = 3500
					TECH_1 = giga_tech_terraform_gas
				}
			}
			macro_stabilizer_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = macro_stabilizer_3
					ENERGY = 10000
					TECH_1 = giga_tech_terraform_gas
				}
			}
			maginot_world_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = maginot_world_1
					MINERALS = 5000
					UNITY = @giga_big_mega_unity_cost
					ALLOYS = 15000
					TECH_1 = giga_tech_maginot_world
				}
			}
			maginot_world_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = maginot_world_2
					MINERALS = 20000
					ENERGY = 10000
					UNITY = @giga_big_mega_unity_cost
					ALLOYS = 30000
					TECH_1 = giga_tech_maginot_world
				}
			}
			maginot_world_ringworld_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = maginot_world_ringworld_1
					MINERALS = 5000
					ALLOYS = 15000
					TECH_1 = giga_tech_maginot_world
				}
			}
			maginot_world_ringworld_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = maginot_world_ringworld_2
					MINERALS = 20000
					ENERGY = 10000
					ALLOYS = 30000
					TECH_1 = giga_tech_maginot_world
				}
			}
			matter_decompressor_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = matter_decompressor_1
					UNITY = @giga_big_mega_unity_cost
					ALLOYS = 12500
					TECH_1 = tech_matter_decompressor
				}
			}
			matter_decompressor_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = matter_decompressor_2
					UNITY = @giga_big_mega_unity_cost
					ALLOYS = 12500
					TECH_1 = tech_matter_decompressor
				}
			}
			matter_decompressor_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = matter_decompressor_3
					UNITY = @giga_big_mega_unity_cost
					ALLOYS = 12500
					TECH_1 = tech_matter_decompressor
				}
			}
			matter_decompressor_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = matter_decompressor_4
					UNITY = @giga_big_mega_unity_cost
					ALLOYS = 12500
					TECH_1 = tech_matter_decompressor
				}
			}
			matter_decompressor_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = matter_decompressor_restored
					UNITY = @giga_big_mega_repair_unity_cost
					ALLOYS = 20000
					TECH_1 = tech_mega_engineering
				}
			}
			mega_art_installation_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = mega_art_installation_1
					UNITY = @giga_mega_unity_cost
					ALLOYS = 15000
					TECH_1 = tech_mega_art
				}
			}
			mega_art_installation_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = mega_art_installation_2
					UNITY = @giga_mega_unity_cost
					ALLOYS = 15000
					TECH_1 = tech_mega_art
				}
			}
			mega_art_installation_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = mega_art_installation_3
					UNITY = @giga_mega_unity_cost
					ALLOYS = 15000
					TECH_1 = tech_mega_art
				}
			}
			mega_art_installation_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = mega_art_installation_4
					MINOR_ARTIFACTS = 2000
					UNITY = @giga_mega_unity_cost
					TECH_1 = tech_mega_art
				}
			}
			mega_art_installation_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = mega_art_installation_restored
					UNITY = @giga_mega_repair_unity_cost
					ALLOYS = 15000
					TECH_1 = tech_mega_engineering
				}
			}
			mega_art_installation_restored = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = mega_art_installation_restored_2
					MINOR_ARTIFACTS = 2000
					UNITY = @giga_mega_repair_unity_cost
					TECH_1 = tech_mega_art
				}
			}
			mega_shipyard_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = mega_shipyard_1
					UNITY = @giga_mega_unity_cost
					ALLOYS = 10000
					TECH_1 = tech_mega_shipyard
				}
			}
			mega_shipyard_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = mega_shipyard_2
					UNITY = @giga_mega_unity_cost
					ALLOYS = 10000
					TECH_1 = tech_mega_shipyard
				}
			}
			mega_shipyard_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = mega_shipyard_3
					UNITY = @giga_mega_unity_cost
					ALLOYS = 10000
					TECH_1 = tech_mega_shipyard
				}
			}
			mega_shipyard_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = mega_shipyard_restored
					UNITY = @giga_mega_repair_unity_cost
					ALLOYS = 10000
					TECH_1 = tech_mega_engineering
				}
			}
			neutronium_gigaforge_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = neutronium_gigaforge_1
					UNITY = @giga_mega_unity_cost
					ALLOYS = 7500
					TECH_1 = giga_tech_neutronium_gigaforge
				}
			}
			neutronium_gigaforge_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = neutronium_gigaforge_2
					UNITY = @giga_mega_unity_cost
					ALLOYS = 5000
					TECH_1 = giga_tech_neutronium_gigaforge
				}
			}
			neutronium_gigaforge_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = neutronium_gigaforge_3
					UNITY = @giga_mega_unity_cost
					ALLOYS = 5000
					TECH_1 = giga_tech_neutronium_gigaforge
				}
			}
			neutronium_gigaforge_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = neutronium_gigaforge_restored
					UNITY = @giga_mega_repair_unity_cost
					ALLOYS = 15000
					TECH_1 = giga_tech_neutronium_gigaforge
				}
			}
			orbital_bastion_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = orbital_bastion_1
					UNITY = @giga_small_mega_unity_cost
					ALLOYS = 2000
					TECH_1 = giga_tech_orbital_bastion
				}
			}
			orbital_bastion_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = orbital_bastion_2
					UNITY = @giga_small_mega_unity_cost
					ALLOYS = 2500
					TECH_1 = giga_tech_orbital_bastion
				}
			}
			orbital_bastion_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = orbital_bastion_3
					UNITY = @giga_mega_unity_cost
					ALLOYS = 9000
					TECH_1 = giga_tech_orbital_bastion
				}
			}
			penrose_sphere_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = penrose_sphere_1
					UNITY = @giga_mega_unity_cost
					ALLOYS = 5000
					TECH_1 = giga_tech_penrose_sphere_1
				}
			}
			#penrose_sphere_1 = { 
			#	auto_upgrade_megastructure = { 
			#		UPGRADE_TO = penrose_sphere_a2
			#		UNITY = @giga_mega_unity_cost
			#		ALLOYS = 7500
			#		TECH_1 = giga_tech_penrose_sphere_1
			#	}
			#}
			penrose_sphere_a2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = penrose_sphere_a3
					ENERGY = 10000
					TECH_1 = giga_tech_penrose_sphere_1
				}
			}
			penrose_sphere_a3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = penrose_sphere_a4
					ENERGY = 2500
					TECH_1 = giga_tech_penrose_sphere_1
				}
			}
			# penrose_sphere_1 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = penrose_sphere_b2
			# 		UNITY = @giga_mega_unity_cost
			# 		ALLOYS = 7500
			# 		TECH_1 = giga_tech_penrose_sphere_1
			# 	}
			# }
			penrose_sphere_b2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = penrose_sphere_b3
					UNITY = @giga_mega_unity_cost
					ALLOYS = 5000
					TECH_1 = giga_tech_penrose_sphere_2
				}
			}
			penrose_sphere_b3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = penrose_sphere_b4
					INFLUENCE = 300
					ALLOYS = 20000
					TECH_1 = giga_tech_penrose_sphere_3
				}
			}
			gigablackhole_ring_world_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = gigablackhole_ring_world_3
					ALLOYS = 40000
					TECH_1 = giga_tech_penrose_sphere_3
				}
			}
			planetary_computer_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = planetary_computer_1
					ENERGY = 5000
					UNITY = @giga_mega_unity_cost
					ALLOYS = 5000
					TECH_1 = giga_tech_planetary_computer
				}
			}
			planetary_computer_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = planetary_computer_2
					ENERGY = 20000
					UNITY = @giga_mega_unity_cost
					ALLOYS = 20000
					TECH_1 = giga_tech_planetary_computer
				}
			}
			planetary_drive_yard_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = planetary_drive_yard_1
					UNITY = @giga_small_mega_unity_cost
					ALLOYS = 4000
					TECH_1 = giga_tech_planetary_drive_yard
				}
			}
			# planetary_drive_yard_1 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = planetary_drive_yard_1_shipyard
			# 		UNITY = @giga_mega_unity_cost
			# 		ALLOYS = 6000
			# 		TECH_1 = giga_tech_planetary_drive_yard_shipyard
			# 	}
			# }
			# planetary_drive_yard_1 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = planetary_drive_yard_1_fortress
			# 		UNITY = @giga_mega_unity_cost
			# 		ALLOYS = 7500
			# 		TECH_1 = giga_tech_planetary_drive_yard_defense
			# 	}
			# }
			ehof_presphere_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ehof_presphere_dyson
					GIGA_SR_SENTIENT_METAL = 50000
					GIGA_SR_NEGATIVE_MASS = 50000
					TECH_1 = tech_ehof_phase_01
				}
			}
			psychic_beacon_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = psychic_beacon_1
					UNITY = @giga_mega_unity_cost
					ALLOYS = 10000
					TECH_1 = giga_tech_psychic_beacon
				}
			}
			psychic_beacon_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = psychic_beacon_2
					UNITY = @giga_mega_unity_cost
					ALLOYS = 10000
					TECH_1 = giga_tech_psychic_beacon
				}
			}
			psychic_beacon_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = psychic_beacon_3
					UNITY = @giga_mega_unity_cost
					ALLOYS = 10000
					TECH_1 = giga_tech_psychic_beacon
				}
			}
			psychic_beacon_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = psychic_beacon_4
				}
			}
			psychic_hypersiphon_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = psychic_hypersiphon_1
					UNITY = @giga_small_mega_unity_cost
					ALLOYS = 7500
					TECH_1 = giga_tech_psychic_hypersiphon
				}
			}
			psychic_hypersiphon_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = psychic_hypersiphon_2
					ENERGY = 20000
					SR_ZRO = 500
					ALLOYS = 7500
					TECH_1 = giga_tech_psychic_hypersiphon
				}
			}
			quantum_catapult_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = quantum_catapult_1
					ALLOYS = 10000
					TECH_1 = tech_mega_engineering
					TECH_2 = tech_quantum_catapult
				}
			}
			quantum_catapult_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = quantum_catapult_2
					ALLOYS = 10000
					TECH_1 = tech_mega_engineering
					TECH_2 = tech_quantum_catapult
				}
			}
			quantum_catapult_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = quantum_catapult_3
					ALLOYS = 10000
					TECH_1 = tech_mega_engineering
					TECH_2 = tech_quantum_catapult
				}
			}
			quantum_catapult_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = quantum_catapult_restored
					ALLOYS = 10000
					TECH_1 = tech_mega_engineering
				}
			}
			quantum_catapult_ruined_slingshot = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = quantum_catapult_restored_slingshot
					ALLOYS = 2500
					TECH_1 = tech_mega_engineering
				}
			}
			quantum_catapult_restored_slingshot = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = quantum_catapult_improved_slingshot
					ALLOYS = 15000
					TECH_1 = tech_mega_engineering
					TECH_2 = tech_quantum_catapult
				}
			}
			ring_world_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ring_world_2_intermediate
					ALLOYS = 10000
					TECH_1 = tech_ring_world
				}
			}
			ring_world_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ring_world_3_intermediate
					ALLOYS = 10000
					TECH_1 = tech_ring_world
				}
			}
			ring_world_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ring_world_restored
					ALLOYS = 10000
					TECH_1 = tech_mega_engineering
				}
			}
			think_tank_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = think_tank_1
					UNITY = @giga_big_mega_unity_cost
					ALLOYS = 15000
					TECH_1 = tech_science_nexus
				}
			}
			think_tank_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = think_tank_2
					UNITY = @giga_big_mega_unity_cost
					ALLOYS = 15000
					TECH_1 = tech_science_nexus
				}
			}
			think_tank_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = think_tank_3
					UNITY = @giga_big_mega_unity_cost
					ALLOYS = 15000
					TECH_1 = tech_science_nexus
				}
			}
			think_tank_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = think_tank_restored
					UNITY = @giga_big_mega_repair_unity_cost
					ALLOYS = 15000
					TECH_1 = tech_mega_engineering
				}
			}
			ehof_sm_forge_phase00 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ehof_sm_forge_phase1
					GIGA_SR_NEGATIVE_MASS = 10000
					ALLOYS = 10000
				}
			}
			ehof_sm_forge_phase1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ehof_sm_forge_phase2
					GIGA_SR_SENTIENT_METAL = 5000
					GIGA_SR_NEGATIVE_MASS = 7500
				}
			}
			ehof_sm_forge_phase2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ehof_sm_forge_phase3
					GIGA_SR_SENTIENT_METAL = 10000
					GIGA_SR_NEGATIVE_MASS = 15000
				}
			}
			ehof_sm_forge_phase3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ehof_sm_forge_phase4
					GIGA_SR_SENTIENT_METAL = 20000
					GIGA_SR_NEGATIVE_MASS = 30000
				}
			}
			spy_orb_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = spy_orb_1
					UNITY = @giga_mega_unity_cost
					ALLOYS = 10000
					TECH_1 = tech_sentry_array
				}
			}
			spy_orb_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = spy_orb_2
					UNITY = @giga_mega_unity_cost
					ALLOYS = 10000
					TECH_1 = tech_sentry_array
				}
			}
			spy_orb_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = spy_orb_3
					UNITY = @giga_mega_unity_cost
					ALLOYS = 10000
					TECH_1 = tech_sentry_array
				}
			}
			spy_orb_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = spy_orb_4
					UNITY = @giga_mega_unity_cost
					ALLOYS = 10000
					TECH_1 = tech_sentry_array
				}
			}
			spy_orb_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = spy_orb_restored
					UNITY = @giga_mega_repair_unity_cost
					ALLOYS = 15000
					TECH_1 = tech_mega_engineering
				}
			}
			r_square_world_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = r_square_world_restored
					SR_LIVING_METAL = 200
					ALLOYS = 10000
					TECH_1 = giga_tech_event_squareworld
				}
			}
			r_square_world_hub = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = r_square_world_hub_powered
					ENERGY = 7500
					ALLOYS = 1000
				}
			}
			r_square_world_hub_powered = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = r_square_world_hub_garyx
					ENERGY = 100
				}
			}
			star_lifter_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = star_lifter_1
					UNITY = @starlifter_cost_unity_g_star
					ALLOYS = @starlifter_p1_cost_alloys_g_star
					TECH_1 = giga_tech_star_lifter
				}
			}
			star_lifter_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = star_lifter_2
					UNITY = @starlifter_cost_unity_g_star
					ALLOYS = @starlifter_p2_cost_alloys_g_star
					TECH_1 = giga_tech_star_lifter
				}
			}
			star_lifter_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = star_lifter_3
					UNITY = @starlifter_cost_unity_g_star
					ALLOYS = @starlifter_p3_cost_alloys_g_star
					TECH_1 = giga_tech_star_lifter
				}
			}
			star_lifter_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = star_lifter_4
					UNITY = @starlifter_cost_unity_g_star
					ALLOYS = @starlifter_p4_cost_alloys_g_star
					TECH_1 = giga_tech_star_lifter
				}
			}
			star_lifter_4 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = star_lifter_5
					UNITY = @starlifter_cost_unity_g_star
					ALLOYS = @starlifter_p5_cost_alloys_g_star
					TECH_1 = giga_tech_star_lifter
				}
			}
			stellarite_kaiser_moon_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = stellarite_kaiser_moon_1
					ENERGY = 50000
					ALLOYS = 30000
					TECH_1 = giga_tech_stellarite_kaiser_moon
				}
			}
			stellarite_kaiser_moon_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = stellarite_kaiser_moon_2
					ENERGY = 75000
					ALLOYS = 30000
					TECH_1 = giga_tech_stellarite_kaiser_moon
				}
			}
			stellar_ring_habitat_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = stellar_ring_habitat_1
					ENERGY = 1000
					MINERALS = 15000
					UNITY = @giga_mega_unity_cost
					TECH_1 = giga_tech_stellar_ring_habitat
				}
			}
			stellar_ring_habitat_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = stellar_ring_habitat_2
					ALLOYS = 300
					UNITY = @giga_mega_unity_cost
					TECH_1 = giga_tech_stellar_ring_habitat
				}
			}
			stellar_ring_habitat_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = stellar_ring_habitat_3
					ALLOYS = 300
					UNITY = @giga_mega_unity_cost
					TECH_1 = giga_tech_stellar_ring_habitat
				}
			}
			strategic_coordination_center_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = strategic_coordination_center_1
					UNITY = @giga_mega_unity_cost
					ALLOYS = 15000
					TECH_1 = tech_strategic_coordination
				}
			}
			strategic_coordination_center_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = strategic_coordination_center_2
					UNITY = @giga_mega_unity_cost
					ALLOYS = 15000
					TECH_1 = tech_strategic_coordination
				}
			}
			strategic_coordination_center_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = strategic_coordination_center_3
					UNITY = @giga_mega_unity_cost
					ALLOYS = 15000
					TECH_1 = tech_strategic_coordination
				}
			}
			strategic_coordination_center_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = strategic_coordination_center_restored
					UNITY = @giga_mega_repair_unity_cost
					ALLOYS = 15000
					TECH_1 = tech_mega_engineering
				}
			}
			substellar_compressor_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = substellar_compressor_1
					UNITY = @giga_mega_unity_cost
					ALLOYS = 6500
					TECH_1 = giga_tech_substellar_compressor
				}
			}
			substellar_compressor_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = substellar_compressor_2
					UNITY = @giga_mega_unity_cost
					ALLOYS = 3500
					TECH_1 = giga_tech_substellar_compressor
				}
			}
			substellar_compressor_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = substellar_compressor_4
					ENERGY = 30000
					UNITY = @giga_mega_unity_cost
					ALLOYS = 5000
					TECH_1 = giga_tech_substellar_compressor
				}
			}
			substellar_compressor_4 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = substellar_compressor_5
					ENERGY = 5000
					UNITY = @giga_mega_unity_cost
					TECH_1 = giga_tech_substellar_compressor
				}
			}
			substellar_compressor_6 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = substellar_compressor_7
					ENERGY = 1000
					ALLOYS = -5000
					TECH_1 = giga_tech_substellar_compressor
				}
			}
			terraform_molten_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = terraform_molten_1
					UNITY = @giga_kilo_unity_cost
					ALLOYS = @terraform_molten_cost
					TECH_1 = giga_tech_terraform_molten
				}
			}
			terraform_toxic_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = terraform_toxic_1
					UNITY = @giga_kilo_unity_cost
					ALLOYS = @terraform_toxic_cost
					TECH_1 = giga_tech_terraform_toxic
				}
			}
			terraform_barren_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = terraform_barren_1
					UNITY = @giga_kilo_unity_cost
					ALLOYS = @terraform_barren_cost
					TECH_1 = giga_tech_terraform_barren
				}
			}
			ringworld_titanic_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ringworld_titanic_1
					ALLOYS = 20000
					TECH_1 = giga_tech_ringworld_titanic_2
				}
			}
			ringworld_t_3x_segment = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ringworld_titanic_2
					ALLOYS = 20000
					TECH_1 = giga_tech_ringworld_titanic_2
				}
			}
			ring_world_titanic_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ring_world_titanic_restored
					ALLOYS = 20000
					TECH_1 = tech_mega_engineering
				}
			}
			yggdrasil_orchid_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = yggdrasil_orchid_1
					UNITY = @giga_mega_unity_cost
					ALLOYS = 7500
					TECH_1 = giga_tech_yggdrasil_orchid
				}
			}
			yggdrasil_orchid_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = yggdrasil_orchid_2
					UNITY = @giga_mega_unity_cost
					ALLOYS = 5000
					TECH_1 = giga_tech_yggdrasil_orchid
				}
			}
			yggdrasil_orchid_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = yggdrasil_orchid_3
					BIO = 1000
					ENERGY = 5000
					UNITY = @giga_mega_unity_cost
					ALLOYS = -1
					TECH_1 = giga_tech_yggdrasil_orchid
				}
			}
			yggdrasil_orchid_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = yggdrasil_orchid_restored
					BIO = 1500
					ENERGY = 10000
					UNITY = @giga_mega_repair_unity_cost
					ALLOYS = 5000
					TECH_1 = tech_mega_engineering
				}
			}
			alderson_disk_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = alderson_disk_1
					UNITY = @giga_giga_unity_cost
					ALLOYS = 150000
					TECH_1 = giga_tech_alderson_disk
				}
			}
			alderson_disk_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = alderson_disk_2_gaia
					UNITY = @giga_giga_unity_cost
					ALLOYS = 150000
					TECH_1 = giga_tech_alderson_disk
				}
			}
			# alderson_disk_2 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_pc
			# 		UNITY = @giga_giga_unity_cost
			# 		ALLOYS = 120000
			# 		TECH_1 = giga_tech_planetary_computer
			# 		TECH_2 = giga_tech_alderson_disk
			# 	}
			# }
			# alderson_disk_2 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_ecu
			# 		UNITY = @giga_giga_unity_cost
			# 		ALLOYS = 120000
			# 		TECH_1 = giga_tech_alderson_disk
			# 	}
			# }
			# alderson_disk_2 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_hive
			# 		UNITY = @giga_giga_unity_cost
			# 		ALLOYS = 120000
			# 		TECH_1 = giga_tech_alderson_disk
			# 	}
			# }
			# alderson_disk_2 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_machine
			# 		UNITY = @giga_giga_unity_cost
			# 		ALLOYS = 120000
			# 		TECH_1 = giga_tech_alderson_disk
			# 	}
			# }
			# alderson_disk_ruined_left = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_construction_gaia_restored_left_complete
			# 		UNITY = @giga_giga_repair_unity_cost
			# 		ALLOYS = 75000
			# 		TECH_1 = giga_tech_tetradimensional_engineering
			# 	}
			# }
			# alderson_disk_ruined_center = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_construction_gaia_restored_center_complete
			# 		UNITY = @giga_giga_repair_unity_cost
			# 		ALLOYS = 75000
			# 		TECH_1 = giga_tech_tetradimensional_engineering
			# 	}
			# }
			# alderson_disk_ruined_right = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_construction_gaia_restored_right_complete
			# 		UNITY = @giga_giga_repair_unity_cost
			# 		ALLOYS = 75000
			# 		TECH_1 = giga_tech_tetradimensional_engineering
			# 	}
			# }
			# alderson_disk_ruined_left = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_construction_pc_restored_left_complete
			# 		UNITY = @giga_giga_repair_unity_cost
			# 		ALLOYS = 75000
			# 		TECH_1 = giga_tech_tetradimensional_engineering
			# 		TECH_2 = giga_tech_planetary_computer
			# 	}
			# }
			# alderson_disk_ruined_center = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_construction_pc_restored_center_complete
			# 		UNITY = @giga_giga_repair_unity_cost
			# 		ALLOYS = 75000
			# 		TECH_1 = giga_tech_tetradimensional_engineering
			# 		TECH_2 = giga_tech_planetary_computer
			# 	}
			# }
			# alderson_disk_ruined_right = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_construction_pc_restored_right_complete
			# 		UNITY = @giga_giga_repair_unity_cost
			# 		ALLOYS = 75000
			# 		TECH_1 = giga_tech_tetradimensional_engineering
			# 		TECH_2 = giga_tech_planetary_computer
			# 	}
			# }
			# alderson_disk_ruined_left = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_construction_ecu_restored_left_complete
			# 		UNITY = @giga_giga_repair_unity_cost
			# 		ALLOYS = 75000
			# 		TECH_1 = giga_tech_tetradimensional_engineering
			# 	}
			# }
			# alderson_disk_ruined_center = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_construction_ecu_restored_center_complete
			# 		UNITY = @giga_giga_repair_unity_cost
			# 		ALLOYS = 75000
			# 		TECH_1 = giga_tech_tetradimensional_engineering
			# 	}
			# }
			# alderson_disk_ruined_right = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_construction_ecu_restored_right_complete
			# 		UNITY = @giga_giga_repair_unity_cost
			# 		ALLOYS = 75000
			# 		TECH_1 = giga_tech_tetradimensional_engineering
			# 	}
			# }
			# alderson_disk_ruined_left = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_construction_hive_restored_left_complete
			# 		UNITY = @giga_giga_repair_unity_cost
			# 		ALLOYS = 75000
			# 		TECH_1 = giga_tech_tetradimensional_engineering
			# 	}
			# }
			# alderson_disk_ruined_center = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_construction_hive_restored_center_complete
			# 		UNITY = @giga_giga_repair_unity_cost
			# 		ALLOYS = 75000
			# 		TECH_1 = giga_tech_tetradimensional_engineering
			# 	}
			# }
			# alderson_disk_ruined_right = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_construction_hive_restored_right_complete
			# 		UNITY = @giga_giga_repair_unity_cost
			# 		ALLOYS = 75000
			# 		TECH_1 = giga_tech_tetradimensional_engineering
			# 	}
			# }
			# alderson_disk_ruined_left = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_construction_machine_restored_left_complete
			# 		UNITY = @giga_giga_repair_unity_cost
			# 		ALLOYS = 75000
			# 		TECH_1 = giga_tech_tetradimensional_engineering
			# 	}
			# }
			# alderson_disk_ruined_center = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_construction_machine_restored_center_complete
			# 		UNITY = @giga_giga_repair_unity_cost
			# 		ALLOYS = 75000
			# 		TECH_1 = giga_tech_tetradimensional_engineering
			# 	}
			# }
			# alderson_disk_ruined_right = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = alderson_disk_2_construction_machine_restored_right_complete
			# 		UNITY = @giga_giga_repair_unity_cost
			# 		ALLOYS = 75000
			# 		TECH_1 = giga_tech_tetradimensional_engineering
			# 	}
			# }
			planetcraft_printer_0_real = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = planetcraft_printer_1
					RARE_CRYSTALS = 1000
					VOLATILE_MOTES = 1000
					EXOTIC_GASES = 1000
					UNITY = @giga_giga_unity_cost
					ALLOYS = 15000
					TECH_1 = giga_tech_planet_assembly
				}
			}
			planetcraft_printer_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = planetcraft_printer_2
					RARE_CRYSTALS = 2000
					VOLATILE_MOTES = 2000
					EXOTIC_GASES = 2000
					UNITY = @giga_giga_unity_cost
					ALLOYS = 80000
					TECH_1 = giga_tech_planet_assembly
				}
			}
			planetcraft_printer_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = planetcraft_printer_3
					RARE_CRYSTALS = 5000
					VOLATILE_MOTES = 5000
					EXOTIC_GASES = 5000
					UNITY = @giga_giga_unity_cost
					ALLOYS = 200000
					TECH_1 = giga_tech_planet_assembly
				}
			}
			planetcraft_printer_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = planetcraft_printer_make_planet
					ENERGY = 200000
					UNITY = @giga_giga_unity_cost
					ALLOYS = 250000
					TECH_1 = giga_tech_planet_assembly
				}
			}
			war_planet_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_planet_1
					UNITY = @giga_giga_unity_cost
					ALLOYS = 35000
					TECH_1 = giga_tech_war_planet
				}
			}
			war_planet_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_planet_2
					UNITY = @giga_giga_unity_cost
					ALLOYS = 75000
					TECH_1 = giga_tech_war_planet
				}
			}
			war_planet_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_planet_3
					UNITY = @giga_giga_unity_cost
					ALLOYS = 100000
					TECH_1 = giga_tech_war_planet
				}
			}
			#war_planet_debris = { 
			#	auto_upgrade_megastructure = { 
			#		UPGRADE_TO = war_planet_scrap
			#		ENERGY = 30000
			#		TECH_1 = tech_mega_engineering
			#	}
			#}
			war_planet_debris = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_planet_restored
					UNITY = @giga_giga_repair_unity_cost
					ALLOYS = 100000
					TECH_1 = giga_tech_war_planet
				}
			}
			ringworld_behemoth_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ringworld_behemoth_1
					ALLOYS = 30000
					TECH_1 = giga_tech_ringworld_behemoth
				}
			}
			ringworld_b_3x_segment = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ringworld_behemoth_2
					ALLOYS = 30000
					TECH_1 = giga_tech_ringworld_behemoth
				}
			}
			ring_world_behemoth_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ring_world_behemoth_restored
					ALLOYS = 30000
					TECH_1 = tech_mega_engineering
				}
			}
			ringworld_gargantuan_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ringworld_gargantuan_1
					ALLOYS = 40000
					TECH_1 = giga_tech_ringworld_titanic_2
					TECH_2 = giga_tech_ringworld_behemoth
					TECH_3 = giga_tech_ringworld_gargantuan_2
				}
			}
			ringworld_g_3x_segment = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ringworld_gargantuan_2
					ALLOYS = 40000
					TECH_1 = giga_tech_ringworld_titanic_2
					TECH_2 = giga_tech_ringworld_behemoth
					TECH_3 = giga_tech_ringworld_gargantuan_2
				}
			}
			ring_world_gargantuan_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = ring_world_gargantuan_restored
					ALLOYS = 40000
					TECH_1 = tech_mega_engineering
				}
			}
			hrae_mc_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = hrae_mc_1
					UNITY = @giga_giga_unity_cost
					ALLOYS = 20000
					TECH_1 = giga_tech_hrae_mc
				}
			}
			hrae_mc_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = hrae_mc_2
					UNITY = @giga_giga_unity_cost
					ALLOYS = 20000
					TECH_1 = giga_tech_hrae_mc
				}
			}
			hrae_mc_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = hrae_mc_3
					UNITY = @giga_giga_unity_cost
					ALLOYS = 20000
					TECH_1 = giga_tech_hrae_mc
				}
			}
			hrae_mc_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = hrae_mc_4
					UNITY = @giga_giga_unity_cost
					ALLOYS = 20000
					TECH_1 = giga_tech_hrae_mc
				}
			}
			hyperstructural_ass_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = hyperstructural_ass_1
					UNITY = @giga_giga_unity_cost
					ALLOYS = 10000
					TECH_1 = giga_tech_hyperstructural_ass
				}
			}
			hyperstructural_ass_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = hyperstructural_ass_2
					UNITY = @giga_giga_unity_cost
					ALLOYS = 20000
					TECH_1 = giga_tech_hyperstructural_ass
				}
			}
			hyperstructural_ass_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = hyperstructural_ass_3
					UNITY = @giga_giga_unity_cost
					ALLOYS = 35000
					TECH_1 = giga_tech_hyperstructural_ass
				}
			}
			hyperstructural_ass_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = hyperstructural_ass_4
					UNITY = @giga_giga_unity_cost
					ALLOYS = 40000
					TECH_1 = giga_tech_hyperstructural_ass
				}
			}
			lunar_macroreplicator_0_real = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = lunar_macroreplicator_1
					RARE_CRYSTALS = 250
					VOLATILE_MOTES = 250
					EXOTIC_GASES = 250
					UNITY = @giga_giga_unity_cost
					ALLOYS = 25000
					TECH_1 = giga_tech_lunar_assembly
				}
			}
			lunar_macroreplicator_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = lunar_macroreplicator_2
					RARE_CRYSTALS = 1000
					VOLATILE_MOTES = 1000
					EXOTIC_GASES = 1000
					UNITY = @giga_giga_unity_cost
					ALLOYS = 35000
					TECH_1 = giga_tech_lunar_assembly
				}
			}
			lunar_macroreplicator_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = lunar_macroreplicator_make_moon
					ENERGY = 20000
					UNITY = @giga_mega_unity_cost
					ALLOYS = 30000
					TECH_1 = giga_tech_lunar_assembly
				}
			}
			moon_printer_orbital_mass_harvester_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = moon_printer_orbital_mass_harvester_1
					TECH_1 = giga_tech_planetary_matter_harvesting
				}
			}
			nicoll_beam_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nicoll_beam_1
					UNITY = @giga_giga_unity_cost
					ALLOYS = 15000
					TECH_1 = giga_tech_ndb_1
				}
			}
			nicoll_beam_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nicoll_beam_2
					UNITY = @giga_giga_unity_cost
					ALLOYS = 35000
					TECH_1 = giga_tech_ndb_2
				}
			}
			nicoll_beam_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nicoll_beam_3
					UNITY = @giga_giga_unity_cost
					ALLOYS = 30000
					TECH_1 = giga_tech_ndb_3
				}
			}
			nicoll_beam_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nicoll_beam_4
					UNITY = @giga_giga_unity_cost
					ALLOYS = 27000
					TECH_1 = giga_tech_ndb_4
				}
			}
			nicoll_beam_menu = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nicoll_beam_ready
				}
			}
			nicoll_beam_ready = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nicoll_beam_targetting
				}
			}
			nidavellir_forge_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nidavellir_forge_1
					UNITY = @giga_giga_unity_cost
					ALLOYS = 15000
					TECH_1 = giga_tech_nidavellir
				}
			}
			nidavellir_forge_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nidavellir_forge_2
					UNITY = @giga_giga_unity_cost
					ALLOYS = 20000
					TECH_1 = giga_tech_nidavellir
				}
			}
			nidavellir_forge_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nidavellir_forge_3
					UNITY = @giga_giga_unity_cost
					ALLOYS = 30000
					TECH_1 = giga_tech_nidavellir
				}
			}
			nidavellir_forge_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nidavellir_forge_4
					UNITY = @giga_giga_unity_cost
					ALLOYS = 40000
					TECH_1 = giga_tech_nidavellir
				}
			}
			war_system_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_system_1
					UNITY = @giga_tera_unity_cost
					ALLOYS = 100000
					TECH_1 = giga_tech_war_system_1
					TECH_2 = giga_tech_war_system_2
				}
			}
			war_system_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_system_2
					UNITY = @giga_tera_unity_cost
					ALLOYS = 100000
					TECH_1 = giga_tech_war_system_1
					TECH_2 = giga_tech_war_system_2
					TECH_3 = giga_tech_war_system_3
				}
			}
			war_system_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_system_3
					UNITY = @giga_tera_unity_cost
					ALLOYS = 100000
					TECH_1 = giga_tech_war_system_1
					TECH_2 = giga_tech_war_system_2
					TECH_3 = giga_tech_war_system_3
					TECH_4 = giga_tech_war_system_4
				}
			}
			war_system_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_system_4
					UNITY = @giga_tera_unity_cost
					ALLOYS = 100000
					TECH_1 = giga_tech_war_system_1
					TECH_2 = giga_tech_war_system_2
					TECH_3 = giga_tech_war_system_3
					TECH_4 = giga_tech_war_system_4
					TECH_5 = giga_tech_war_system_5
				}
			}
			war_system_4 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = war_system_5
					UNITY = @giga_tera_unity_cost
					ALLOYS = 100000
					TECH_1 = giga_tech_war_system_1
					TECH_2 = giga_tech_war_system_2
					TECH_3 = giga_tech_war_system_3
					TECH_4 = giga_tech_war_system_4
					TECH_5 = giga_tech_war_system_5
					TECH_6 = giga_tech_war_system_6
				}
			}
			birch_world_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = birch_world_1
					VOLATILE_MOTES = 2500
					EXOTIC_GASES = 2500
					RARE_CRYSTALS = 2500
					UNITY = @giga_tera_unity_cost
					ALLOYS = 300000
					TECH_1 = giga_tech_birch_world_1
				}
			}
			birch_world_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = birch_world_2
					VOLATILE_MOTES = 5000
					EXOTIC_GASES = 5000
					RARE_CRYSTALS = 5000
					UNITY = @giga_tera_unity_cost
					ALLOYS = 450000
					TECH_1 = giga_tech_birch_world_1
				}
			}
			birch_world_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = birch_world_3
					VOLATILE_MOTES = 7500
					EXOTIC_GASES = 7500
					RARE_CRYSTALS = 7500
					UNITY = @giga_tera_unity_cost
					ALLOYS = 600000
					TECH_1 = giga_tech_birch_world_1
				}
			}
			quasi_stellar_obliterator_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = quasi_stellar_obliterator_1
					UNITY = @giga_tera_unity_cost
					ALLOYS = 250000
					TECH_1 = giga_tech_quasi_stellar_2
				}
			}
			quasi_stellar_obliterator_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = quasi_stellar_obliterator_2
					VOLATILE_MOTES = 2500
					EXOTIC_GASES = 2500
					RARE_CRYSTALS = 2500
					UNITY = @giga_tera_unity_cost
					ALLOYS = 300000
					TECH_1 = giga_tech_quasi_stellar_3
				}
			}
			quasi_stellar_obliterator_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = quasi_stellar_obliterator_3
					VOLATILE_MOTES = 5000
					EXOTIC_GASES = 5000
					RARE_CRYSTALS = 5000
					UNITY = @giga_tera_unity_cost
					ALLOYS = 325000
					TECH_1 = giga_tech_quasi_stellar_4
				}
			}
			quasi_stellar_obliterator_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = quasi_stellar_obliterator_4
					VOLATILE_MOTES = 7500
					EXOTIC_GASES = 7500
					RARE_CRYSTALS = 7500
					UNITY = @giga_tera_unity_cost
					ALLOYS = 350000
					TECH_1 = giga_tech_quasi_stellar_5
				}
			}
			quasi_stellar_obliterator_4 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = quasi_stellar_obliterator_5
					VOLATILE_MOTES = 10000
					EXOTIC_GASES = 10000
					RARE_CRYSTALS = 10000
					UNITY = @giga_tera_unity_cost
					ALLOYS = 400000
					TECH_1 = giga_tech_quasi_stellar_6
				}
			}
			quasi_stellar_obliterator_5 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = quasi_stellar_obliterator_6
					TECH_1 = giga_tech_quasi_stellar_2
				}
			}
			supermassive_ehof_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = supermassive_ehof_1
					GIGA_SR_SENTIENT_METAL = 20000
					VOLATILE_MOTES = 2500
					EXOTIC_GASES = 2500
					RARE_CRYSTALS = 2500
					UNITY = @giga_tera_unity_cost
					ALLOYS = 300000
					TECH_1 = giga_tech_supermassive_ehof
				}
			}
			supermassive_ehof_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = supermassive_ehof_2
					GIGA_SR_SENTIENT_METAL = 10000
					GIGA_SR_NEGATIVE_MASS = 10000
					VOLATILE_MOTES = 2500
					EXOTIC_GASES = 2500
					RARE_CRYSTALS = 2500
					UNITY = @giga_tera_unity_cost
					ALLOYS = 300000
					TECH_1 = giga_tech_supermassive_ehof
				}
			}
			# supermassive_ehof_2 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = supermassive_ehof_3
			# 		GIGA_SR_NEGATIVE_MASS = 20000
			# 		ENERGY = 1000000
			# 		UNITY = @giga_tera_unity_cost
			# 		ALLOYS = 50000
			# 		TECH_1 = giga_tech_supermassive_ehof
			# 	}
			# }
			# supermassive_ehof_2 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = supermassive_ehof_3_no_catapult
			# 		GIGA_SR_NEGATIVE_MASS = 20000
			# 		ENERGY = 1000000
			# 		UNITY = @giga_tera_unity_cost
			# 		ALLOYS = 50000
			# 		TECH_1 = giga_tech_supermassive_ehof
			# 	}
			# }
			blokkat_gigarelay_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = blokkat_gigarelay_1
					ALLOYS = 300000
					RARE_CRYSTALS = 10000
					EXOTIC_GASES = 10000
					VOLATILE_MOTES = 10000
					UNITY = @giga_tera_unity_cost
					TECH_1 = giga_tech_blokkat_gigarelay_core
				}
			}
			blokkat_gigarelay_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = blokkat_gigarelay_2
					ALLOYS = 600000
					RARE_CRYSTALS = 20000
					EXOTIC_GASES = 20000
					VOLATILE_MOTES = 20000
					UNITY = @giga_tera_unity_cost
					TECH_1 = giga_tech_blokkat_gigarelay_frame
				}
			}
			blokkat_prison_1_filled = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = blokkat_prison_1_manage
				}
			}
			blokkat_shield_killer_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = blokkat_shield_killer_1
					ALLOYS = 200000
					ENERGY = 100000
					UNITY = @giga_tera_unity_cost
					TECH_1 = giga_tech_blokkat_mega_stage_1
				}
			}
			blokkat_shield_killer_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = blokkat_shield_killer_2
					ALLOYS = 400000
					ENERGY = 200000
					UNITY = @giga_tera_unity_cost
					TECH_1 = giga_tech_blokkat_mega_stage_2
				}
			}
			blokkat_shield_killer_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = blokkat_shield_killer_3
					ALLOYS = 600000
					ENERGY = 400000
					UNITY = @giga_tera_unity_cost
					TECH_1 = giga_tech_blokkat_mega_stage_3
				}
			}
			# blokkat_shield_killer_3 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = blokkat_shield_killer_4
			# 		ALLOYS = 500000
			# 		ENERGY = 1000000
			# 		UNITY = @giga_tera_unity_cost
			# 		TECH_1 = giga_tech_blokkat_mega_stage_4
			# 	}
			# }
			# blokkat_shield_killer_3 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = blokkat_shield_killer_activate
			# 		TECH_1 = giga_tech_blokkat_mega_stage_3
			# 	}
			# }
			blokkat_shield_killer_4 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = blokkat_shield_killer_activate_chrono
					TECH_1 = giga_tech_blokkat_mega_stage_4
				}
			}
			# blokkat_shipyard_0 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = blokkat_shipyard_build_evictors
			# 	}
			# }
			# blokkat_shipyard_0 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = blokkat_shipyard_build_custodians
			# 	}
			# }
			# blokkat_shipyard_0 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = blokkat_shipyard_build_terminator
			# 	}
			# }
			# blokkat_shipyard_0 = { 
			# 	auto_upgrade_megastructure = { 
			# 		UPGRADE_TO = blokkat_shipyard_build_dismantler
			# 	}
			# }
			blokkat_star_fix_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = blokkat_star_fix_1
					ALLOYS = 75000
					ENERGY = 200000
					TECH_1 = giga_tech_blokkat_fix_systems
				}
			}
			blokkat_star_fix_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = blokkat_star_fix_active
					ENERGY = 400000
					TECH_1 = giga_tech_blokkat_fix_systems
				}
			}
		}
	}
	else = {
		switch = {
			trigger = is_megastructure_type
			#00_ring_world
			ring_world_1 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = ring_world_2_intermediate
					ALLOYS = 10000
					BIO = 10000
					TECH_1 = tech_ring_world
				}
			}
			ring_world_2_intermediate = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = ring_world_2
					TECH_1 = tech_ring_world
				}
			}
			ring_world_2 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = ring_world_3_intermediate
					ALLOYS = 10000
					BIO = 10000
					TECH_1 = tech_ring_world
				}
			}
			ring_world_ruined = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = ring_world_restored
					ALLOYS = 10000
					BIO = 10000
					TECH_1 = tech_mega_engineering
				}
			}
			#01_dyson_sphere
			dyson_sphere_0 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = dyson_sphere_1
					ALLOYS = 10000
					BIO = 10000
					UNITY = 5000
					TECH_1 = tech_dyson_sphere
				}
			}
			dyson_sphere_1 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = dyson_sphere_2
					ALLOYS = 10000
					BIO = 10000
					UNITY = 5000
					TECH_1 = tech_dyson_sphere
				}
			}
			dyson_sphere_2 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = dyson_sphere_3
					ALLOYS = 10000
					BIO = 10000
					UNITY = 5000
					TECH_1 = tech_dyson_sphere
				}
			}
			dyson_sphere_3 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = dyson_sphere_4
					ALLOYS = 10000
					BIO = 10000
					UNITY = 5000
					TECH_1 = tech_dyson_sphere
				}
			}
			dyson_sphere_4 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = dyson_sphere_5
					ALLOYS = 10000
					BIO = 10000
					UNITY = 5000
					TECH_1 = tech_dyson_sphere
				}
			}
			#02_spy_orb
			spy_orb_0 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = spy_orb_1
					ALLOYS = 10000
					BIO = 10000
					UNITY = 2500
					TECH_1 = tech_sentry_array
				}
			}
			spy_orb_1 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = spy_orb_2
					ALLOYS = 10000
					BIO = 10000
					UNITY = 2500
					TECH_1 = tech_sentry_array
				}
			}
			spy_orb_2 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = spy_orb_3
					ALLOYS = 10000
					BIO = 10000
					UNITY = 2500
					TECH_1 = tech_sentry_array
				}
			}
			spy_orb_3 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = spy_orb_4
					ALLOYS = 10000
					BIO = 10000
					UNITY = 2500
					TECH_1 = tech_sentry_array
				}
			}
			spy_orb_ruined = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = spy_orb_restored
					ALLOYS = 15000
					BIO = 10000
					UNITY = 3500
					TECH_1 = tech_mega_engineering
				}
			}
			#03_think_tank
			think_tank_0 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = think_tank_1
					ALLOYS = 15000
					BIO = 15000
					UNITY =  5000
					TECH_1 = tech_science_nexus
				}
			}
			think_tank_1 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = think_tank_2
					ALLOYS = 15000
					BIO = 15000
					UNITY = 5000
					TECH_1 = tech_science_nexus
				}
			}
			think_tank_2 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = think_tank_3
					ALLOYS = 15000
					BIO = 15000
					UNITY = 5000
					TECH_1 = tech_science_nexus
				}
			}
			# think_tank_3 = {
			# 	auto_upgrade_megastructure = {
			# 		UPGRADE_TO = think_tank_4
			# 		ALLOYS = 15000
			# 		UNITY = 5000
			# 		TECH_1 = tech_science_nexus
			# 	}
			# }
			think_tank_ruined = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = think_tank_restored
					ALLOYS = 15000
					BIO = 15000
					UNITY = 3200
					TECH_1 = tech_mega_engineering
				}
			}
			#05_gateways
			gateway_0 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = gateway_final
					ALLOYS = 2500
					BIO = 2500
					ENERGY = 6000
					TECH_1 = tech_gateway_activation
				}
			}
			gateway_ruined = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = gateway_restored
					ALLOYS = 2500
					BIO = 2500
					ENERGY = 6000
					TECH_1 = tech_gateway_activation
				}
			}
			#06_matter_decompressor
			matter_decompressor_0 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = matter_decompressor_1
					ALLOYS = 12500
					BIO = 12500
					UNITY = 5000
					TECH_1 = tech_matter_decompressor
				}
			}
			matter_decompressor_1 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = matter_decompressor_2
					ALLOYS = 12500
					BIO = 12500
					UNITY = 5000
					TECH_1 = tech_matter_decompressor
				}
			}
			matter_decompressor_2 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = matter_decompressor_3
					ALLOYS = 12500
					BIO = 12500
					UNITY = 5000
					TECH_1 = tech_matter_decompressor
				}
			}
			matter_decompressor_3 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = matter_decompressor_4
					ALLOYS = 12500
					BIO = 12500
					UNITY = 5000
					TECH_1 = tech_matter_decompressor
				}
			}
			matter_decompressor_ruined = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = matter_decompressor_restored
					ALLOYS = 20000
					BIO = 20000
					UNITY = 7500
					TECH_1 = tech_mega_engineering
				}
			}
			#07_strategic_coordination_center
			strategic_coordination_center_0 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = strategic_coordination_center_1
					ALLOYS = 15000
					BIO = 15000
					UNITY = 2500
					TECH_1 = tech_strategic_coordination
				}
			}
			strategic_coordination_center_1 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = strategic_coordination_center_2 
					ALLOYS = 15000
					BIO = 15000
					UNITY = 2500
					TECH_1 = tech_strategic_coordination
				}
			}
			strategic_coordination_center_2 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = strategic_coordination_center_3
					ALLOYS = 15000
					BIO = 15000
					UNITY = 2500
					TECH_1 = tech_strategic_coordination
				}
			}
			strategic_coordination_center_ruined = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = strategic_coordination_center_restored
					ALLOYS = 15000
					BIO = 15000
					UNITY = 3200
					TECH_1 = tech_mega_engineering
				}
			}
			#08_mega_art_installation
			mega_art_installation_0 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = mega_art_installation_1
					ALLOYS = 15000
					BIO = 15000
					UNITY = 2500
					TECH_1 = tech_mega_art
				}
			}
			mega_art_installation_1 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = mega_art_installation_2
					ALLOYS = 15000
					BIO = 15000
					UNITY = 2500
					TECH_1 = tech_mega_art
				}
			}
			mega_art_installation_2 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = mega_art_installation_3
					ALLOYS = 15000
					BIO = 15000
					UNITY = 2500
					TECH_1 = tech_mega_art
				}
			}
			mega_art_installation_3 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = mega_art_installation_4
					UNITY = 2500
					MINOR_ARTIFACTS = 100
					TECH_1 = tech_mega_art
				}
			}
			mega_art_installation_ruined = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = mega_art_installation_restored
					ALLOYS = 15000
					BIO = 15000
					UNITY = 3200
					TECH_1 = tech_mega_engineering
				}
			}
			#09_interstellar_assembly
			interstellar_assembly_0 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = interstellar_assembly_1
					ALLOYS = 10000
					BIO = 10000
					UNITY = 2500
					TECH_1 = tech_interstellar_assembly
				}
			}
			interstellar_assembly_1 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = interstellar_assembly_2
					ALLOYS = 10000
					BIO = 10000
					UNITY = 2500
					TECH_1 = tech_interstellar_assembly
				}
			}
			interstellar_assembly_2 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = interstellar_assembly_3
					ALLOYS = 10000
					BIO = 10000
					UNITY = 2500
					TECH_1 = tech_interstellar_assembly
				}
			}
			interstellar_assembly_3 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = interstellar_assembly_4
					ALLOYS = 10000
					BIO = 10000
					UNITY = 2500
					TECH_1 = tech_interstellar_assembly
				}
			}
			interstellar_assembly_ruined = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = interstellar_assembly_restored
					ALLOYS = 10000
					BIO = 10000
					UNITY = 3200
					TECH_1 = tech_mega_engineering
				}
			}
			#11_mega_shipyard
			mega_shipyard_0 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = mega_shipyard_1
					ALLOYS = 10000
					BIO = 10000
					UNITY = 2500
					TECH_1 = tech_mega_shipyard
				}
			}
			mega_shipyard_1 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = mega_shipyard_2
					ALLOYS = 10000
					BIO = 10000
					UNITY = 2500
					TECH_1 = tech_mega_shipyard
				}
			}
			mega_shipyard_2 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = mega_shipyard_3
					ALLOYS = 10000
					BIO = 10000
					UNITY = 2500
					TECH_1 = tech_mega_shipyard
				}
			}
			mega_shipyard_ruined = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = mega_shipyard_restored
					ALLOYS = 10000
					BIO = 10000
					UNITY = 3200
					TECH_1 = tech_mega_engineering
				}
			}
			#12_crisis_sphere
			#13_quantum_catapult
			quantum_catapult_0 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = quantum_catapult_1
					ALLOYS = 10000
					BIO = 10000
					TECH_1 = tech_quantum_catapult
				}
			}
			quantum_catapult_1 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = quantum_catapult_2 
					ALLOYS = 10000
					BIO = 10000
					TECH_1 = tech_quantum_catapult
				}
			}
			quantum_catapult_2 = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = quantum_catapult_3
					ALLOYS = 10000
					BIO = 10000
					TECH_1 = tech_quantum_catapult
				}
			}
			quantum_catapult_ruined = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = quantum_catapult_restored
					ALLOYS = 10000
					BIO = 10000
					TECH_1 = tech_mega_engineering
				}
			}
			#14_hyper_relay
			hyper_relay_ruined = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = hyper_relay_restored
					ALLOYS = 500
					BIO = 500
					ENERGY = 500
					RARE_CRYSTALS = 100
					TECH_1 = tech_hyper_relays
					TECH_2 = tech_hyper_drive_2
				}
			}
			#15_orbital_ring
			orbital_ring_ruined = {
				auto_upgrade_megastructure = {
					UPGRADE_TO = orbital_ring_restored
					ALLOYS = 500
					BIO = 500
					INFLUENCE = 50
					TECH_1 = tech_orbital_ring_tier_1
				}
			}
		}
	}
	if = {
		limit = {
			prev = {
				has_global_flag = has_nsc_active
			}
		}
		switch = {
			trigger = is_megastructure_type
			mega_shipyard_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = mega_shipyard_1
					UNITY = 2500
					ALLOYS = 10000
					BIO = 10000
					TECH_1 = tech_mega_shipyard
				}
			}
			mega_shipyard_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = mega_shipyard_2
					UNITY = 2500
					ALLOYS = 10000
					BIO = 10000
					TECH_1 = tech_mega_shipyard
				}
			}
			mega_shipyard_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = mega_shipyard_3
					UNITY = 2500
					ALLOYS = 10000
					BIO = 10000
					TECH_1 = tech_mega_shipyard
				}
			}
			mega_shipyard_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = mega_shipyard_restored
					UNITY = 3200
					ALLOYS = 10000
					BIO = 10000
					TECH_1 = tech_mega_engineering
				}
			}
			nsc_flagship_shipyard = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nsc_flagship_shipyard_complete
					ALLOYS = 2000
					UNITY = 2000
					TECH_1 = tech_Flagship_1
				}
			}
			nsc_galactic_mall_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nsc_galactic_mall_1
					ALLOYS = 15000
					UNITY = 1000
					BIO = 15000
				}
			}
			nsc_headquarters_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nsc_headquarters_1
					ALLOYS = 15000
					UNITY = 1500
					BIO = 15000
				}
			}
			nsc_hospital_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nsc_hospital_1
					ALLOYS = 15000
					UNITY = 2500
					BIO = 15000
				}
			}
			nsc_hospital_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nsc_hospital_2
					ALLOYS = 15000
					UNITY = 2500
					BIO = 15000
				}
			}
			nsc_hospital_2 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nsc_hospital_3
					ALLOYS = 15000
					UNITY = 2500
					BIO = 15000
				}
			}
			nsc_hospital_3 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nsc_hospital_4
					ALLOYS = 15000
					UNITY = 2500
					BIO = 15000
				}
			}
			nsc_hospital_4 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nsc_hospital_5
					ALLOYS = 15000
					UNITY = 2500
					BIO = 15000
				}
			}
			hyperlane_creator_emisor_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = hyperlane_creator_emisor_1
					ALLOYS = 2000
					ENERGY = 2000
					UNITY = 500
					TECH_1 = tech_hyperlane_generation
				}
			}
			hyperlane_creator_emisor_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = hyperlane_creator_emisor_2
					ENERGY = 10000
					UNITY = 500
					TECH_1 = tech_hyperlane_generation
				}
			}
			hyperlane_creator_receptor_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = hyperlane_creator_receptor_1
					ALLOYS = 2000
					ENERGY = 2000
					UNITY = 500
					BIO = 2000
					TECH_1 = tech_hyperlane_generation
				}
			}
			hyperlane_remover_emisor_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = hyperlane_remover_emisor_1
					ALLOYS = 2000
					ENERGY = 2000
					UNITY = 500
					BIO = 2000
					TECH_1 = tech_hyperlane_generation
				}
			}
			hyperlane_remover_emisor_1 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = hyperlane_remover_emisor_2
					ENERGY = 10000
					UNITY = 500
					TECH_1 = tech_hyperlane_generation
				}
			}
			hyperlane_remover_receptor_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = hyperlane_remover_receptor_1
					ALLOYS = 2000
					ENERGY = 2000
					UNITY = 500
					BIO = 2000
					TECH_1 = tech_hyperlane_generation
				}
			}
			nsc_strategic_resource_factory_0 = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = nsc_strategic_resource_factory_1
					ALLOYS = 30000
					UNITY = 2500
					BIO = 30000
				}
			}
		}
	}
	if = {
		limit = {
			prev = {
				has_global_flag = acot_activated
			}
		}
		switch = {
			trigger = is_megastructure_type
			acot_dark_matter_obelisk_core_portal = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_dark_matter_obelisk_core
					ENERGY = 10000
					TECH_1 = tech_precursor_enigmalith
				}
			}
			acot_dark_matter_obelisk_core = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_dark_matter_obelisk_core_advanced
					ENERGY = 10000
					ALLOYS = 20000
					SR_DARK_MATTER = 2000
					ACOT_SR_DARK_ENERGY = 2000
					TECH_1 = tech_precursor_enigmalith
				}
			}
			acot_dark_matter_obelisk_core_advanced = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_dark_matter_obelisk_core_super
					ENERGY = 10000
					ALLOYS = 40000
					SR_DARK_MATTER = 4000
					ACOT_SR_DARK_ENERGY = 4000
					TECH_1 = tech_precursor_enigmalith
				}
			}
			acot_dark_matter_obelisk_core_portal_ae = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_dark_matter_obelisk_core_ae
					ENERGY = 10000
					TECH_1 = tech_precursor_enigmalith_ae
				}
			}
			acot_dark_matter_obelisk_core_ae = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_dark_matter_obelisk_core_advanced_ae
					ENERGY = 10000
					ALLOYS = 20000
					SR_DARK_MATTER = 10000
					ACOT_SR_DARK_ENERGY = 10000
					TECH_1 = tech_precursor_enigmalith_ae
				}
			}
			acot_dark_matter_obelisk_core_advanced_ae = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_dark_matter_obelisk_core_super_ae
					ENERGY = 10000
					ALLOYS = 40000
					SR_DARK_MATTER = 20000
					ACOT_SR_DARK_ENERGY = 20000
					TECH_1 = tech_precursor_enigmalith_ae
				}
			}
			acot_dark_matter_obelisk_core_portal_se = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_dark_matter_obelisk_core_se
					ENERGY = 10000
					TECH_1 = tech_precursor_enigmalith_se
				}
			}
			acot_dark_matter_obelisk_core_se = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_dark_matter_obelisk_core_advanced_se
					ENERGY = 10000
					ALLOYS = 20000
					SR_DARK_MATTER = 10000
					ACOT_SR_DARK_ENERGY = 10000
					TECH_1 = tech_precursor_enigmalith_se
				}
			}
			acot_dark_matter_obelisk_core_advanced_se = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_dark_matter_obelisk_core_super_se
					ENERGY = 10000
					ALLOYS = 40000
					SR_DARK_MATTER = 20000
					ACOT_SR_DARK_ENERGY = 20000
					TECH_1 = tech_precursor_enigmalith_se
				}
			}
			acot_dark_matter_obelisk_core_portal_oe = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_dark_matter_obelisk_core_oe
					TECH_1 = tech_precursor_enigmalith_oe
				}
			}
			acot_dark_matter_obelisk_core_oe = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_dark_matter_obelisk_core_advanced_oe
					ALLOYS = 5000
					ACOT_SR_LIGHT_MATTER = 500
					TECH_1 = tech_precursor_enigmalith_oe
				}
			}
			acot_dark_matter_obelisk_core_advanced_oe = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_dark_matter_obelisk_core_super_oe
					ALLOYS = 10000
					ACOT_SR_LIGHT_MATTER = 10
					TECH_1 = tech_precursor_enigmalith_oe
				}
			}
			acot_amerigo = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_amerigo_ae
					ALLOYS = 250000
					SR_DARK_MATTER = 25000
					ACOT_SR_DARK_ENERGY = 25000
					TECH_1 = tech_precursor_amerigo_ae
				}
			}
			acot_amerigo_ae = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_amerigo_se
					SR_DARK_MATTER = 100000
					ACOT_SR_DARK_ENERGY = 100000
					TECH_1 = tech_precursor_amerigo_se
				}
			}
			acot_amerigo_se = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_amerigo_oe
					ACOT_SR_LIGHT_MATTER = 1000
					TECH_1 = tech_precursor_amerigo_oe
				}
			}
			acot_precursor_citadel_site = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_citadel_base
				}
			}
			acot_precursor_sigma_citadel_site = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_sigma_citadel_base
				}
			}
			acot_precursor_phanon_citadel_site = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_phanon_citadel_base
				}
			}
			acot_precursor_platform_l_site = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_platform_l_complete
					TECH_1 = tech_precursor_construcor
				}
			}
			acot_precursor_platform_m_site = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_platform_m_complete
					TECH_1 = tech_precursor_construcor
				}
			}
			acot_precursor_colossus_site = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_colossus_base
					TECH_1 = tech_precursor_colossus
				}
			}
			acot_precursor_colossus_base = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_colossus_stage_one
					ALLOYS = 500000
					UNITY = 100000
					SR_DARK_MATTER = 50000
					ACOT_SR_DARK_ENERGY = 50000
					TECH_1 = tech_precursor_colossus
				}
			}
			acot_precursor_colossus_stage_one = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_colossus_stage_two
					ALLOYS = 500000
					UNITY = 100000
					SR_DARK_MATTER = 50000
					ACOT_SR_DARK_ENERGY = 50000
					TECH_1 = tech_precursor_colossus
				}
			}
			acot_precursor_colossus_stage_two = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_colossus_final
					ALLOYS = 500000
					UNITY = 100000
					SR_DARK_MATTER = 50000
					ACOT_SR_DARK_ENERGY = 50000
					TECH_1 = tech_precursor_colossus
				}
			}
			acot_world_shaper_planet_portal = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_world_shaper_planet_core
				}
			}
			acot_world_shaper_planet_core = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_world_shaper_planet_stage_two
				}
			}
			acot_precursor_orbital_ring_assembly = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_orbital_ring_mega
					TECH_1 = tech_precursor_orbital_ring
				}
			}
			acot_precursor_orbital_ring_mega_ruined = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_orbital_ring_mega_restored
					ALLOYS = 5000
					SR_DARK_MATTER = 5000
					ACOT_SR_DARK_ENERGY = 5000
					TECH_1 = tech_precursor_orbital_ring
				}
			}
			acot_precursor_science_nexus_portal = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_science_nexus_stage_one
					TECH_1 = tech_precursor_nexus
				}
			}
			acot_precursor_science_nexus_stage_one = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_science_nexus_stage_two
					TECH_1 = tech_precursor_nexus
				}
			}
			acot_precursor_science_nexus_stage_two = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_science_nexus_stage_three
					TECH_1 = tech_precursor_nexus
				}
			}
			acot_precursor_strategy_center_portal = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_strategy_center_stage_one
					TECH_1 = tech_precursor_strategy_center
				}
			}
			acot_precursor_strategy_center_stage_one = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_strategy_center_stage_two
					TECH_1 = tech_precursor_strategy_center
				}
			}
			acot_precursor_strategy_center_stage_two = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_strategy_center_stage_three
					TECH_1 = tech_precursor_strategy_center
				}
			}
			acot_precursor_sentry_orb_portal = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_sentry_orb_stage_one
					TECH_1 = tech_precursor_spyorb
				}
			}
			acot_precursor_sentry_orb_stage_one = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_sentry_orb_stage_two
					TECH_1 = tech_precursor_spyorb
				}
			}
			acot_precursor_sentry_orb_stage_two = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_sentry_orb_stage_three
					TECH_1 = tech_precursor_spyorb
				}
			}
			acot_precursor_dyson_sphere_portal = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_dyson_sphere_stage_one
					TECH_1 = tech_precursor_dyson_sphere
				}
			}
			acot_precursor_dyson_sphere_stage_one = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_dyson_sphere_stage_two
					TECH_1 = tech_precursor_enigmalith
				}
			}
			acot_precursor_mega_shipyard_portal = { 
				auto_upgrade_megastructure = { 
					UPGRADE_TO = acot_precursor_mega_shipyard
					TECH_1 = tech_precursor_mega_shipyard
				}
			}
		}
	}
}

auto_upgrade_megastructure = {
	[[BIO]
		if = {
			limit = {
				prev = {
					country_uses_bio_ships = yes
				}
			}
			set_megastructure_flag = auto_upgrading_bio_megastructure_flag
		}
	]

	if = {
		limit = {
			prev = {
				[[TECH_1]
					has_technology = $TECH_1$
				]
				[[TECH_2]
					has_technology = $TECH_2$
				]
				[[TECH_3]
					has_technology = $TECH_3$
				]
				[[TECH_4]
					has_technology = $TECH_4$
				]
				[[TECH_5]
					has_technology = $TECH_5$
				]
				[[TECH_6]
					has_technology = $TECH_6$
				]
				[[BIO]
					if = {
						limit = {
							country_uses_bio_ships = yes
						}
						resource_stockpile_compare = {
							resource = food
							value >= $BIO$
							mult = value:posivite_mega_upgrading_bio_cost
						}
					}
				]
				[[ALLOYS]
					resource_stockpile_compare = {
						resource = alloys
						value >= $ALLOYS$
						mult = value:posivite_mega_upgrading_alloy_cost
					}
				]
				[[UNITY]
					resource_stockpile_compare = {
						resource = unity
						value >= $UNITY$
						mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
					}
				]
				[[FOOD]
					resource_stockpile_compare = {
						resource = food
						value >= $FOOD$
						mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
					}
				]
				[[MINERALS]
					resource_stockpile_compare = {
						resource = minerals
						value >= $MINERALS$
						mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
					}
				]
				[[ENERGY]
					resource_stockpile_compare = {
						resource = energy
						value >= $ENERGY$
						mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
					}
				]
				[[INFLUENCE]
					resource_stockpile_compare = {
						resource = influence
						value >= $INFLUENCE$
						mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
					}
				]
                [[EXOTIC_GASES]
                    resource_stockpile_compare = {
                        resource = exotic_gases
                        value >= $EXOTIC_GASES$
                        mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
                    }
                ]
                [[RARE_CRYSTALS]
                    resource_stockpile_compare = {
                        resource = rare_crystals
                        value >= $RARE_CRYSTALS$
                        mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
                    }
                ]
                [[VOLATILE_MOTES]
                    resource_stockpile_compare = {
                        resource = volatile_motes
                        value >= $VOLATILE_MOTES$
                        mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
                    }
                ]
				[[SR_LIVING_METAL]
					resource_stockpile_compare = {
						resource = sr_living_metal
						value >= $SR_LIVING_METAL$
						mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
					}
				]
				[[SR_ZRO]
					resource_stockpile_compare = {
						resource = sr_zro
						value >= $SR_ZRO$
						mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
					}
				]
				[[SR_DARK_MATTER]
					resource_stockpile_compare = {
						resource = sr_dark_matter
						value >= $SR_DARK_MATTER$
						mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
					}
				]
                [[MINOR_ARTIFACTS]
                    resource_stockpile_compare = {
                        resource = minor_artifacts
                        value >= $MINOR_ARTIFACTS$
                        mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
                    }
                ]
                [[GIGA_SR_SENTIENT_METAL]
                    resource_stockpile_compare = {
                        resource = giga_sr_sentient_metal
                        value >= $GIGA_SR_SENTIENT_METAL$
                        mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
                    }
                ]
                [[GIGA_SR_NEGATIVE_MASS]
                    resource_stockpile_compare = {
                        resource = giga_sr_negavive_mass
                        value >= $GIGA_SR_NEGATIVE_MASS$
                        mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
                    }
                ]
                [[EHOF_SR_SENTIENT_METAL]
                    resource_stockpile_compare = {
                        resource = ehof_sr_sentient_metal
                        value >= $EHOF_SR_SENTIENT_METAL$
                        mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
                    }
                ]
                [[EHOF_SR_SENTIENT_MASS]
                    resource_stockpile_compare = {
                        resource = ehof_sr_sentient_metal
                        value >= $EHOF_SR_SENTIENT_MASS$
                        mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
                    }
                ]
                [[EHOF_SR_NEGATIVE_MASS]
                    resource_stockpile_compare = {
                        resource = ehof_sr_negative_mass
                        value >= $EHOF_SR_NEGATIVE_MASS$
                        mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
                    }
                ]
                [[SR_SOLAR_ENERGY]
                    resource_stockpile_compare = {
                        resource = sr_solar_energy
                        value >= $SR_SOLAR_ENERGY$
                        mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
                    }
                ]
				[[ACOT_SR_DARK_ENERGY]
					resource_stockpile_compare = {
						resource = acot_sr_dark_energy
						value >= $ACOT_SR_DARK_ENERGY$
						mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
					}
				]
				[[ACOT_SR_LIGHT_MATTER]
					resource_stockpile_compare = {
						resource = acot_sr_light_matter
						value >= $ACOT_SR_LIGHT_MATTER$
						mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
					}
				]
				[[ACOT_SR_STELLARITE]
					resource_stockpile_compare = {
						resource = acot_sr_light_matter
						value >= $ACOT_SR_STELLARITE$
						mult = value:positive_modifier_mult|MODIFIER|megastructures_cost_mult|
					}
				]
			}
		}
		upgrade_megastructure_to = $UPGRADE_TO$
		prev = {
			create_message = {
				type = AUTO_MEGA_MESSAGE_TYPE
				localization = AUTO_MEGA_MESSAGE_TYPE_DESC
				days = 30
				target = prev.solar_system
				variable = {
					type = name
					localization = MEGASTRUCTURE
					scope = prev
				}
				variable = {
					type = name
					localization = SYSTEM
					scope = prev.solar_system
				}
			}
			[[BIO]
				if = {
					limit = {
						country_uses_bio_ships = yes
					}
					add_resource = {
						food = $BIO$
						mult = value:negative_mega_upgrading_bio_cost
					}
				}
			]
			[[ALLOYS]
				add_resource = {
					alloys = $ALLOYS$
					mult = value:negative_mega_upgrading_alloy_cost
				}
			]
			[[UNITY]
				add_resource = {
					unity = $UNITY$
					mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
				}
			]
			[[FOOD]
				add_resource = {
					food = $FOOD$
					mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
				}
			]
			[[MINERALS]
				add_resource = {
					minerals = $MINERALS$
					mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
				}
			]
			[[ENERGY]
				add_resource = {
					energy = $ENERGY$
					mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
				}
			]
            [[INFLUENCE]
                add_resource = {
                    influence = $INFLUENCE$
                    mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
                }
            ]
            [[EXOTIC_GASES]
                add_resource = {
                    exotic_gases = $EXOTIC_GASES$
                    mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
                }
            ]
            [[RARE_CRYSTALS]
                add_resource = {
                    rare_crystals = $RARE_CRYSTALS$
                    mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
                }
            ]
            [[VOLATILE_MOTES]
                add_resource = {
                    volatile_motes = $VOLATILE_MOTES$
                    mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
                }
            ]
            [[SR_LIVING_METAL]
                add_resource = {
                    sr_living_metal = $SR_LIVING_METAL$
                    mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
                }
            ]
            [[SR_ZRO]
                add_resource = {
                    sr_zro = $SR_ZRO$
                    mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
                }
            ]
            [[SR_DARK_MATTER]
                add_resource = {
                    sr_dark_matter = $SR_DARK_MATTER$
                    mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
                }
            ]
            [[MINOR_ARTIFACTS]
                add_resource = {
                    minor_artifacts = $MINOR_ARTIFACTS$
                    mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
                }
            ]
            [[EHOF_SR_SENTIENT_METAL]
                add_resource = {
                    ehof_sr_sentient_metal = $EHOF_SR_SENTIENT_METAL$
                    mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
                }
            ]
            [[EHOF_SR_SENTIENT_MASS]
                add_resource = {
                    ehof_sr_sentient_mass = $EHOF_SR_SENTIENT_MASS$
                    mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
                }
            ]
            [[EHOF_SR_NEGATIVE_MASS]
                add_resource = {
                    ehof_sr_negative_mass = $EHOF_SR_NEGATIVE_MASS$
                    mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
                }
            ]
			[[SR_SOLAR_ENERGY]
				add_resource = {
					sr_solar_energy = $SR_SOLAR_ENERGY$
					mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
				}
			]
			[[ACOT_SR_DARK_ENERGY]
				add_resource = {
					acot_sr_dark_energy = $ACOT_SR_DARK_ENERGY$
					mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
				}
			]
			[[ACOT_SR_LIGHT_MATTER]
				add_resource = {
					acot_sr_light_matter = $ACOT_SR_LIGHT_MATTER$
					mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
				}
			]
			[[ACOT_SR_STELLARITE]
				add_resource = {
					acot_sr_stellarite = $ACOT_SR_STELLARITE$
					mult = value:negative_modifier_mult|MODIFIER|megastructures_cost_mult|
				}
			]
		}
		break = yes
	}
}