# Full ai_design block for waystation starbase types
# If you add a new waystation module, also add it to this file
# and update the weights for all waystation starbase types in common/starbase_types/01_waystation_types.txt
#
# Economy params:    ENERGY_WEIGHT, MINING_WEIGHT, REFINERY_WEIGHT, RESEARCH_WEIGHT, TRADE_WEIGHT, HYDROPONICS_WEIGHT, TRIBUTE_VAULT_WEIGHT
# Infrastructure:    LOGISTICS_HUB_WEIGHT, REPAIR_BAY_WEIGHT, RESOURCE_SILO_WEIGHT
# Situational:       NEBULA_REFINERY_WEIGHT, OBSERVATORY_WEIGHT, DIMENSIONAL_SHRINE_WEIGHT, NANOTECH_WEIGHT
# Utility:           RECRUITMENT_OFFICE_WEIGHT, AURA_EMITTER_WEIGHT, HYPERLANE_DETAILER_WEIGHT, CLOAKING_WEIGHT, VOIDLURE_WEIGHT
# Enclave:           ART_COLLEGE_WEIGHT, CURATOR_THINK_TANK_WEIGHT, TRADER_PROXY_WEIGHT, SALVAGER_WORKSHOP_WEIGHT
# Precursor:         CYBREX_MINING_HUB_WEIGHT, YUHT_DETECTION_ARRAY_WEIGHT
# Defense:           ASTEROID_BATTERIES_WEIGHT, MISSILE_SILOS_WEIGHT, PATROL_HANGARS_WEIGHT
# Pirate:            PIRATE_HIDEOUT_WEIGHT, CONCEALMENT_FIELD_WEIGHT, REAVER_STRONGHOLD_WEIGHT
# Naval support:     GROWTH_CHAMBER_WEIGHT
# Crisis:            AETHEROPHASIC_ANCHOR_WEIGHT, GRAVITATIONAL_CENTRIFUGE_WEIGHT

