class SniperNestController extends SensorDeviceController
{

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

}

class SniperNestControllerPS extends SensorDeviceControllerPS
{
	default m_deviceName = "LocKey#91723";
	default m_tweakDBRecord = T"Devices.SniperNest";
	default m_tweakDBDescriptionRecord = T"device_descriptions.SecurityTurret";
	default m_canPlayerTakeOverControl = true;
	default m_lookAtPresetVert = T"LookatPreset.TurretVertical";
	default m_lookAtPresetHor = T"LookatPreset.TurretHorizontal";
	default m_canBeInDeviceChain = true;
	default m_disableQuickHacks = true;
	[ category = "Weapon custom override" ]
	private editable var m_vfxNameOnShoot : CName;
	private persistent var m_isRippedOff : Bool;

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

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

	protected override function GameAttached() {}

	public function GetRippedOff() : Bool
	{
		return m_isRippedOff;
	}

	public function SetRippedOff( value : Bool )
	{
		m_isRippedOff = value;
	}

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

	protected override final function SetDeviceState( state : EDeviceStatus )
	{
		super.SetDeviceState( state );
	}

	public const function GetIsUnderControl() : Bool
	{
		return m_isControlledByThePlayer;
	}

	public const function GetVfxNameOnShoot() : String
	{
		return ( ( String )( m_vfxNameOnShoot ) );
	}

	protected function ActionQuestEjectPlayer() : QuestEjectPlayer
	{
		var action : QuestEjectPlayer;
		action = new QuestEjectPlayer;
		action.clearanceLevel = DefaultActionsParametersHolder.GetQuestClearance();
		action.SetUp( this );
		action.SetProperties();
		action.AddDeviceName( m_deviceName );
		return action;
	}

	protected function ActionQuestEnterPlayer() : QuestEnterPlayer
	{
		var action : QuestEnterPlayer;
		action = new QuestEnterPlayer;
		action.clearanceLevel = DefaultActionsParametersHolder.GetQuestClearance();
		action.SetUp( this );
		action.SetProperties();
		action.AddDeviceName( m_deviceName );
		return action;
	}

	protected function ActionQuestEnterNoAnimation() : QuestEnterNoAnimation
	{
		var action : QuestEnterNoAnimation;
		action = new QuestEnterNoAnimation;
		action.clearanceLevel = DefaultActionsParametersHolder.GetQuestClearance();
		action.SetUp( this );
		action.SetProperties();
		action.AddDeviceName( m_deviceName );
		return action;
	}

	protected function ActionQuestExitNoAnimation() : QuestExitNoAnimation
	{
		var action : QuestExitNoAnimation;
		action = new QuestExitNoAnimation;
		action.clearanceLevel = DefaultActionsParametersHolder.GetQuestClearance();
		action.SetUp( this );
		action.SetProperties();
		action.AddDeviceName( m_deviceName );
		return action;
	}

	public function OnQuestEjectPlayer( evt : QuestEjectPlayer ) : EntityNotificationType
	{
		var notifier : ActionNotifier;
		notifier = new ActionNotifier;
		notifier.SetNone();
		Notify( notifier, evt );
		return EntityNotificationType.SendThisEventToEntity;
	}

	public function OnQuestEnterPlayer( evt : QuestEnterPlayer ) : EntityNotificationType
	{
		var notifier : ActionNotifier;
		notifier = new ActionNotifier;
		notifier.SetNone();
		Notify( notifier, evt );
		return EntityNotificationType.SendThisEventToEntity;
	}

	public function OnQuestEnterNoAnimation( evt : QuestEnterNoAnimation ) : EntityNotificationType
	{
		var notifier : ActionNotifier;
		notifier = new ActionNotifier;
		notifier.SetNone();
		Notify( notifier, evt );
		return EntityNotificationType.SendThisEventToEntity;
	}

	public function OnQuestExitNoAnimation( evt : QuestExitNoAnimation ) : EntityNotificationType
	{
		var notifier : ActionNotifier;
		notifier = new ActionNotifier;
		notifier.SetNone();
		Notify( notifier, evt );
		return EntityNotificationType.SendThisEventToEntity;
	}

	public override function GetActions( out actions : array< DeviceAction >, context : GetActionsContext ) : Bool
	{
		var currentAction : ScriptableDeviceAction;
		if( !( super.GetActions( actions, context ) ) )
		{
			return false;
		}
		currentAction = ActionToggleTakeOverControl();
		currentAction.SetInactiveWithReason( m_canPlayerTakeOverControl, "LocKey#7006" );
		actions.PushBack( currentAction );
		SetActionIllegality( actions, m_illegalActions.regularActions );
		return true;
	}

	public override function GetQuestActions( out actions : array< DeviceAction >, const context : ref< GetActionsContext > )
	{
		super.GetQuestActions( actions, context );
		actions.PushBack( ActionQuestEjectPlayer() );
		actions.PushBack( ActionQuestEnterPlayer() );
		actions.PushBack( ActionQuestEnterNoAnimation() );
	}

}

class QuestEjectPlayer extends ActionBool
{

	public function SetProperties()
	{
		actionName = 'EjectPlayer';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( 'QuestEjectPlayer', true, 'QuestEjectPlayer', 'QuestEjectPlayer' );
	}

}

class QuestEnterPlayer extends ActionBool
{

	public function SetProperties()
	{
		actionName = 'EnterPlayer';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( 'QuestEnterPlayer', true, 'QuestEnterPlayer', 'QuestEnterPlayer' );
	}

}

class QuestEnterNoAnimation extends ActionBool
{

	public function SetProperties()
	{
		actionName = 'EnterNoAnimation';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( 'QuestEnterNoAnimation', true, 'QuestEnterNoAnimation', 'QuestEnterNoAnimation' );
	}

}

class QuestExitNoAnimation extends ActionBool
{

	public function SetProperties()
	{
		actionName = 'ExitNoAnimation';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( 'QuestExitNoAnimation', true, 'QuestExitNoAnimation', 'QuestExitNoAnimation' );
	}

}

