#Remember to update operation_sabotage_starbase if you add any new modules.
# You will need to update the description, espionage_sabotage_starbase_module, and remove_sabotage_starbase_flag

orbital_ring_habitation = {
	icon = "GFX_orbitalring_module_habitation"
	section = "HABITAT_ORBITAL_RING_SECTION"
	construction_days = 360
	starbase_type = orbital_ring
	category = sm_colony_cat

	potential = {
		exists = owner
		owner = { has_technology = tech_housing_2 }
		is_orbital_ring = yes
	}

	show_in_tech = "tech_housing_2"

	show_tech_unlock_if = {
		has_overlord_dlc = yes
		is_nomadic = no
	}

	resources = {
		category = starbase_modules
		cost = {
			alloys = 200
			influence = 25
		}

		upkeep = {
			energy = 2
		}
	}

	planet_modifier = {
		planet_max_districts_add = 1
	}

	triggered_planet_modifier = {
		potential = {
			exists = planet
			planet = {
				exists = owner.overlord
				has_holding = {
					holding = holding_orbital_assembly_complex
					owner = owner.overlord
				}
			}
		}
		planet_max_districts_add = 0.5
	}

	replaceable = {
		custom_tooltip = {
			fail_text = orbital_ring_habitation_districts_maxed_out
			OR = { # to keep tooltip from showing up when no module is built yet
				NOT = { has_starbase_module = orbital_ring_habitation }
				AND = {
					has_starbase_module = orbital_ring_habitation
					planet = {
						num_free_districts = { type = any value >= 1 }
					}
				}
			}
		}
	}

	ai_weight = {
		weight = 100
	}
}

orbital_ring_shipyard = {
	icon = "GFX_starbase_shipyard"
	section = "SHIPYARD_ORBITAL_RING_SECTION"
	construction_days = 180
	starbase_type = orbital_ring
	category = sm_naval_support_cat
	initial = yes

	potential = {
		is_orbital_ring = yes
		solar_system = {
			count_starbase_modules = {
				type = orbital_ring_beastport
				count < 1
				include_being_constructed = yes
			}
		}
	}

	possible = {
		solar_system = {
			count_starbase_modules = {
				type = orbital_ring_beastport
				count < 1
				include_being_constructed = yes
			}
		}
	}

	abort_construction_trigger = {
		has_starbase_module = orbital_ring_beastport
	}

	resources = {
		category = starbase_modules
		cost = {
			alloys = 50
		}

		upkeep = {
			energy = 1
		}
	}

	station_modifier = {
		starbase_shipyard_capacity_add = 1
	}

	triggered_station_modifier = {
		potential = {
			exists = planet
			planet = {
				exists = owner.overlord
				has_holding = {
					holding = holding_orbital_assembly_complex
					owner = owner.overlord
				}
			}
		}
		starbase_shipyard_capacity_add = 1
	}

	on_finished = {
		set_ship_construction_type = starbase_shipyard
	}
	on_destroyed = {
		if = {
			limit = { NOT = { has_starbase_module = orbital_ring_shipyard } }
			set_ship_construction_type = none
		}
	}

	ai_weight = {
		inline_script = {
			script = starbase_modules/ship_construction_ai_weight
			MODULE = orbital_ring_shipyard
		}
		modifier = {
			factor = 0
			owner = {
				uses_standard_ship_sizes = no
			}
		}
	}
}

