class Confess extends Pay
{

	public function SetProperties( displayName : CName )
	{
		actionName = 'Confess';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( actionName, true, displayName, displayName );
	}

	public static function IsDefaultConditionMet( device : ScriptableDeviceComponentPS, const context : ref< GetActionsContext > ) : Bool
	{
		if( IsAvailable( device ) && IsClearanceValid( context.clearance ) )
		{
			return true;
		}
		return false;
	}

	public static function IsAvailable( device : ScriptableDeviceComponentPS ) : Bool
	{
		if( device.IsDisabled() || device.IsUnpowered() )
		{
			return false;
		}
		return true;
	}

	public static function IsClearanceValid( clearance : Clearance ) : Bool
	{
		if( Clearance.IsInRange( clearance, DefaultActionsParametersHolder.GetToggleOnClearance() ) )
		{
			return true;
		}
		return false;
	}

	public override function GetInkWidgetTweakDBID() : TweakDBID
	{
		return T"DevicesUIDefinitions.ConfessDeviceActionWidget";
	}

}

class ConfessionBoothController extends BasicDistractionDeviceController
{

	public const override function GetPS() : ConfessionBoothControllerPS
	{
		return ( ( ConfessionBoothControllerPS )( GetBasePS() ) );
	}

}

class ConfessionBoothControllerPS extends BasicDistractionDeviceControllerPS
{
	default m_deviceName = "LocKey#1942";
	default m_tweakDBRecord = T"Devices.ConfessionBooth";
	default m_tweakDBDescriptionRecord = T"device_descriptions.ConfessionBooth";
	default m_hasAuthorizationModule = true;

	protected event OnInstantiated()
	{
		super.OnInstantiated();
		if( !( IsStringValid( m_deviceName ) ) )
		{
			m_deviceName = "Gameplay-Devices-DisplayNames-ConfessionBooth";
		}
	}

	protected override function Initialize()
	{
		super.Initialize();
	}

	public override function GetActions( out actions : array< DeviceAction >, context : GetActionsContext ) : Bool
	{
		if( !( super.GetActions( actions, context ) ) )
		{
			return false;
		}
		if( Confess.IsDefaultConditionMet( this, context ) )
		{
			actions.PushBack( ActionConfess() );
		}
		SetActionIllegality( actions, m_illegalActions.regularActions );
		return true;
	}

	protected const override function CanCreateAnyQuickHackActions() : Bool
	{
		return true;
	}

	protected override function GetQuickHackActions( out outActions : array< DeviceAction >, const context : ref< GetActionsContext > )
	{
		var currentAction : ScriptableDeviceAction;
		currentAction = ActionGlitchScreen( T"DeviceAction.GlitchScreenSuicide", T"QuickHack.SuicideHackBase" );
		currentAction.SetDurationValue( GetDistractionDuration( currentAction ) );
		outActions.PushBack( currentAction );
		currentAction = ActionGlitchScreen( T"DeviceAction.GlitchScreenBlind", T"QuickHack.BlindHack" );
		currentAction.SetDurationValue( GetDistractionDuration( currentAction ) );
		outActions.PushBack( currentAction );
		currentAction = ActionGlitchScreen( T"DeviceAction.GlitchScreenGrenade", T"QuickHack.GrenadeHackBase" );
		currentAction.SetDurationValue( GetDistractionDuration( currentAction ) );
		outActions.PushBack( currentAction );
		if( !( GlitchScreen.IsDefaultConditionMet( this, context ) ) )
		{
			SetActionsInactiveAll( outActions, "LocKey#7003" );
		}
		currentAction = ActionQuickHackDistraction();
		currentAction.SetObjectActionID( T"DeviceAction.MalfunctionClassHack" );
		currentAction.SetDurationValue( GetDistractionDuration( currentAction ) );
		currentAction.SetInactiveWithReason( QuickHackDistraction.IsDefaultConditionMet( this, context ), "LocKey#7003" );
		outActions.PushBack( currentAction );
		if( IsGlitching() || IsDistracting() )
		{
			SetActionsInactiveAll( outActions, "LocKey#7004" );
		}
		FinalizeGetQuickHackActions( outActions, context );
	}

	public override function GetQuestActions( out outActions : array< DeviceAction >, const context : ref< GetActionsContext > )
	{
		super.GetQuestActions( outActions, context );
	}

	protected virtual function ActionConfess() : Confess
	{
		var action : Confess;
		action = new Confess;
		action.clearanceLevel = DefaultActionsParametersHolder.GetInteractiveClearance();
		action.SetObjectActionID( T"Payment.Confess" );
		action.SetExecutor( GetPlayer( GetGameInstance() ) );
		action.SetUp( this );
		action.SetProperties( 'LocKey#3389' );
		action.AddDeviceName( m_deviceName );
		action.CreateActionWidgetPackage();
		action.SetDurationValue( 1.5 );
		return action;
	}

	public virtual function OnConfess( evt : Confess ) : EntityNotificationType
	{
		var notifier : ActionNotifier;
		if( IsDisabled() )
		{
			return SendActionFailedEvent( evt, evt.GetRequesterID(), "Disabled" );
		}
		if( evt.IsStarted() )
		{
			ExecutePSActionWithDelay( evt, this, evt.GetDurationValue() );
		}
		else
		{
			if( evt.CanPayCost() )
			{
				notifier = new ActionNotifier;
				notifier.SetAll();
				Notify( notifier, evt );
			}
		}
		return EntityNotificationType.DoNotNotifyEntity;
	}

	public const override function GetBlackboardDef() : ConfessionalBlackboardDef
	{
		return GetAllBlackboardDefs().ConfessionalBlackboard;
	}

}