ai_design = {
	modules = {
		# Economy modules
		waystation_energy_module = {
			base = $ENERGY_WEIGHT$
		}
		waystation_mining_module = {
			base = $MINING_WEIGHT$
		}
		waystation_refinery_module = {
			base = $REFINERY_WEIGHT$
		}
		waystation_research_module = {
			base = $RESEARCH_WEIGHT$
		}
		waystation_trade_module = {
			base = $TRADE_WEIGHT$
			# Genocidal empires have no one to trade with
			modifier = {
				factor = 0.1
				owner? = {
					is_homicidal = yes
				}
			}
		}
		waystation_hydroponics_module = {
			base = $HYDROPONICS_WEIGHT$
			# Empires that don't use food have no need for this
			modifier = {
				factor = 0
				owner? = {
					country_uses_food = no
				}
			}
		}
		waystation_treasure_vault = {
			base = $TRIBUTE_VAULT_WEIGHT$
			# Only relevant for overlords with subject colonies in the system
			modifier = {
				factor = 0
				owner? = { is_overlord = no }
			}
		}

		# Infrastructure
		waystation_logistics_hub = {
			base = $LOGISTICS_HUB_WEIGHT$
			# A hub covers the whole connected wayline, so one per network is enough
			modifier = {
				factor = 0
				waystation_network_has_remote_collection = yes
			}
		}
		waystation_repair_bay = {
			base = $REPAIR_BAY_WEIGHT$
		}
		waystation_resource_silo = {
			base = $RESOURCE_SILO_WEIGHT$
		}

		# Situational economy
		waystation_nebula_refinery = {
			base = $NEBULA_REFINERY_WEIGHT$
		}
		waystation_observatory = {
			base = $OBSERVATORY_WEIGHT$
		}
		waystation_dimensional_shrine = {
			base = $DIMENSIONAL_SHRINE_WEIGHT$
		}
		waystation_nanotech_module = {
			base = $NANOTECH_WEIGHT$
		}

		# Utility
		waystation_recruitment_office = {
			base = $RECRUITMENT_OFFICE_WEIGHT$
			modifier = {
				factor = 0.1
				owner? = {
					is_homicidal = yes
				}
			}
		}
		waystation_aura_emitter = {
			base = $AURA_EMITTER_WEIGHT$
		}
		waystation_hyperlane_detailer = {
			base = $HYPERLANE_DETAILER_WEIGHT$
		}
		waystation_cloaking = {
			base = $CLOAKING_WEIGHT$
		}

		# Space fauna voidlures (gated by potential: Grand Archive prereqs + fauna home system)
		waystation_voidlure_tiyanki = {
			base = $VOIDLURE_WEIGHT$
		}
		waystation_voidlure_space_amoeba = {
			base = $VOIDLURE_WEIGHT$
		}
		waystation_voidlure_crystalline_entity = {
			base = $VOIDLURE_WEIGHT$
		}
		waystation_voidlure_voidworm = {
			base = $VOIDLURE_WEIGHT$
		}
		waystation_voidlure_cutholoid = {
			base = $VOIDLURE_WEIGHT$
		}

		# Enclave modules
		waystation_art_college = {
			base = $ART_COLLEGE_WEIGHT$
		}
		waystation_curator_think_tank = {
			base = $CURATOR_THINK_TANK_WEIGHT$
		}
		waystation_trader_proxy_office = {
			base = $TRADER_PROXY_WEIGHT$
		}
		waystation_salvager_workshop = {
			base = $SALVAGER_WORKSHOP_WEIGHT$
		}

		# Precursor modules
		waystation_cybrex_mining_hub = {
			base = $CYBREX_MINING_HUB_WEIGHT$
		}
		waystation_yuht_detection_array = {
			base = $YUHT_DETECTION_ARRAY_WEIGHT$
		}

		# Defense weapon modules
		waystation_laser_battery = {
			base = $ASTEROID_BATTERIES_WEIGHT$
			modifier = {
				factor = 3
				owner? = {
					is_at_war = yes
				}
			}
		}
		waystation_archaeo_laser_battery = {
			base = $ASTEROID_BATTERIES_WEIGHT$
			modifier = {
				factor = 3
				owner? = {
					is_at_war = yes
				}
			}
		}
		waystation_mass_driver_battery = {
			base = $ASTEROID_BATTERIES_WEIGHT$
			modifier = {
				factor = 3
				owner? = {
					is_at_war = yes
				}
			}
		}
		waystation_archaeo_mass_driver_battery = {
			base = $ASTEROID_BATTERIES_WEIGHT$
			modifier = {
				factor = 3
				owner? = {
					is_at_war = yes
				}
			}
		}
		waystation_swarmer_missile_battery = {
			base = $ASTEROID_BATTERIES_WEIGHT$
			modifier = {
				factor = 3
				owner? = {
					is_at_war = yes
				}
			}
		}
		waystation_particle_launcher = {
			base = $MISSILE_SILOS_WEIGHT$
			modifier = {
				factor = 3
				owner? = {
					is_at_war = yes
				}
			}
		}
		waystation_psionic_torpedo = {
			base = $MISSILE_SILOS_WEIGHT$
			modifier = {
				factor = 3
				owner? = {
					is_at_war = yes
				}
			}
		}
		waystation_scourge_missile_battery = {
			base = $MISSILE_SILOS_WEIGHT$
			modifier = {
				factor = 3
				owner? = {
					is_at_war = yes
				}
			}
		}
		waystation_hangar_bay = {
			base = $PATROL_HANGARS_WEIGHT$
			modifier = {
				factor = 3
				owner? = {
					is_at_war = yes
				}
			}
		}
		waystation_archaeo_hangar_bay = {
			base = $PATROL_HANGARS_WEIGHT$
			modifier = {
				factor = 3
				owner? = {
					is_at_war = yes
				}
			}
		}
		waystation_psionic_hangar_bay = {
			base = $PATROL_HANGARS_WEIGHT$
			modifier = {
				factor = 3
				owner? = {
					is_at_war = yes
				}
			}
		}
		waystation_amoeba_hangar_bay = {
			base = $PATROL_HANGARS_WEIGHT$
			modifier = {
				factor = 3
				owner? = {
					is_at_war = yes
				}
			}
		}
		waystation_swarm_hangar_bay = {
			base = $PATROL_HANGARS_WEIGHT$
			modifier = {
				factor = 3
				owner? = {
					is_at_war = yes
				}
			}
		}

		# Naval support modules
		waystation_growth_chamber = {
			base = $GROWTH_CHAMBER_WEIGHT$
		}

		# Pirate modules (only buildable by void reavers — weights set directly per starbase type)
		waystation_pirate_hideout = {
			base = $PIRATE_HIDEOUT_WEIGHT$
		}
		waystation_concealment_field = {
			base = $CONCEALMENT_FIELD_WEIGHT$
			# Encourage in nebulae
			modifier = {
				factor = 2
				solar_system = {
					is_inside_nebula = yes
				}
			}
			# Encourage if a Reaver Stronghold is present
			modifier = {
				factor = 5
				has_starbase_module = waystation_reaver_stronghold
			}
		}
		waystation_reaver_stronghold = {
			base = $REAVER_STRONGHOLD_WEIGHT$
			# Discourage building near rivals
			modifier = {
				factor = 0.25
				solar_system = {
					any_neighbor_system = {
						owner? = {
							is_rival = root.owner
						}
					}
				}
			}
			# Encourage in nebulae
			modifier = {
				factor = 5
				solar_system = {
					is_inside_nebula = yes
				}
			}
		}

		# Crisis modules — gated by potential, only relevant during a specific crisis path
		waystation_aetherophasic_anchor = {
			base = $AETHEROPHASIC_ANCHOR_WEIGHT$
		}
		waystation_gravitational_centrifuge = {
			base = $GRAVITATIONAL_CENTRIFUGE_WEIGHT$
			# Don't build adjacent to foreign-owned systems (the centrifuge requires a stable neighborhood)
			modifier = {
				factor = 0
				solar_system = {
					any_neighbor_system = {
						owner? = { NOT = { is_same_value = root.owner } }
					}
				}
			}
			# Cap at 5 instances per empire
			modifier = {
				factor = 0
				owner? = {
					count_owned_nonprimary_starbase = {
						count >= 5
						limit = {
							is_waystation_starbase = yes
							has_starbase_module = waystation_gravitational_centrifuge
						}
					}
				}
			}
		}
	}
}
