# possible section models:
# SHIPYARD_STARBASE_SECTION
# REFINERY_STARBASE_SECTION
# SCIENCE_STARBASE_SECTION
# HANGAR_STARBASE_SECTION
# ASSEMBLYYARD_STARBASE_SECTION


##########################################
### VANILLA STARBASE MODULE OVERWRITES ###
##########################################

anchorage = {
	icon = "GFX_starbase_anchorage"
	section = "ANCHORAGE_STARBASE_SECTION"
	construction_days = 180

	potential = {
		is_orbital_ring = no
	}

	resources = {
		category = starbase_modules
		cost = { alloys = 50 }
		upkeep = { energy = 1 }
	}

	country_modifier = {
		country_naval_cap_add = 20
	}
	triggered_country_modifier = {
		potential = { has_starbase_building = naval_logistics_office }
		country_naval_cap_add = 10
	}

	ai_weight = {
		weight = 100 #use same weight here - ai weighting is done in starbase_types.txt
		modifier = {
			factor = 2
			count_starbase_modules = {
				type = anchorage
				count < 2
			}
		}
		modifier = {
			factor = 0
			count_starbase_modules = {
				type = anchorage
				count = 2
			}
		}
	}
}

detection_array = {
	icon = "GFX_spaceport_module_detecton_array"
	section = "SCIENCE_STARBASE_SECTION"
	construction_days = 60

	potential = {
		exists = owner
		owner = { has_technology = tech_detection_array }
		is_orbital_ring = no
	}

	possible = {
		NOT = {
			has_starbase_building = dark_matter_listening_post
		}
		custom_tooltip = {
			fail_text = "starbase_detection_limit_6.tooltip.fail"
			NOT = { count_starbase_modules = { count > 6 type = detection_array include_being_constructed = yes } }
		}
	}

	resources = {
		category = starbase_modules
		cost = { alloys = 25 }
		upkeep = { energy = 0.25 }
	}

	station_modifier = {
		ship_cloaking_detection_add = 1
	}

	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = yes
	ai_weight = {
		weight = 100 #use same weight here - ai weighting is done in starbase_types.txt
		modifier = {
			add = 1000
			owner = {
				NOT = {
					any_owned_starbase = {
						has_starbase_module = detection_array
					}
				}
			}
		}
	}

	show_in_tech = "tech_detection_array"
}

solar_panel_network = {
	icon = "GFX_solar_panel_network"
	section = "SCIENCE_STARBASE_SECTION"
	construction_days = 180
	initial = yes

	potential = {
		exists = owner
		is_normal_starbase = yes
		owner = {
			has_technology = "tech_solar_panel_network"
			NOT = { has_civic = civic_machine_astromining_drones }
		}
	}

	possible = {
		OR = {
			is_scope_valid = no
			solar_system = {
				custom_tooltip = {
					fail_text = "requires_no_black_hole_or_dyson_sphere"
					NOR = {
						is_star_class = sc_black_hole
						has_megastructure = dyson_sphere_3
						has_megastructure = dyson_sphere_4
						has_megastructure = dyson_sphere_5
					}
				}
			}
		}
	}

	show_in_tech = "tech_solar_panel_network"

	resources = {
		category = starbase_modules
		cost = { alloys = 50 }
		
		produces = { 
			energy = 6
		}
		produces = {
			trigger = {
				exists = owner
				owner = {
					is_galactic_community_member = yes
				}
				OR = {
					is_active_resolution = "resolution_galacticstudies_astral_studies_network"
					is_active_resolution = "resolution_galacticstudies_advanced_xenostudies"
					is_active_resolution = "resolution_galacticstudies_ethical_guideline_refactoring"
					is_active_resolution = "resolution_galacticstudies_extradimensional_experimentation"
				}
			}
			energy = 6
		}
		upkeep = {
			alloys = 1
		}
		produces = {
			trigger = { has_starbase_building = solar_capacitor }
			energy = 3
		}
		upkeep = {
			trigger = { has_starbase_building = solar_capacitor }
			alloys = 1
		}
	}

	ai_build_at_chokepoint = no
	ai_build_outside_chokepoint = yes
	
	ai_weight = {
		weight = 50
		modifier = { factor = 5 has_starbase_size < starbase_starport }
		modifier = { factor = 4 count_starbase_modules = { type = solar_panel count > 0 } }
		modifier = { factor = 3 count_starbase_modules = { type = solar_panel count > 1 } }
		modifier = { factor = 2 count_starbase_modules = { type = solar_panel count > 2 } }
		modifier = { factor = 1 count_starbase_modules = { type = solar_panel count > 3 } }
		modifier = { factor = 0 count_starbase_modules = { type = solar_panel count > 4 } }
	}

	ai_weight = {
		weight = 100 #use same weight here - ai weighting is done in starbase_types.txt
	}
}


