# Trading Hub info
sesap_ct2_diplomacy_finance_trade_post = {
	potential = {
		has_starbase_size > starbase_outpost
		exists = owner
		owner = { NOT = { has_ethic = ethic_gestalt_consciousness } }
		# If we are AI only build this in sector capitals
		if = {
			limit = {
				owner = { is_ai = yes }
			}
			owner = { should_ai_focus_on_trade = yes }
			solar_system = {
				is_same_value = sector.sector_capital.solar_system
			}
		}
	}

	weight_modifier = {
		base = 0
		complex_trigger_modifier = { #+100 for each trading_hub
			trigger = count_starbase_modules
			parameters = {
				type = trading_hub
			}
			mode = add
			mult = 100
		}
		complex_trigger_modifier = { #+100 for esap_ct2_diplomacy_finance_trade_post
			trigger = count_starbase_buildings
			parameters = {
				type = esap_ct2_diplomacy_finance_trade_post
			}
			mode = add
			mult = 100
		}
		modifier = {
			add = 1000
			exists = owner
			owner = {
				is_ai = yes 
				should_ai_focus_on_trade = yes
			}
			solar_system = {
				is_same_value = sector.sector_capital.solar_system
			}
		}
	}

	ai_design = {
		min = {
			base = 0
		}

		ratio = {
			base = 0.11
			modifier = {
				add = 0.07
				exists = owner
				owner = {
					OR = {
						has_ethic = ethic_xenophile
						is_megacorp = yes
					}
				}
			}
			modifier = {
				add = 0.11
				exists = owner
				owner = {
					OR = {
						has_ethic = ethic_fanatic_xenophile
						is_megacorp = yes
					}
				}
			}
		}

		# token followed by priority
		buildings = {
			offworld_trading_company = {
				base = 1.00
			}

			nebula_refinery = {
				base = 1.00
			}

			resource_silo = {
				base = 0.25
			}

			art_college = {
				base = 1.00
			}

			curator_think_tank = {
				base = 1.00
			}

			ice_mining_station = {
				base = 1.00
			}

			dragon_hatchery = {
				base = 1.00
			}

			hydroponics_bay = {
				base = 1.00
			}

			defense_grid = {
				base = 0.05
			}

			communications_jammer = {
				base = 0.05
			}

			yuht_detection_array = {
				base = 1.25
				modifier = {
					factor = 0
					exists = owner
					owner = {
						OR = {
							has_megastructure = spy_orb_1
							has_megastructure = spy_orb_2
							has_megastructure = spy_orb_3
							has_megastructure = spy_orb_4
						}
					}
				}
				modifier = {
					factor = 0.10
					exists = owner
					owner = {
						any_owned_starbase = {
							count_starbase_buildings = {
								type = yuht_detection_array
								count > 0
							}
						}
					}
				}
			}
		}

		modules = {
			trading_hub = {
				base = 1.0
			}
		}
	}
}