# Comprehensive Sandbox Control - co-op consent effects
#
# Country-scoped. Actor is ROOT.

# Execute the pending action on the saved target country
csc_consent_execute_action = {
	if = {
		limit = { csc_disruptive_enabled = yes }
		if = {
			limit = { has_country_flag = csc_pending_action_annex }
			event_target:csc_pending_target_country = { csc_effect_country_annex = yes }
		}
		if = {
			limit = { has_country_flag = csc_pending_action_puppet }
			event_target:csc_pending_target_country = { csc_effect_country_puppet = yes }
		}
		if = {
			limit = { has_country_flag = csc_pending_action_release_subject }
			event_target:csc_pending_target_country = { csc_effect_country_release_subject = yes }
		}
		if = {
			limit = { has_country_flag = csc_pending_action_grant_independence }
			event_target:csc_pending_target_country = { csc_effect_country_grant_independence = yes }
		}
		if = {
			limit = { has_country_flag = csc_pending_action_set_autonomy }
			event_target:csc_pending_target_country = { csc_effect_country_set_autonomy = yes }
		}
		if = {
			limit = { has_country_flag = csc_pending_action_white_peace }
			event_target:csc_pending_target_country = { csc_effect_country_white_peace = yes }
		}
		if = {
			limit = { has_country_flag = csc_pending_action_faction_invite }
			event_target:csc_pending_target_country = { csc_effect_country_faction_invite = yes }
		}
		if = {
			limit = { has_country_flag = csc_pending_action_faction_remove }
			event_target:csc_pending_target_country = { csc_effect_country_faction_remove = yes }
		}
		if = {
			limit = { has_country_flag = csc_pending_action_leave_faction }
			event_target:csc_pending_target_country = { csc_effect_country_leave_faction = yes }
		}
		if = {
			limit = { has_country_flag = csc_pending_action_create_faction }
			event_target:csc_pending_target_country = { csc_effect_country_create_faction = yes }
		}
		if = {
			limit = { has_country_flag = csc_pending_action_dismantle_faction }
			event_target:csc_pending_target_country = { csc_effect_country_dismantle_faction = yes }
		}
		if = {
			limit = { has_country_flag = csc_pending_action_set_faction_leader }
			event_target:csc_pending_target_country = { csc_effect_country_set_faction_leader = yes }
		}
	}
}

# Clear all pending action flags
csc_consent_clear_flags = {
	clr_country_flag = csc_pending_action_annex
	clr_country_flag = csc_pending_action_puppet
	clr_country_flag = csc_pending_action_release_subject
	clr_country_flag = csc_pending_action_grant_independence
	clr_country_flag = csc_pending_action_set_autonomy
	clr_country_flag = csc_pending_action_white_peace
	clr_country_flag = csc_pending_action_faction_invite
	clr_country_flag = csc_pending_action_faction_remove
	clr_country_flag = csc_pending_action_leave_faction
	clr_country_flag = csc_pending_action_create_faction
	clr_country_flag = csc_pending_action_dismantle_faction
	clr_country_flag = csc_pending_action_set_faction_leader
	clr_country_flag = csc_consent_request_pending
}