#############################
### NSC2 STARBASE MODULES ###
#############################

pd_battery = {
	section = "PD_STARBASE_SECTION"
	icon = "GFX_starbase_pd_battery"
	construction_days = 150
	
	resources = {
		category = starbase_modules
		cost = { alloys = 50 }
		upkeep = { energy = 1 }
	}
	
	station_modifier = {
		weapon_type_point_defense_weapon_damage_mult = 0.025
	}
	
	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = no
	
	potential = { 
		exists = owner 
		owner = { 
			OR = {
				has_technology = tech_pd_tracking_1 
				has_technology = tech_pd_tracking_2
				has_technology = tech_pd_tracking_3 
				has_technology = tech_flak_batteries_1 
				has_technology = tech_flak_batteries_2
				has_technology = tech_flak_batteries_3
			}
		}
		has_starbase_size >= starbase_starport #not for outposts
	}
	
	ai_weight = {
		weight = 100
		modifier = { factor = 0 has_starbase_size < starbase_starfortress }
		modifier = { factor = 0 count_starbase_modules = { type = pd_battery count = 2 } }
	}
}

large_battery = {
	section = "LARGE_STARBASE_SECTION"
	icon = "GFX_starbase_large_battery"
	construction_days = 240

	potential = {
		is_orbital_ring = no
		has_starbase_size >= starbase_starfortress
	}
	
	resources =	{
		category = starbase_modules
		cost = { alloys = 125 }
		upkeep = { energy = 1 }
	}
	
	station_modifier = {
		ship_hull_mult = 0.10
		ship_armor_mult = 0.10
	}
	
	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = no
	
	
	ai_weight = {
		weight = 100
		modifier = { factor = 0 has_starbase_size < starbase_starfortress }
		modifier = { factor = 0 count_starbase_modules = { type = large_battery count = 5 } }
	}	
}

xl_battery = {
	section = "EXTRA_LARGE_STARBASE_SECTION"
	icon = "GFX_starbase_xl_battery"
	construction_days = 320

	resources = {
		category = starbase_modules
		cost = { alloys = 300 }
		upkeep = { alloys = 1 energy = 3 }
	}
	
	station_modifier = {
		ship_hull_mult = 0.05
		ship_armor_mult = 0.05
	}
	
	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = no

	potential = { 
		exists = owner 
		owner = { 
			OR = {
				has_technology = tech_energy_lance_1 
				has_technology = tech_energy_lance_2 
				has_technology = tech_arc_emitter_1 
				has_technology = tech_arc_emitter_2 
				has_technology = tech_mass_accelerator_1
				has_technology = tech_mass_accelerator_2 
			}
		}
		has_starbase_size >= starbase_citadel
		is_orbital_ring = no

	}
	
	possible = {
		custom_tooltip = {
			fail_text = "starbase_xl_limit.tooltip.fail"
			NOT = { count_starbase_modules = { count > 6 type = xl_battery include_being_constructed = yes } }
		}
	}


	ai_weight = {
		weight = 100
	}
}

titanic_battery = {
	section = "TITANIC_STARBASE_SECTION"
	icon = "GFX_starbase_titanic_battery"
	construction_days = 420

	resources = {
		category = starbase_modules
		cost = { alloys = 750 }
		upkeep = { alloys = 3 energy = 5 }
	}

	station_modifier = { 
		ship_hull_mult = 0.025
		ship_armor_mult = 0.025
	}

	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = no

	potential = { 
		exists = owner owner = { has_technology = tech_titans }
		has_starbase_size >= starbase_citadel
		is_orbital_ring = no
	}

	possible = {
		custom_tooltip = {
			fail_text = "starbase_t_limit.tooltip.fail"
			NOT = { count_starbase_modules = { count > 2 type = titanic_battery include_being_constructed = yes } }
		}
	}


	ai_weight = {
		weight = 100
	}

	show_in_tech = "tech_titans"
}

