struct ForkliftSetup
{
	instanceeditable var m_actionActivateName : CName;
	default m_actionActivateName = 'Activate';
	instanceeditable var m_liftingAnimationTime : Float;
	default m_liftingAnimationTime = 2.0f;
	instanceeditable var m_hasDistractionQuickhack : Bool;
	default m_hasDistractionQuickhack = true;
}

class ForkliftController extends ScriptableDeviceComponent
{

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

}

class ForkliftControllerPS extends ScriptableDeviceComponentPS
{
	default m_deviceName = "LocKey#1639";
	default m_tweakDBRecord = T"Devices.Forklift";
	default m_tweakDBDescriptionRecord = T"device_descriptions.Forklift";
	private instanceeditable persistent var m_forkliftSetup : ForkliftSetup;
	private persistent var m_isUp : Bool;
	default m_isUp = false;

	public function GetActionName() : CName
	{
		return m_forkliftSetup.m_actionActivateName;
	}

	public function GetLiftingAnimationTime() : Float
	{
		return m_forkliftSetup.m_liftingAnimationTime;
	}

	public function IsForkliftUp() : Bool
	{
		return m_isUp;
	}

	public function ToggleForkliftPosition()
	{
		m_isUp = !( m_isUp );
	}

	public function ChangeState( newState : EDeviceStatus )
	{
		SetDeviceState( newState );
	}

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

	public override function GetActions( out actions : array< DeviceAction >, context : GetActionsContext ) : Bool
	{
		super.GetActions( actions, context );
		if( !( IsDistracting() ) && IsON() )
		{
			actions.PushBack( ActionActivateDevice( "Activate" ) );
		}
		SetActionIllegality( actions, m_illegalActions.regularActions );
		return true;
	}

	protected const override function CanCreateAnyQuickHackActions() : Bool
	{
		if( m_forkliftSetup.m_hasDistractionQuickhack )
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	protected override function GetQuickHackActions( out actions : array< DeviceAction >, const context : ref< GetActionsContext > )
	{
		var currentAction : ScriptableDeviceAction;
		if( !( IsDistracting() ) && m_forkliftSetup.m_hasDistractionQuickhack )
		{
			currentAction = ActionQuickHackDistraction();
			currentAction.SetObjectActionID( T"DeviceAction.MalfunctionClassHack" );
			currentAction.SetDurationValue( GetDistractionDuration( currentAction ) );
			currentAction.SetInactiveWithReason( IsON(), "LocKey#7005" );
			actions.PushBack( currentAction );
		}
		super.GetQuickHackActions( actions, context );
	}

	protected function ActionActivateDevice( const interactionName : ref< String > ) : ActivateDevice
	{
		var action : ActivateDevice;
		action = new ActivateDevice;
		action.clearanceLevel = DefaultActionsParametersHolder.GetInteractiveClearance();
		action.SetUp( this );
		action.SetProperties( GetActionName() );
		action.AddDeviceName( m_deviceName );
		action.CreateActionWidgetPackage();
		action.CreateInteraction( , interactionName );
		return action;
	}

	protected override function OnActivateDevice( evt : ActivateDevice ) : EntityNotificationType
	{
		super.OnActivateDevice( evt );
		SetDeviceState( EDeviceStatus.OFF );
		ToggleForkliftPosition();
		return EntityNotificationType.SendThisEventToEntity;
	}

}