orbital_ring_anchorage = {
	icon = "GFX_starbase_anchorage"
	section = "ANCHORAGE_ORBITAL_RING_SECTION"
	construction_days = 180
	starbase_type = orbital_ring
	category = sm_naval_support_cat

	potential = {
		is_orbital_ring = yes
	}

	resources = {
		category = starbase_modules
		cost = {
			alloys = 50
		}

		upkeep = {
			energy = 1
			trade = 4
		}

		upkeep = {
			trigger = {
				is_scope_valid = yes
				has_starbase_building = naval_logistics_office
			}
			trade = 2
		}
	}

	country_modifier = {
		country_naval_cap_add = 5
	}

	triggered_country_modifier = {
		potential = {
			is_scope_valid = yes
			has_starbase_building = naval_logistics_office
		}
		country_naval_cap_add = 3
	}

	triggered_country_modifier = {
		potential = {
			exists = planet
			planet = {
				exists = owner.overlord
				has_holding = {
					holding = holding_orbital_assembly_complex
					owner = owner.overlord
				}
			}
		}
		country_naval_cap_add = 3
	}


	ai_weight = {
		weight = 100
	}
}
orbital_ring_beastport = {
	icon = "GFX_starbase_beastport"
	section = "SHIPYARD_ORBITAL_RING_SECTION"
	construction_days = 180
	starbase_type = orbital_ring
	category = sm_naval_support_cat

	potential = {
		exists = owner
		is_orbital_ring = yes
		owner = {
			OR = {
				has_technology = tech_alien_cloning
				is_beastmasters_empire = yes
			}
		}
		solar_system = {
			count_starbase_modules = {
				type = orbital_ring_shipyard
				count < 1
				include_being_constructed = yes
			}
		}
	}

	possible = {
		solar_system = {
			count_starbase_modules = {
				type = orbital_ring_shipyard
				count < 1
				include_being_constructed = yes
			}
		}
	}

	abort_construction_trigger = {
		has_starbase_module = orbital_ring_shipyard
	}

	resources = {
		category = starbase_modules
		cost = {
			alloys = 50
		}

		upkeep = {
			energy = 1
		}
	}

	station_modifier = {
		custom_tooltip = sm_beastport_capacity_add_tt
		show_only_custom_tooltip = yes
		starbase_shipyard_capacity_add = 1
	}

	country_modifier = {
		country_vivarium_max_capacity_add = 25
	}

	on_finished = {
		set_ship_construction_type = starbase_beastport
	}
	on_destroyed = {
		if = {
			limit = { NOT = { has_starbase_module = orbital_ring_beastport } }
			set_ship_construction_type = none
		}
	}

	triggered_station_modifier = {
		potential = {
			exists = planet
			planet = {
				exists = owner.overlord
				has_holding = {
					holding = holding_orbital_assembly_complex
					owner = owner.overlord
				}
			}
		}
		custom_tooltip = sm_beastport_capacity_add_tt
		show_only_custom_tooltip = yes
		starbase_shipyard_capacity_add = 1
	}

	ai_weight = {
		inline_script = {
			script = starbase_modules/ship_construction_ai_weight
			MODULE = orbital_ring_beastport
		}
		modifier = {
			factor = 0
			owner = {
				uses_fauna_ship_sizes = no
			}
		}
	}
}

orbital_ring_vivarium_tank = {
	icon = "GFX_starbase_vivarium_tank"
	section = "HANGAR_ORBITAL_RING_SECTION"
	construction_days = 180
	starbase_type = orbital_ring
	category = sm_naval_support_cat

	potential = {
		exists = owner
		is_orbital_ring = yes
		owner = {
			OR = {
				has_technology = tech_gravity_wells
				has_origin = origin_primal_calling
			}
		}
	}

	resources = {
		category = starbase_modules
		cost = {
			alloys = 50
		}

		upkeep = {
			energy = 1
		}
	}

	country_modifier = {
		country_vivarium_max_capacity_add = 50
	}

	orbit_modifier = {
		space_fauna_growth_rate_mult = 0.1
	}

	ai_weight = {
		inline_script = {
			script = starbase_modules/ship_construction_ai_weight
			MODULE = orbital_ring_vivarium_tank
		}
	}

	show_in_tech = "tech_gravity_wells"

	show_tech_unlock_if = {
		has_overlord_dlc = yes
		is_nomadic = no
	}
}