shield_module = {
	section = "ANCHORAGE_STARBASE_SECTION"
	icon = "GFX_starbase_shield_module"
	construction_days = 180
	
	resources = {
		category = starbase_modules
		cost = { alloys = 75 }
		upkeep = { energy = 1 }
	}

	station_modifier = { 
		ship_shield_add = 3000
		ship_shield_regen_add_perc = 0.01
	}

	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = yes
	
	potential = { 
		has_starbase_size >= starbase_starport #not for outposts
		solar_system = { NOT = { is_star_class = sc_pulsar } } #not for Pulsar Systems
	}

	possible = {
	}

	ai_weight = {
		weight = 20
		modifier = { factor = 0.5 count_starbase_modules = { type = shield_module count > 7 } }
		modifier = { factor = 0 count_starbase_modules = { type = shield_module count >= 5 } }
	}
}

armor_module = {
	section = "ANCHORAGE_STARBASE_SECTION"
	icon = "GFX_starbase_armor_module"
	construction_days = 180
	resources = {
		category = starbase_modules
		cost = { alloys = 75 }
		upkeep = { alloys = 1 }
	}
	station_modifier = { 
		ship_armor_add = 3000
		ship_armor_regen_add_perc = 0.01
	}
	ai_build_at_chokepoint = yes
	ai_build_outside_chokepoint = yes
	
	potential = {
		has_starbase_size >= starbase_starport #not for outposts
	}

	ai_weight = {
		weight = 20
		modifier = { factor = 0.5 count_starbase_modules = { type = armor_module count > 7 } }
		modifier = { factor = 0 count_starbase_modules = { type = armor_module count >= 5 } }
	}
}

asteroid_mining = {
	section = "HANGAR_STARBASE_SECTION"
	icon = "GFX_starbase_asteroid_mining"
	construction_days = 120
	resources =	{
		category = starbase_modules
		cost = { alloys = 50 }
		produces = { minerals = 10 }
		produces = { trigger = { has_starbase_building = mining_manager } minerals = 2 }
		upkeep = { energy = 2 }
	}
	
	potential = {
		is_orbital_ring = no
	}
	
	possible = {
		custom_tooltip = { fail_text = "nsc.requires.asteroid" solar_system = { any_system_planet = { is_asteroid = yes } } }
	}

	ai_build_at_chokepoint = no
	ai_build_outside_chokepoint = yes
	ai_weight = {
		weight = 50
		modifier = { factor = 5 has_starbase_size < starbase_starport }
		modifier = { factor = 4 count_starbase_modules = { type = asteroid_mining count > 1 } }
		modifier = { factor = 3 count_starbase_modules = { type = asteroid_mining count > 2 } }
		modifier = { factor = 2 count_starbase_modules = { type = asteroid_mining count > 3 } }
		modifier = { factor = 1 count_starbase_modules = { type = asteroid_mining count > 4 } }
		modifier = { factor = 0 count_starbase_modules = { type = asteroid_mining count > 5 } }
	}
}

space_foundry = {
	section = "REFINERY_STARBASE_SECTION"
	icon = "GFX_starbase_space_foundry"
	construction_days = 120
	
	resources = {
		category = starbase_modules
		cost = { alloys = 75 }
		
		produces = { 
			alloys = 8
		}
		upkeep = {
			minerals = 16
			energy = 2
		}
		produces = {
			trigger = { has_starbase_building = assembly_line_manufacturing }
			alloys = 1
		}
		upkeep = {
			trigger = { has_starbase_building = assembly_line_manufacturing }
			minerals = 2
			energy = 1
		}
	}
	
	ai_build_at_chokepoint = no
	ai_build_outside_chokepoint = yes
	
	potential = { exists = owner owner = { has_technology = tech_alloys_1 } is_orbital_ring = no }
	ai_weight = {
		weight = 50
		modifier = { factor = 5 has_starbase_size < starbase_starport }
		modifier = { factor = 4 count_starbase_modules = { type = space_foundry count > 1 } }
		modifier = { factor = 3 count_starbase_modules = { type = space_foundry count > 2 } }
		modifier = { factor = 2 count_starbase_modules = { type = space_foundry count > 3 } }
		modifier = { factor = 1 count_starbase_modules = { type = space_foundry count > 4 } }
		modifier = { factor = 0 count_starbase_modules = { type = space_foundry count > 5 } }
	}
	show_in_tech = "tech_alloys_1"
}

