oeo_orbital_drill_build_site_1 = {
    entity = "oeo_ring_entity"
	construction_entity = "oeo_ring_entity"
	portrait = "GFX_megastructure_construction_background"
	place_entity_on_planet_plane = yes
	entity_offset = { x = 0 y = 0 }
	scales_with_planet = yes
	show_in_outliner = yes
	construction_blocks_and_blocked_by = none
	build_time = @oeo_drill1_build_time
	resources = {
		category = megastructures_oeo_kilostructures
		cost = { influence = @oeo_drill1_influence_cost }
		cost = {
			trigger = { country_uses_bio_ships = no }
			alloys = @oeo_drill1_alloy_cost
		}
		cost = {
			trigger = { country_uses_bio_ships = yes }
			alloys = @oeo_drill1_alloy_cost
			mult = 0.5
		}
		cost = {
			trigger = { country_uses_bio_ships = yes }
			food = @oeo_drill1_alloy_cost
			mult = @halved_alloy_to_food_cost_ratio
		}
		upkeep = { trade = @oeo_drill1_trade_upkeep }
	}
	dismantle_cost = {
		category = megastructures
		cost = { energy = @oeo_drill1_alloy_cost }
	}
	dismantle_time = 360
	dismantle_potential = { always = yes }
	dismantle_possible = {
		custom_tooltip = {
			fail_text = "oeo_dismantle_cooldown" 
			NOT = { has_megastructure_flag = oeo_dismantle_cooldown }
		}
	}
	on_dismantle_start = {
		fromfrom.planet = {
			set_planet_flag = oeo_not_cancelled
			planet_event = { id = oeo_individual_dismantle.1 days = 361 }
		}
	}
	on_dismantle_cancel = {
		fromfrom = { set_timed_megastructure_flag = { flag = oeo_dismantle_cooldown days = 360 } }
		fromfrom.planet = { remove_planet_flag = oeo_not_cancelled }
	}
	on_dismantle_complete = {
		from = {
			add_resource = {
				alloys = @oeo_drill1_alloy_cost
				mult = modifier:megastructure_dismantle_refund_mult
			}
		}
	}
	potential = { has_technology = tech_oeo_orbital_drill }
	possible = {
		exists = starbase
		custom_tooltip = {
			fail_text = "requires_inside_border"
			is_inside_border = from
		}
	}
	placement_rules = {
		planet_possible = {
			custom_tooltip = {
				fail_text = "requires_surveyed_planet"
				is_surveyed = {			# prevent leaking habitability information
					who = prev.from
					status = yes
				}
			}
			custom_tooltip = {
				fail_text = "requires_oeo_non_colonized"
				is_colony = no
			}
			custom_tooltip = {
				fail_text = "requires_no_anomaly"
				NOT = { has_anomaly = yes }
			}
			custom_tooltip = {
				fail_text = "requires_no_existing_megastructure"
				NOR = { 
					has_planet_flag = has_megastructure
					has_planet_flag = megastructure
				}
			}
			custom_tooltip = {
				fail_text = "oeo_requires_large_planet"
				NOR = { 
					is_asteroid = yes
					is_star = yes
					is_astral_scar = yes
					is_planet_class = pc_gas_giant
					is_planet_class = pc_shattered
				}
			}
		}
	}
	custom_tooltip_requirements = "oeo_MEGASTRUCTURE_TOOLTIP_REQUIREMENTS_KILOSTRUCTURE_LIMIT"
	ai_weight = {
		factor = 5
		modifier = {
			factor = 0.1
			starbase = { NOT = { has_starbase_size >= starbase_starfortress } }
		}
		modifier = {
			factor = 0.1
			any_neighbor_system = {
				exists = owner
				NOT = {
					owner = { is_same_value = from }
				}
			}
		}
		modifier = {
			factor = 0
		 	from = { has_country_flag = oeo_kilo_cooldown }
		}
	}
	on_build_start = {
		from = { set_timed_country_flag = { flag = oeo_kilo_cooldown days = @oeo_kilo_cooldown_time } }
	}
	on_build_complete = {
		fromfrom.planet = {
			set_planet_flag = shroud_storm_changed
			set_planet_flag = has_megastructure
			set_planet_flag = has_oeo_planet_mega
			set_planet_flag = megastructure
			set_planet_flag = oeo_drill
			if = {
				limit = { has_orbital_station = yes }
				orbital_station = {
					dismantle = yes
				}
			}	
		}
	}
}
oeo_orbital_drill_minerals = {
	entity = "oeo_orbital_drill_entity"
	construction_entity = "oeo_orbital_drill_entity"
	portrait = "GFX_megastructure_construction_background"
	place_entity_on_planet_plane = yes
	scales_with_planet = yes
	use_planet_resource = yes
	outliner_trigger = {
		exists = owner
		owner = {
			NOT = { has_country_flag = oeo_drill_outliner }
		}
	}
	potential = { has_technology = tech_oeo_orbital_drill }
	construction_blocks_and_blocked_by = none
	dismantle_potential = { always = no }
	dismantle_possible = { always = no }
	upgrade_from = { oeo_orbital_drill_build_site_1 }
	build_time = @oeo_drill2_build_time
	resources = {
		category = megastructures_oeo_kilostructures
		cost = { unity = @oeo_drill2_unity_cost }
		cost = {
			trigger = { country_uses_bio_ships = no }
			alloys = @oeo_drill2_alloy_cost
		}
		cost = {
			trigger = { country_uses_bio_ships = yes }
			alloys = @oeo_drill2_alloy_cost
			mult = 0.5
		}
		cost = {
			trigger = { country_uses_bio_ships = yes }
			food = @oeo_drill2_alloy_cost
			mult = @halved_alloy_to_food_cost_ratio
		}
		upkeep = { trade = @oeo_drill2_trade_upkeep }
		produces = { minerals = 10 }
		produces = { 
			trigger = {
				is_scope_type = megastructure
				root = {
					planet = { planet_size > 10 }
				} 
			} 
			minerals = 10
		}
		produces = { 
			trigger = {
				is_scope_type = megastructure
				root = {
					planet = { planet_size > 20 }
				} 
			} 
			minerals = 10
		}
		produces = { 
			trigger = {
				is_scope_type = megastructure
				root = {
					planet = { planet_size > 30 }
				} 
			} 
			minerals = 10
		}
		produces = { 
			trigger = {
				is_scope_type = megastructure
				root = {
					planet = { planet_size > 40 }
				} 
			}  
			minerals = 10
		}
	}
	on_build_complete = {
		fromfrom.planet = {
			change_pc = pc_oeo_broken
			planet_event = { id = oeo_orbital_dismantle.1 }
			planet_event = { id = oeo_core_drill.2 days = @oeo_drill2_lifetime }
		}
	}
}
oeo_orbital_drill_gas = {
	entity = "oeo_orbital_drill_entity"
	construction_entity = "oeo_orbital_drill_entity"
	portrait = "GFX_megastructure_construction_background"
	place_entity_on_planet_plane = yes
	scales_with_planet = yes
	use_planet_resource = yes
	outliner_trigger = {
		exists = owner
		owner = {
			has_country_flag = oeo_drill_outliner
		}
	}
	potential = { has_technology = tech_oeo_orbital_drill }
	construction_blocks_and_blocked_by = none
	dismantle_potential = { always = no }
	dismantle_possible = { always = no }
	upgrade_from = { oeo_orbital_drill_build_site_1 }
	build_time = @oeo_drill2_build_time
	resources = {
		category = megastructures_oeo_kilostructures
		cost = { unity = @oeo_drill2_unity_cost }
		cost = {
			trigger = { country_uses_bio_ships = no }
			alloys = @oeo_drill2_alloy_cost
		}
		cost = {
			trigger = { country_uses_bio_ships = yes }
			alloys = @oeo_drill2_alloy_cost
			mult = 0.5
		}
		cost = {
			trigger = { country_uses_bio_ships = yes }
			food = @oeo_drill2_alloy_cost
			mult = @halved_alloy_to_food_cost_ratio
		}
		upkeep = { trade = @oeo_drill2_trade_upkeep }
		produces = { exotic_gases = 1 }
		produces = { 
			trigger = {
				is_scope_type = megastructure
				root = {
					planet = { planet_size > 10 }
				} 
			}  
			exotic_gases = 1
		}
		produces = { 
			trigger = {
				is_scope_type = megastructure
				root = {
					planet = { planet_size > 20 }
				} 
			}  
			exotic_gases = 1
		}
		produces = { 
			trigger = {
				is_scope_type = megastructure
				root = {
					planet = { planet_size > 30 }
				} 
			}  
			exotic_gases = 1
		}
		produces = { 
			trigger = {
				is_scope_type = megastructure
				root = {
					planet = { planet_size > 40 }
				} 
			}  
			exotic_gases = 1
		}
	}
	on_build_complete = {
		fromfrom.planet = {
			change_pc = pc_oeo_broken
			planet_event = { id = oeo_orbital_dismantle.1 }
			planet_event = { id = oeo_core_drill.2 days = @oeo_drill2_lifetime }
			
		}
	}
}
oeo_orbital_drill_crystal = {
	entity = "oeo_orbital_drill_entity"
	construction_entity = "oeo_orbital_drill_entity"
	portrait = "GFX_megastructure_construction_background"
	place_entity_on_planet_plane = yes
	scales_with_planet = yes
	use_planet_resource = yes
	outliner_trigger = {
		exists = owner
		owner = {
			has_country_flag = oeo_drill_outliner
		}
	}
	potential = { has_technology = tech_oeo_orbital_drill }
	construction_blocks_and_blocked_by = none
	dismantle_potential = { always = no }
	dismantle_possible = { always = no }
	upgrade_from = { oeo_orbital_drill_build_site_1 }
	build_time = @oeo_drill2_build_time
	resources = {
		category = megastructures_oeo_kilostructures
		cost = { unity = @oeo_drill2_unity_cost }
		cost = {
			trigger = { country_uses_bio_ships = no }
			alloys = @oeo_drill2_alloy_cost
		}
		cost = {
			trigger = { country_uses_bio_ships = yes }
			alloys = @oeo_drill2_alloy_cost
			mult = 0.5
		}
		cost = {
			trigger = { country_uses_bio_ships = yes }
			food = @oeo_drill2_alloy_cost
			mult = @halved_alloy_to_food_cost_ratio
		}
		upkeep = { trade = @oeo_drill2_trade_upkeep }
		produces = { rare_crystals = 1 }
		produces = { 
			trigger = {
				is_scope_type = megastructure
				root = {
					planet = { planet_size > 10 }
				} 
			}  
			rare_crystals = 1
		}
		produces = { 
			trigger = {
				is_scope_type = megastructure
				root = {
					planet = { planet_size > 20 }
				} 
			}  
			rare_crystals = 1
		}
		produces = { 
			trigger = {
				is_scope_type = megastructure
				root = {
					planet = { planet_size > 30 }
				} 
			}  
			rare_crystals = 1
		}
		produces = { 
			trigger = {
				is_scope_type = megastructure
				root = {
					planet = { planet_size > 40 }
				} 
			}  
			rare_crystals = 1
		}
	}
	on_build_complete = {
		fromfrom.planet = {
			change_pc = pc_oeo_broken
			planet_event = { id = oeo_orbital_dismantle.1 }
			planet_event = { id = oeo_core_drill.2 days = @oeo_drill2_lifetime }
			
		}
	}
}
oeo_orbital_drill_motes = {
	entity = "oeo_orbital_drill_entity"
	construction_entity = "oeo_orbital_drill_entity"
	portrait = "GFX_megastructure_construction_background"
	place_entity_on_planet_plane = yes
	scales_with_planet = yes
	use_planet_resource = yes
	outliner_trigger = {
		exists = owner
		owner = {
			has_country_flag = oeo_drill_outliner
		}
	}
	potential = { has_technology = tech_oeo_orbital_drill }
	construction_blocks_and_blocked_by = none
	dismantle_potential = { always = no }
	dismantle_possible = { always = no }
	upgrade_from = { oeo_orbital_drill_build_site_1 }
	build_time = @oeo_drill2_build_time
	resources = {
		category = megastructures_oeo_kilostructures
		cost = { unity = @oeo_drill2_unity_cost }
		cost = {
			trigger = { country_uses_bio_ships = no }
			alloys = @oeo_drill2_alloy_cost
		}
		cost = {
			trigger = { country_uses_bio_ships = yes }
			alloys = @oeo_drill2_alloy_cost
			mult = 0.5
		}
		cost = {
			trigger = { country_uses_bio_ships = yes }
			food = @oeo_drill2_alloy_cost
			mult = @halved_alloy_to_food_cost_ratio
		}
		upkeep = { trade = @oeo_drill2_trade_upkeep }
		produces = { volatile_motes = 1 }
		produces = { 
			trigger = {
				is_scope_type = megastructure
				root = {
					planet = { planet_size > 10 }
				} 
			}  
			volatile_motes = 1
		}
		produces = { 
			trigger = {
				is_scope_type = megastructure
				root = {
					planet = { planet_size > 20 }
				} 
			}  
			volatile_motes = 1
		}
		produces = { 
			trigger = {
				is_scope_type = megastructure
				root = {
					planet = { planet_size > 30 }
				} 
			}  
			volatile_motes = 1
		}
		produces = { 
			trigger = {
				is_scope_type = megastructure
				root = {
					planet = { planet_size > 40 }
				} 
			}  
			volatile_motes = 1
		}
	}
	on_build_complete = {
		fromfrom.planet = {
			change_pc = pc_oeo_broken
			planet_event = { id = oeo_orbital_dismantle.1 }
			planet_event = { id = oeo_core_drill.2 days = @oeo_drill2_lifetime }
			
		}
	}
}
