############################################################
###         ESC Special Resource Orbital Modules         ###
############################################################

# 	- Dark Matter Orbital Plant
#	- Zro Orbital Plant
#	- Nanite Orbital Plant

############################################################
###              Dark Matter Orbital Plant               ###
############################################################

esc_starbase_dm_orbital_plant = {
	icon = GFX_esc_starbase_dark_matter_plant
	section = REFINERY_STARBASE_SECTION
	construction_days = 180
	initial = no

	potential = {
		owner = { has_technology = esc_tech_dark_matter_facilities }
		NOR = {
			has_global_flag = ESC_GLOBAL_FLAG_chronospatial_weapons_forbidden
			has_global_flag = ESC_GLOBAL_FLAG_enigmatic_weapons_forbidden
			has_global_flag = ESC_GLOBAL_FLAG_gravitic_weapons_forbidden
		}
	}

	resources = {
		category = starbase_modules
		cost = {
			alloys = 150
			volatile_motes = 50
		}
		# resource production
		produces = {
			sr_dark_matter = 6
		}
		produces = {
			trigger = {
				solar_system = { ESC_TRIGGER_system_has_dark_matter = yes }
			}
			sr_dark_matter = 6
		}
		# upkeep
		upkeep = {
			energy = 10
			volatile_motes = 2
		}
		upkeep = {
			trigger = {
				solar_system = { ESC_TRIGGER_system_has_dark_matter = yes }
			}
			volatile_motes = -2
		}
	}

	show_in_tech = "esc_tech_dark_matter_facilities"

	ai_build_at_chokepoint = no
	ai_weight = {
		weight = 0
		modifier = {
			weight = 5
			owner = {
				resource_income_compare = {
					resource = sr_dark_matter
					value < 2
				}
			}
		}
		modifier = {
			factor = 0
			starbase = {
				has_starbase_module = esc_starbase_dm_orbital_plant
			}
		}
	}
}

############################################################
###                  Zro Orbital Plant                   ###
############################################################

esc_starbase_zro_orbital_plant = {
	icon = GFX_esc_starbase_zro_plant
	section = REFINERY_STARBASE_SECTION
	construction_days = 180
	initial = no

	potential = {
		owner = { has_technology = esc_tech_zro_distilleries }
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_psionic_weapons_forbidden }
	}

	resources = {
		category = starbase_modules
		cost = {
			alloys = 150
			volatile_motes = 50
			rare_crystals = 50
			exotic_gases = 50
		}
		# resource production
		produces = {
			sr_zro = 6
		}
		produces = {
			trigger = { solar_system = { ESC_TRIGGER_system_has_zro = yes } }
			sr_zro = 3
		}
		# upkeep
		upkeep = {
			energy = 10
			volatile_motes = 3
			rare_crystals = 3
			exotic_gases = 3
		}
	}

	show_in_tech = "esc_tech_zro_distilleries"

	ai_build_at_chokepoint = no
	ai_weight = {
		weight = 0
		modifier = {
			weight = 5
			owner = {
				resource_income_compare = {
					resource = sr_zro
					value < 2
				}
			}
		}
		modifier = {
			factor = 0
			has_starbase_module = esc_starbase_zro_orbital_plant
		}
	}
}

############################################################
###                Nanite Orbital Plant                  ###
############################################################

esc_starbase_nanite_factory = {
	icon = GFX_esc_starbase_nanite_plant
	section = REFINERY_STARBASE_SECTION
	construction_days = 180
	initial = no

	potential = {
		owner = { has_technology = esc_tech_synthetic_lifeform_studies }
		NOT = { has_global_flag = ESC_GLOBAL_FLAG_nanite_weapons_forbidden }
	}

	resources = {
		category = starbase_modules
		cost = {
			alloys = 150
			rare_crystals = 50
			exotic_gases = 50
		}
		# resource production
		produces = {
			nanites = 6
		}
		produces = {
			trigger = { solar_system = { ESC_TRIGGER_system_has_nanites = yes } }
			nanites = 3
		}
		# upkeep
		upkeep = {
			energy = 6
			alloys = 10
		}
	}

	show_in_tech = "esc_tech_synthetic_lifeform_studies"

	ai_build_at_chokepoint = no
	ai_weight = {
		weight = 0
		modifier = {
			weight = 5
			owner = {
				resource_income_compare = {
					resource = nanites
					value < 2
				}
			}
		}
		modifier = {
			factor = 0
			has_starbase_module = esc_starbase_nanite_factory
		}
	}
}