space_factory = {
	section = "REFINERY_STARBASE_SECTION"
	icon = "GFX_starbase_space_factory"
	construction_days = 120
	
	resources = {
		category = starbase_modules
		cost = { alloys = 75 }
		
		produces = { 
			consumer_goods = 10
		}
		upkeep = {
			minerals = 10
			energy = 2
		}
		produces = {
			trigger = { has_starbase_building = assembly_line_manufacturing }
			consumer_goods = 2
		}
		upkeep = {
			trigger = { has_starbase_building = assembly_line_manufacturing }
			minerals = 2
			energy = 1
		}
	}

	ai_build_at_chokepoint = no
	ai_build_outside_chokepoint = yes
	
	potential = {
		exists = owner 
		owner = { has_technology = tech_luxuries_1 }
		is_orbital_ring = no
	}

	ai_weight = {
		weight = 50
		modifier = { factor = 5 has_starbase_size < starbase_starport }
		modifier = { factor = 4 count_starbase_modules = { type = space_factory count > 1 } }
		modifier = { factor = 3 count_starbase_modules = { type = space_factory count > 2 } }
		modifier = { factor = 2 count_starbase_modules = { type = space_factory count > 3 } }
		modifier = { factor = 1 count_starbase_modules = { type = space_factory count > 4 } }
		modifier = { factor = 0 count_starbase_modules = { type = space_factory count > 5 } }
	}
	show_in_tech = "tech_luxuries_1"
}

security_branch_office = {
	section = "ANCHORAGE_STARBASE_SECTION"
	icon = "GFX_starbase_security_branch_office"
	construction_days = 120

	potential = {
		is_orbital_ring = no
		exists = owner
		owner = { is_gestalt = no }
	}
	resources = {
		category = starbase_modules
		cost = { alloys = 50 }
		upkeep = { energy = 1 }
	}

	system_modifier = { planet_crime_add = -15 job_enforcer_add = 100 }
	ai_build_at_chokepoint = no
	ai_build_outside_chokepoint = yes
	ai_weight = {
		weight = 50
	}
}

# solar_panel = {
	# section = "SCIENCE_STARBASE_SECTION"
	# icon = "GFX_sb_solar_panel_network"
	# construction_days = 120

	# potential = {
		# exists = owner
		# is_orbital_ring = no
		# owner = {
			# is_gestalt = no
		# }
	# }
	
	# possible = {
		# solar_system = {
			# custom_tooltip = {
				# fail_text = "requires_no_black_hole_or_dyson_sphere"
				# NOR = {
					# is_star_class = sc_black_hole
					# has_megastructure = dyson_sphere_3
					# has_megastructure = dyson_sphere_4
					# has_megastructure = dyson_sphere_5
				# }
			# }
			# custom_tooltip = {
			# fail_text = "starbase_filler_limit.tooltip_10.fail"
			# NOT = { count_starbase_modules = { count > 10 type = solar_panel include_being_constructed = yes } }
			# }
		# }
	# }

	# resources = {
		# category = starbase_modules
		# cost = { alloys = 150 }
		
		# produces = { 
			# energy = 5
		# }
		# upkeep = {
			# alloys = 1
		# }
		# produces = {
			# trigger = { has_starbase_building = solar_capacitor }
			# energy = 3
		# }
		# upkeep = {
			# trigger = { has_starbase_building = solar_capacitor }
			# alloys = 1
		# }
	# }

	# ai_build_at_chokepoint = no
	# ai_build_outside_chokepoint = yes
	
	# ai_weight = {
		# weight = 50
		# modifier = { factor = 5 has_starbase_size < starbase_starport }
		# modifier = { factor = 4 count_starbase_modules = { type = solar_panel count > 0 } }
		# modifier = { factor = 3 count_starbase_modules = { type = solar_panel count > 1 } }
		# modifier = { factor = 2 count_starbase_modules = { type = solar_panel count > 2 } }
		# modifier = { factor = 1 count_starbase_modules = { type = solar_panel count > 3 } }
		# modifier = { factor = 0 count_starbase_modules = { type = solar_panel count > 4 } }
	# }
# }

farming_base = {
	icon = "GFX_starbase_farming_terminal"
	construction_days = 180
	
	potential = {
		exists = owner
		owner = { has_technology = tech_hydroponics }
		is_orbital_ring = no
	}
	
	possible = {
		custom_tooltip = {
			fail_text = "requires_colonized_planet"
			solar_system = { any_system_colony = { is_owned_by = from } }
		}
		
		custom_tooltip = {
			fail_text = "starbase_filler_limit.tooltip_10.fail"
			NOT = { count_starbase_modules = { count > 10 type = farming_base include_being_constructed = yes } }
		}
	}
	system_modifier = {
		planet_farmers_food_produces_add = 1
	}

	resources = {
		category = starbase_buildings
		cost = {
			alloys = 1000
			energy = 1000
			influence = 50
		}
		upkeep = { energy = 5 }
	}

	ai_build_at_chokepoint = no
	ai_build_outside_chokepoint = yes
	
	ai_weight = { weight = 25 }
}

