shipyard = {
	icon = "GFX_starbase_shipyard"
	section = "ASSEMBLYYARD_STARBASE_SECTION"
	construction_days = 180
	category = sm_naval_support_cat
	initial = yes

	potential = {
		is_normal_starbase = yes
		solar_system = {
			count_starbase_modules = {
				type = beastport
				count < 1
				include_being_constructed = yes
			}
		}
	}

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

	abort_construction_trigger = {
		has_starbase_module = beastport
	}

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

		upkeep = {
			energy = 1
		}
	}

	station_modifier = {
		starbase_shipyard_capacity_add = 1
	}
	triggered_station_modifier = {
		potential = { has_starbase_building = irassian_naval_yards }
		starbase_shipyard_capacity_add = 1
	}

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

	ai_weight = {
		inline_script = {
			script = starbase_modules/ship_construction_ai_weight
			MODULE = shipyard
		}
		modifier = {
			factor = 0
			owner = {
				uses_fauna_ship_sizes = yes
			}
		}
	}
}

# 覆盖 增加海军容量
anchorage = {
	icon = "GFX_starbase_anchorage"
	section = "ANCHORAGE_STARBASE_SECTION"
	construction_days = 180
	category = sm_naval_support_cat

	potential = {
		is_normal_starbase = 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
	}

	#mod建筑触发
	triggered_country_modifier = {
		potential = { has_starbase_building = anchorage_enhance }
		country_naval_cap_add = 5
	}

	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 = 2
			exists = owner
			owner = {
				used_naval_capacity_percent > 0.95
			}
		}
	}
}

# 覆盖 增强炮塔
gun_battery = {
	section = "BATTERY_STARBASE_SECTION"
	icon = GFX_spaceport_modules
	construction_days = 180
	category = sm_defense_cat

	potential = {
		is_normal_starbase = yes
	}

	resources = {
		category = starbase_modules
		cost = {
			alloys = @defense_platform_section_cost
		}

		upkeep = {
			energy = 1
		}
	}

	station_modifier = {
		ship_hull_mult = 0.10
		ship_armor_mult = 0.10
		# 增加防御平台
		starbase_defense_platform_capacity_add = 1
	}


	ai_weight = {
		weight = 100 #use same weight here - ai weighting is done in starbase_types.txt
		modifier = {
			factor = 2
			exists = owner
			owner = {
				OR = {
					is_preferred_weapons = weapon_type_energy
					is_preferred_weapons = weapon_type_kinetic
				}
			}
		}
	}

	show_in_tech = "tech_mass_drivers_1"

	show_tech_unlock_if = {
		is_nomadic = no
	}
}

missile_battery = {
	section = "MISSILE_STARBASE_SECTION"
	icon = "GFX_starbase_missile_battery"
	construction_days = 180
	category = sm_defense_cat

	potential = {
		exists = owner
		owner = { has_technology = tech_torpedoes_1 }
		is_normal_starbase = yes
	}

	resources = {
		category = starbase_modules
		cost = {
			alloys = @defense_platform_section_cost
		}

		upkeep = {
			energy = 1
		}
	}

	station_modifier = {
		ship_hull_mult = 0.10
		ship_armor_mult = 0.10
	}



	ai_weight = {
		weight = 100 #use same weight here - ai weighting is done in starbase_types.txt
		modifier = {
			factor = 2
			exists = owner
			owner = { is_preferred_weapons = weapon_type_explosive }
		}
	}

	show_in_tech = "tech_torpedoes_1"

	show_tech_unlock_if = {
		is_nomadic = no
	}
}

# 修改
hangar_bay = {
	icon = "GFX_starbase_hangar_bay"
	section = "HANGAR_STARBASE_SECTION"
	construction_days = 180
	category = sm_defense_cat

	potential = {
		exists = owner
		owner = { has_technology = tech_strike_craft_1 }
		is_normal_starbase = yes
	}

	resources = {
		category = starbase_modules
		cost = {
			alloys = @defense_platform_section_cost
		}

		produces = {
			trade = 0.25
			mult = value:councilor_level|TYPE|councilor_flight_director|
		}

		upkeep = {
			energy = 1
		}
	}

	station_modifier = {
		ship_hull_mult = 0.10
		ship_armor_mult = 0.10
		# 防御平台+1
		starbase_defense_platform_capacity_add = 1
	}

	ai_weight = {
		weight = 100 #use same weight here - ai weighting is done in starbase_types.txt
		modifier = {
			factor = 2
			exists = owner
			owner = { is_preferred_weapons = weapon_type_strike_craft }
		}
	}

	show_in_tech = "tech_strike_craft_1"

	show_tech_unlock_if = {
		is_nomadic = no
	}
}

solar_panel_network = {
	icon = "GFX_solar_panel_network"
	section = "SCIENCE_STARBASE_SECTION"
	construction_days = 180
	category = sm_economy_cat
	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"

	show_tech_unlock_if = {
		is_nomadic = no
	}

	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
		}
	}

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

