@entity_x				= 0
@entity_y 				= -20

acot_precursor_theta_citadel_site = {
	entity = "precursor_dark_obelisk_construction_portal_entity"
	construction_entity = "precursor_dark_obelisk_construction_portal_entity"
	portrait = "GFX_acot_precursor_theta_station_plans_background"
	entity_offset = { x = -20 y = -20 }
	place_entity_on_planet_plane = yes
	build_time = 1
	resources = {
		category = megastructures
		cost = {
			alloys = 2000000
			sm_sr_perfect_runic_energy = 500
			influence = 200
		}
		upkeep = {	
		}
	}

	prerequisites = { "tech_precursor_theia_design" }
	
	possible = {
		exists = starbase
		custom_tooltip = {
			fail_text = "requires_inside_border"
			is_inside_border = from
		}	
		any_fleet_in_system = {
			OR = {
				is_ship_size = starbase_outpost
				is_ship_size = starbase_starport
				is_ship_size = starbase_starhold
				is_ship_size = starbase_starfortress
				is_ship_size = starbase_citadel
				is_ship_size = acot_fallen_outpost
				is_ship_size = acot_fallen_starbase
				is_ship_size = acot_precusor_starbase
				is_ship_size = acot_precusor_starcitadel
				is_ship_size = acot_precusor_starfortress
				is_ship_size = acot_precusor_sigma_starbase
				is_ship_size = acot_precusor_sigma_starfortress
				is_ship_size = acot_precusor_sigma_starcitadel
				is_ship_size = acot_precusor_phanon_starcitadel
			}
		}
		custom_tooltip = {
			fail_text = "requires_no_existing_megastructure"
			NOR = {
				has_megastructure = acot_precursor_theta_citadel_site
				has_megastructure = acot_precursor_theta_citadel_base
				any_ship_in_system = {
					OR = {
						is_ship_size >= acot_precusor_theta_starbase
					}
				}
			}
		}
	}
	
	placement_rules = {
		planet_possible = {
			custom_tooltip = {
				fail_text = "must_build_around_star"
				is_star = yes
			}
			custom_tooltip = {
				fail_text = "requires_no_anomaly"
				NOT = { has_anomaly = yes }
			}
		}
	}
	
	# root = system
	# from = country	
	ai_weight = {
		factor = 0
		
		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 } 
				}
			}
		}
	}
	
	on_build_start = {}
	on_build_cancel = {}
	on_build_complete = {
		if = {
			limit = {
				any_ship_in_system = {
					is_ship_size = acot_precusor_starfortress
				}
			}
			set_star_flag = acot_will_become_fortress
		}	
		if = {
			limit = {
				any_ship_in_system = {
					is_ship_size = acot_precusor_starcitadel
				}
			}
			set_star_flag = acot_will_become_citadel
		}
		fromfrom = {
			upgrade_megastructure_to = acot_precursor_theta_citadel_base
		}
	}
}

#Precursor Starbase Prodoctor
acot_precursor_theta_citadel_base = {
	entity = "acot_precusor_starbase_megastructure_entity"
	construction_entity = "acot_precusor_theta_starbase_construction_entity"
	portrait = "GFX_acot_precursor_theta_station_plans_background"
	build_time = 4320
	entity_offset = { x = -20 y = -20 }
	place_entity_on_planet_plane = yes
	resources = {
		category = megastructures
		cost = {
		}
		cost = {
			trigger = {
				solar_system = {
					has_star_flag = acot_will_become_fortress
				}
			}
			alloys = -75000
		}
		cost = {
			trigger = {
				solar_system = {
					has_star_flag = acot_will_become_citadel
				}
			}
			alloys = -125000
		}
	}
	
	upgrade_from = {
		acot_precursor_theta_citadel_site
	}

	on_build_complete = {
		if = {
			limit = {
				has_star_flag = acot_will_become_fortress
			}
			remove_star_flag = acot_will_become_fortress
		}	
		if = {
			limit = {
				has_star_flag = acot_will_become_citadel
			}
			remove_star_flag = acot_will_become_citadel
		}
	}
}

#VVVVVVVVVVVVVVVVVVVVVV OLD CONSTRUCTION METHOD

##PRECURSOR SIGMA CITADEL SITE 
#acot_precursor_theta_citadel_site = {
#	entity = "acot_precursor_theta_starbase_construction_platform_entity"
#	construction_entity = "acot_precursor_theta_starbase_construction_platform_entity"
#	portrait = "GFX_acot_precursor_theta_station_plans_background"
#	place_entity_on_planet_plane = no
#	#entity_offset = { x = -7 y = -7 }
#	build_time = 720
#	resources = {
#		category = megastructures
#		cost = {
#			alloys = 50000
#			influence = 200
#		}
#		upkeep = {	
#		}
#	}
#
#	prerequisites = { "tech_precursor_theia_design" }
#	
#	possible = {
#		exists = starbase
#		custom_tooltip = {
#			fail_text = "requires_inside_border"
#			is_inside_border = from
#		}	
#	}
#	
#	placement_rules = {
#		planet_possible = {
#			custom_tooltip = {
#				fail_text = "must_build_around_star"
#				is_star = yes
#			}
#			custom_tooltip = {
#				fail_text = "requires_no_anomaly"
#				NOT = { has_anomaly = yes }
#			}
#		}
#		any_fleet_in_system = {
#			is_ship_class = shipclass_starbase
#			OR = {
#				is_ship_size = starbase_outpost
#				is_ship_size = starbase_starport
#				is_ship_size = starbase_starhold
#				is_ship_size = starbase_starfortress
#				is_ship_size = starbase_citadel
#			}
#		}
#		custom_tooltip = {
#			#fail_text = "requires_no_existing_gateway"
#			NOR = {
#				has_megastructure = acot_precursor_theta_citadel_site
#				has_megastructure = acot_precursor_theta_citadel_base
#				has_starbase_size >= acot_precusor_theta_starbase
#			}
#		}
#	}
#	
#	# root = system
#	# from = country	
#	ai_weight = {
#		factor = 0
#		
#		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 } 
#				}
#			}
#		}
#	}
#	
#	on_build_start = {}
#	on_build_cancel = {}
#	on_build_complete = {
#		#set_star_flag = dyson_sphere_built
#		#from = { set_country_flag = built_dyson_sphere }
#	}
#}
#
##Precursor Starbase Prodoctor
#acot_precursor_theta_citadel_base = {
#	entity = "acot_precusor_theta_starbase_construction_entity"
#	construction_entity = "acot_precusor_theta_starbase_construction_entity"
#	portrait = "GFX_acot_precursor_theta_station_plans_background"
#	build_time = 3600
#	resources = {
#		category = megastructures
#		cost = {
#			alloys = 2000000
#			sm_sr_perfect_runic_energy = 500
#		}
#	}
#	
#	upgrade_from = {
#		acot_precursor_theta_citadel_site
#	}
#
#	#prerequisites = { "tech_dyson_sphere" }
#}