public_plaza = {
	icon = "GFX_starbase_public_plaza"
	construction_days = 90

	potential = {
		exists = owner
		owner = { 
			is_hive_empire = no
			is_machine_empire = no
		}
		is_orbital_ring = no
	}
	
	possible = {
		custom_tooltip = {
			fail_text = "starbase_filler_limit.tooltip_3.fail"
			NOT = { count_starbase_modules = { count > 3 type = public_plaza include_being_constructed = yes } }
		}
	}

	resources = {
		category = starbase_buildings
		cost = {
			alloys = 100
			consumer_goods = 50
		}
		produces = { 
			unity = 5
		}
		upkeep = {
			energy = 2
		}
	}
	ai_build_at_chokepoint = no
	ai_build_outside_chokepoint = no
	ai_weight = { weight = 0 }
}

fleet_club = {
	icon = "GFX_starbase_fleet_club"
	construction_days = 90

	potential = {
		exists = owner
		owner = { 
			is_hive_empire = no
			is_machine_empire = no
		}
		is_orbital_ring = no
	}
	
	possible = {
		custom_tooltip = {
			fail_text = "starbase_filler_limit_3.tooltip.fail"
			NOT = { count_starbase_modules = { count > 3 type = fleet_club include_being_constructed = yes } }
		}
	}

	resources = {
		category = starbase_buildings
		cost = {
			alloys = 100
			consumer_goods = 50
		}
		produces = { 
			influence = 0.1
		}
		upkeep = {
			energy = 5
		}
	}
	
	system_modifier = { 
		job_entertainer_add = 100
		job_bureaucrat_add = 100
	}
	
	country_modifier = {
		species_leader_exp_gain = 0.01
	}
	
	ai_build_at_chokepoint = no
	ai_build_outside_chokepoint = no
	ai_weight = { weight = 0 }
}

storage_room = {
	icon = "GFX_starbase_storage_room"
	construction_days = 30

	resources = {
		category = starbase_buildings
		cost = {
			alloys = 80
		}
		upkeep = {
			energy = 1
		}
	}
	
	country_modifier = {
		country_resource_max_add = 500
	}

	ai_build_at_chokepoint = no
	ai_build_outside_chokepoint = no
	ai_weight = { weight = 0 }
}

nightclub = {
	icon = "GFX_starbase_nightclub"
	construction_days = 120

	potential = {
		exists = owner
		owner = { 
			is_hive_empire = no
			is_machine_empire = no
		}
		is_orbital_ring = no
	}
	
	possible = {
		custom_tooltip = {
			fail_text = "starbase_filler_limit_3.tooltip.fail"
			NOT = { count_starbase_modules = { count > 3 type = nightclub include_being_constructed = yes } }
		}
	}

	resources = {
		category = starbase_buildings
		cost = {
			alloys = 100
			consumer_goods = 75
		}
		produces = { 
			unity = 5
		}
		upkeep = {
			energy = 5
		}
	}
	
	system_modifier = { 
		job_entertainer_add = 100
		job_bureaucrat_add = 100
		pop_government_ethic_attraction = 0.01
	}
	
	ai_build_at_chokepoint = no
	ai_build_outside_chokepoint = no
	ai_weight = { weight = 0 }
}

public_market = {
	icon = "GFX_starbase_public_market"
	construction_days = 100

	potential = {
		exists = owner
		owner = { 
			is_hive_empire = no
			is_machine_empire = no
		}
		is_orbital_ring = no
	}
	
	possible = {
		custom_tooltip = {
			fail_text = "starbase_filler_limit_3.tooltip.fail"
			NOT = { count_starbase_modules = { count > 3 type = public_market include_being_constructed = yes } }
		}
	}

	resources = {
		category = starbase_buildings
		cost = {
			alloys = 200
			consumer_goods = 75
		}
		produces = {
			consumer_goods = 5
			trade = 2
		}
		upkeep = {
			energy = 8
		}
	}
	
	system_modifier = {
		job_politician_add = 100
	}
	
	ai_build_at_chokepoint = no
	ai_build_outside_chokepoint = no
	ai_weight = { weight = 0 }
}