trading_hub = {
	icon = "GFX_starbase_trading_hub"
	section = "REFINERY_STARBASE_SECTION"
	construction_days = 180
	category = sm_economy_cat
	initial = yes

	potential = {
		is_normal_starbase = yes
	}

	resources = {
		category = starbase_modules
		cost = {
			alloys = 50
		}
		upkeep = {
			energy = 2
		}
		produces = {
			trigger = {
				hidden_trigger = { exists = this }
				owner = {
					has_councilor = { COUNCILOR = "councilor_trading_posts" }
				}
			}
			trade = 0.5
			mult = value:councilor_level|TYPE|councilor_trading_posts|
		}
		produces = {
			trade = 8
		}
		produces = {
			trigger = {
				exists = this
				has_starbase_building = offworld_trading_company
			}
			trade = 4
		}
		produces = {
			trigger = {
				exists = this
				has_starbase_building = warp_fluctuator
			}
			trade = 2
		}
	}

	station_modifier = {
	}

	ai_weight = {
		weight = 100 #use same weight here - ai weighting is done in starbase_types.txt
		modifier = {
			factor = 5
			NOT = { has_starbase_module = trading_hub }
			planet = {
				planet_resource_compare = {
					resource = trade
					value > 50
					type = produces
				}
			}
		}
	}
}

detection_array = {
	icon = "GFX_spaceport_module_detecton_array"
	section = "SCIENCE_STARBASE_SECTION"
	construction_days = 180
	category = sm_utility_cat

	potential = {
		exists = owner
		owner = { has_technology = tech_detection_array }
		is_normal_starbase = yes
	}

	possible = {
		NOT = {
			has_starbase_building = dark_matter_listening_post
		}
	}

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

		upkeep = {
			energy = 1
		}
	}

	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"

	show_tech_unlock_if = {
		is_nomadic = no
	}
}

archaeo_rampart = {
	section = "ANCHORAGE_STARBASE_SECTION"
	icon = GFX_starbase_archaeo_rampart
	construction_days = 180
	category = sm_defense_cat

	potential = {
		is_normal_starbase = yes
		owner = { has_technology = tech_archaeo_rampart }
	}

	resources = {
		category = starbase_modules
		cost = {
			alloys = 50
			minor_artifacts = @minor_artifacts_cost_xl
		}

		upkeep = {
			energy = 1
		}
	}

	triggered_station_modifier = {
		potential = {
			owner = {
				NOT = { has_ascension_perk = ap_archaeoengineers }
			}
		}
		shipclass_starbase_hull_mult = 0.15
		shipclass_starbase_armor_mult = 0.15
		starbase_defense_platform_capacity_add = 2
	}

	triggered_station_modifier = {
		potential = {
			owner = {
				has_ascension_perk = ap_archaeoengineers
			}
		}
		shipclass_starbase_hull_mult = 0.15
		shipclass_starbase_armor_mult = 0.20
		shipclass_starbase_armor_hardening_add = 0.10
		starbase_defense_platform_capacity_add = 2
	}

	custom_tooltip = sm_archaeo_rampart_desc_modifier

	defense_platform_modifier = {
		shipclass_military_station_damage_mult = 0.05
		shipclass_military_station_hull_mult = 0.05
	}

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

	show_in_tech = "tech_archaeo_rampart"

	show_tech_unlock_if = {
		is_nomadic = no
	}
}

astromining_bay = {
	icon = "GFX_starbase_mining_terminal"
	section = "REFINERY_STARBASE_SECTION"
	construction_days = 180
	category = sm_economy_cat

	potential = {
		is_normal_starbase = yes
		owner = {
			has_civic = civic_machine_astromining_drones
		}
	}

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

		produces = { #From the Solar panels
			energy = 5
		}

		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
		}
	}

	system_modifier = {
		station_gatherers_produces_mult = 0.15
	}
	triggered_system_modifier = {
		potential = { has_starbase_building = astromining_hub }
		station_gatherers_produces_mult = 0.1
	}

	ai_weight = {
		weight = 100 #use same weight here - ai weighting is done in starbase_types.txt
		modifier = {
			factor = 2
			solar_system = {
				count_orbital_station = {
					count > 4
					limit = { is_ship_size = mining_station }
				}
			}
		}
	}
}


beastport = {
	icon = "GFX_starbase_beastport"
	section = "ASSEMBLYYARD_STARBASE_SECTION"
	construction_days = 180
	category = sm_naval_support_cat

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

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

	abort_construction_trigger = {
		has_starbase_module = 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 = beastport } }
			set_ship_construction_type = none
		}
	}

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

vivarium_tank = {
	icon = "GFX_starbase_vivarium_tank"
	section = "SCIENCE_STARBASE_SECTION"
	construction_days = 180
	category = sm_naval_support_cat

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

	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 = vivarium_tank
		}
	}

	show_in_tech = "tech_gravity_wells"

	show_tech_unlock_if = {
		is_nomadic = no
	}
}
