class CoderController extends ScriptableDeviceComponent
{

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

}

class CoderControllerPS extends BasicDistractionDeviceControllerPS
{
	[ tooltip = "Whoever uses this device is granted provided security access level" ]
	private instanceeditable var m_providedAuthorizationLevel : ESecurityAccessLevel;
	default m_providedAuthorizationLevel = ESecurityAccessLevel.ESL_4;

	protected override function ActionAuthorizeUser( optional isForced : Bool ) : AuthorizeUser
	{
		var action : AuthorizeUser;
		action = super.ActionAuthorizeUser( isForced );
		action.CreateInteraction();
		return action;
	}

	public override function OnAuthorizeUser( evt : AuthorizeUser ) : EntityNotificationType
	{
		var secSys : SecuritySystemControllerPS;
		secSys = GetSecuritySystem();
		if( secSys )
		{
			secSys.AuthorizeUser( evt.GetExecutor().GetEntityID(), m_providedAuthorizationLevel );
			return EntityNotificationType.SendThisEventToEntity;
		}
		return EntityNotificationType.DoNotNotifyEntity;
	}

	public override function GetActions( out outActions : array< DeviceAction >, context : GetActionsContext ) : Bool
	{
		var secSys : SecuritySystemControllerPS;
		secSys = GetSecuritySystem();
		if( !( secSys ) )
		{
			return false;
		}
		if( !( secSys.IsUserAuthorized( context.processInitiatorObject.GetEntityID(), m_providedAuthorizationLevel ) ) )
		{
			if( !( secSys.IsEntityBlacklistedForAtLeast( context.processInitiatorObject.GetEntityID(), BlacklistReason.COMBAT ) ) )
			{
				outActions.PushBack( ActionAuthorizeUser( ShouldForceAuthorizeUser( context ) ) );
			}
		}
		return true;
	}

	protected override function GetDeviceIconTweakDBID() : TweakDBID
	{
		return T"DeviceIcons.SecuritySystemDeviceIcon";
	}

	protected override function GetBackgroundTextureTweakDBID() : TweakDBID
	{
		return T"DeviceIcons.SecuritySystemDeviceBackground";
	}

}

