
decision_plnmg_effect_panel = {
	owned_planets_only = yes
	icon = decision_build_planetmega
	ai_weight = { weight = 0 }
	important = yes

	potential = {
		not = { uses_district_set = cosmogenesis_world }
		owner = { has_technology = tech_planetmega_improved }
	}
	effect = { carrier_event = { id = planetmega_effect.100 } }
}
decision_plnmg_effect_panel_advanced = {
	owned_planets_only = yes
	icon = decision_build_planetmega
	ai_weight = { weight = 0 }
	important = yes

	potential = {
		not = { uses_district_set = cosmogenesis_world }
		owner = { has_technology = tech_planetmega_advanced }
	}
	effect = { carrier_event = { id = planetmega_effect.101 } }
}

decision_plnmg_eg_big_catapult = {
	owned_planets_only = yes
	icon = decision_plnmg_extra_galaxy_effect
	ai_weight = { weight = 0 }
	important = yes

	potential = {
		or = {
			has_deposit = d_plnmg_extra_galaxy
			has_carrier_flag = planet_has_plnmg_extra_galaxy
		}
		carrier_is_type = ship
		starbase? = { has_starbase_module = planetmega_eg_catapult }
		owner = {
			not = { has_country_flag = plnmg_exp_big_panel_running }
			has_technology = tech_planetmega_transfer
		}
	}
	allow = {
		custom_tooltip = {
			fail_text = no_eg_espionage_focus
			not = { has_carrier_flag = unlock_eg_espionage }
		}
		custom_tooltip = {
			fail_text = extragalactic_expedition_cooldown_desc
			not = { has_carrier_flag = extragalactic_expedition_cooldown }
		}
	}
	effect = {
		hidden_effect = {
			carrier_event = { id = planetmega_effect.85 }
			owner = { set_country_flag = plnmg_exp_big_panel_running }
		}
	}
}

decision_plnmg_intersys_strike = {
	owned_planets_only = yes
	icon = decision_planet_beam
	ai_weight = { weight = 0 }
	important = yes

	potential = {
		has_deposit = d_plnmg_colossus_assist
		or = {
			has_carrier_flag = district_plnmg_exp_disabled
			owner = { not = { has_policy_flag = district_plnmg_exp_enabled } }
		}
	}
	allow = {
		custom_tooltip = {
			fail_text = plnmg_already_has_megabuild_listed
			not = { exists = event_target:fire_launcher_of_@owner }
		}
		owner = { has_technology = tech_planetmega_colossus }
	}
	effect = {
		tooltip = { owner = { country_event = { id = planetmega_pk.40 } } }
		hidden_effect = { carrier_event = { id = planetmega_pk.39 } }
	}
}
decision_plnmg_ca_excavation = {
	owned_planets_only = yes
	icon = decision_planet_beam
	important = yes

	potential = {
		carrier_is_type = ship
		starbase? = { has_starbase_module = planetmega_ca_excavator }
	}
	allow = {
		custom_tooltip = {
			fail_text = requires_plnmg_ca_orbiting_common_star
			exists = orbit
		}
	}
	effect = { hidden_effect = { carrier_event = { id = planetmega_pk.44 } } }
	ai_weight = { weight = 0 }
}

decision_plnmg_build_defence_ship = {
	icon = decision_landing_ship
	owned_planets_only = yes
	ai_weight = { weight = 0 }
	#important = yes

	potential = {
		carrier_is_type = planet
		or = {
			has_active_building = building_planetmega_ship_builder_1
			has_active_building = building_planetmega_ship_builder_2
		}
		not = { has_carrier_flag = building_plnmg_defence_ship }
		#from = { country_uses_bio_ships = no }
	}
	# allow = {
	# 	or = {
	# 		count_owned_workforce = {
	# 			count > 0
	# 			limit = { has_job_type = plnmg_ship_builder }
	# 		}
	# 		count_owned_workforce = {
	# 			count > 0
	# 			limit = { has_job_type = plnmg_ship_builder_drone }
	# 		}
	# 	}
	# }
	enactment_time = 90
	on_queued = { set_planet_flag = building_plnmg_defence_ship }
	on_unqueued = { remove_planet_flag = building_plnmg_defence_ship }
	effect = {
		custom_tooltip = building_planetmega_ship_builder_extra_desc
		custom_tooltip = building_planetmega_ship_builder_PR_desc
		hidden_effect = {
			remove_planet_flag = building_plnmg_defence_ship
			while = {
				count = value:sv_plnmg_ship_builder_count
				add_deposit = d_plnmg_docked_defence_ship
			}
			# recount
			set_variable = { which = var_plnmg_defence_ship value = 0 }
			every_deposit = {
				limit = { is_deposit_type = d_plnmg_docked_defence_ship }
				prev = { change_variable = { which = var_plnmg_defence_ship value = 1 } }
			}
		}
	}
	resources = {
		category = ships
		cost = {
			minerals = 500
			mult = value:sv_plnmg_defence_ship_cost
		}
	}
}
