class Pay extends ActionBool
{

	public function SetProperties()
	{
		actionName = 'Pay';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( 'Pay', true, 'LocKey#3537', 'LocKey#3537' );
	}

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

	public static function IsAvailable( device : DoorControllerPS ) : Bool
	{
		if( device.IsDisabled() )
		{
			return false;
		}
		if( device.IsSealed() )
		{
			return false;
		}
		if( !( device.IsLocked() ) )
		{
			return false;
		}
		return true;
	}

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

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

}

class QuickHackToggleOpen extends ActionBool
{
	default m_isQuickHack = true;

	public function SetProperties( isOpen : Bool )
	{
		actionName = 'QuickHackToggleOpen';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( 'QuickHackToggleOpen', isOpen, 'LocKey#365', 'LocKey#366' );
	}

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

	public static function IsAvailable( device : DoorControllerPS, isPlayerRequest : Bool ) : Bool
	{
		if( device.IsDisabled() || device.IsSealed() )
		{
			return false;
		}
		if( device.IsConnectedToBackdoorDevice() || device.ExposeQuickHakcsIfNotConnnectedToAP() )
		{
			return true;
		}
		return false;
	}

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

	public override function GetTweakDBChoiceRecord() : String
	{
		if( TDBID.IsValid( m_objectActionID ) )
		{
			return super.GetTweakDBChoiceRecord();
		}
		else
		{
			if( !( ( ( Bool )prop.first ) ) )
			{
				return "HackOpen";
			}
			else
			{
				return "HackClose";
			}
		}
	}

}

class DoorStatus extends BaseDeviceStatus
{

	public override function SetProperties( const deviceRef : ScriptableDeviceComponentPS )
	{
		super.SetProperties( deviceRef );
		actionName = 'DoorStatus';
		prop.second = ( ( Int32 )( ( ( DoorControllerPS )( deviceRef ) ).GetDoorState() ) );
	}

	public const override function GetCurrentDisplayString() : String
	{
		var str : String;
		if( ( ( Int32 )prop.first ) >= 0 )
		{
			switch( prop.second )
			{
				case -2:
					str = "LocKey#17804";
				break;
				case -1:
					str = "LocKey#17805";
				break;
				case 0:
					str = "LocKey#17806";
				break;
				case 1:
					str = "LocKey#17807";
				break;
				default:
				;
			}
		}
		else
		{
			return super.GetCurrentDisplayString();
		}
		return str;
	}

	public const override function GetStatusValue() : Int32
	{
		if( ( ( Int32 )prop.first ) > 0 )
		{
			return ( ( Int32 )prop.second );
		}
		else
		{
			return ( ( Int32 )prop.first );
		}
	}

	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
	{
		return BaseDeviceStatus.IsAvailable( device );
	}

	public static function IsClearanceValid( clearance : Clearance ) : Bool
	{
		return BaseDeviceStatus.IsClearanceValid( clearance );
	}

	public override function GetTweakDBChoiceRecord() : String
	{
		return "wrong_action";
	}

}

class DoorOpeningToken extends ActionBool
{

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

	public override function GetTweakDBChoiceRecord() : String
	{
		return "Open";
	}

	public static function IsDefaultConditionMet( device : DoorControllerPS, const context : ref< GetActionsContext > ) : Bool
	{
		return ToggleOpen.IsDefaultConditionMet( device, context );
	}

	public static function IsAvailable( device : DoorControllerPS ) : Bool
	{
		return ToggleOpen.IsAvailable( device );
	}

	public static function IsClearanceValid( clearance : Clearance ) : Bool
	{
		return ToggleOpen.IsClearanceValid( clearance );
	}

}

class ToggleOpen extends ActionBool
{

	public function SetProperties( isOpen : Bool, optional altOpenChoice : CName, optional altCloseChoice : CName )
	{
		var nameOnTrue : CName;
		var nameOnFalse : CName;
		actionName = 'ToggleOpen';
		if( IsNameValid( altOpenChoice ) && IsNameValid( altCloseChoice ) )
		{
			nameOnTrue = altOpenChoice;
			nameOnFalse = altCloseChoice;
		}
		else
		{
			nameOnTrue = 'LocKey#273';
			nameOnFalse = 'LocKey#274';
		}
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( 'Open', isOpen, nameOnTrue, nameOnFalse );
	}

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

	public static function IsAvailable( device : DoorControllerPS, isPlayerRequest : Bool ) : Bool
	{
		if( device.IsDisabled() )
		{
			return false;
		}
		if( device.IsSealed() )
		{
			return false;
		}
		if( ( device.IsLocked() && device.IsClosed() ) && !( device.IsPlayerAuthorized() ) )
		{
			return false;
		}
		return true;
	}

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

	public override function GetTweakDBChoiceRecord() : String
	{
		if( !( ( ( Bool )prop.first ) ) )
		{
			return "Open";
		}
		else
		{
			return "Close";
		}
	}

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

}

class SetOpened extends ActionBool
{

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

	public override function GetTweakDBChoiceRecord() : String
	{
		return "Open";
	}

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

	public static function IsAvailable( device : DoorControllerPS, isPlayerRequest : Bool ) : Bool
	{
		if( device.IsDisabled() )
		{
			return false;
		}
		if( device.IsSealed() )
		{
			return false;
		}
		if( device.IsOpen() )
		{
			return false;
		}
		return true;
	}

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

}

class SetClosed extends ActionBool
{

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

	public override function GetTweakDBChoiceRecord() : String
	{
		return "Close";
	}

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

	public static function IsAvailable( device : DoorControllerPS ) : Bool
	{
		if( device.IsDisabled() )
		{
			return false;
		}
		if( device.IsSealed() )
		{
			return false;
		}
		if( device.IsLocked() )
		{
			return false;
		}
		if( device.IsLogicallyClosed() )
		{
			return false;
		}
		return true;
	}

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

}

class ToggleLock extends ActionBool
{
	protected var m_shouldOpen : Bool;
	default m_shouldOpen = true;

	public virtual function SetProperties( isLocked : Bool )
	{
		actionName = 'ToggleLock';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( 'Lock', isLocked, 'LocKey#275', 'LocKey#276' );
	}

	public function SetShouldOpen( shouldOpen : Bool )
	{
		m_shouldOpen = shouldOpen;
	}

	public const function ShouldOpen() : Bool
	{
		return m_shouldOpen;
	}

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

	public static function IsAvailable( device : DoorControllerPS, requestType : gamedeviceRequestType ) : Bool
	{
		if( device.IsDisabled() || device.IsSealed() )
		{
			return false;
		}
		if( requestType == gamedeviceRequestType.Internal )
		{
			return true;
		}
		if( device.canPlayerToggleLockState() )
		{
			return true;
		}
		return false;
	}

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

	public override function GetTweakDBChoiceRecord() : String
	{
		if( !( ( ( Bool )prop.first ) ) )
		{
			return "Lock";
		}
		else
		{
			return "Unlock";
		}
	}

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

}

class ToggleSeal extends ActionBool
{

	public function SetProperties( isSealed : Bool )
	{
		actionName = 'ToggleSeal';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( 'Seal', isSealed, 'LocKey#277', 'LocKey#278' );
	}

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

	public static function IsAvailable( device : DoorControllerPS ) : Bool
	{
		if( device.IsDisabled() )
		{
			return false;
		}
		if( !( device.canPlayerToggleSealState() ) )
		{
			return false;
		}
		return true;
	}

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

	public override function GetTweakDBChoiceRecord() : String
	{
		if( !( ( ( Bool )prop.first ) ) )
		{
			return "Seal";
		}
		else
		{
			return "Unseal";
		}
	}

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

}

class ForceOpen extends ActionBool
{

	public function SetProperties()
	{
		actionName = 'ForceOpen';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( 'ForceOpen', true, 'LocKey#537', 'LocKey#537' );
	}

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

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

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

	public override function GetTweakDBChoiceRecord() : String
	{
		return "force_open";
	}

}

class ForceLockElevator extends ToggleLock
{

	public function SetProperties()
	{
		actionName = 'ForceLockElevator';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( 'ForceLockElevator', true, 'LocKey#275', 'LocKey#276' );
	}

	public constexpr static function IsAvailable( device : DoorControllerPS, requestType : gamedeviceRequestType ) : Bool
	{
		return true;
	}

}

class ForceUnlockAndOpenElevator extends ToggleLock
{

	public function SetProperties()
	{
		actionName = 'ForceUnlockAndOpenElevator';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( 'ForceUnlockAndOpenElevator', false, 'LocKey#275', 'LocKey#276' );
	}

	public constexpr static function IsAvailable( device : DoorControllerPS, requestType : gamedeviceRequestType ) : Bool
	{
		return true;
	}

}

class PlayerUnauthorized extends ActionBool
{
	protected var m_isLiftDoor : Bool;

	public function SetProperties( isLift : Bool )
	{
		m_isLiftDoor = isLift;
		actionName = 'PlayerUnauthorized';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( 'PlayerUnauthorized', false, 'LocKey#78162', 'LocKey#78162' );
	}

	public function CreateInteraction( device : DoorControllerPS, optional actions : array< DeviceAction > )
	{
		m_hasInteraction = true;
		interactionChoice.choiceMetaData.tweakDBName = GetTweakDBChoiceRecord();
		ChoiceTypeWrapper.SetType( interactionChoice.choiceMetaData.type, gameinteractionsChoiceType.CheckFailed );
		DeviceHelper.PushActionsIntoInteractionChoice( interactionChoice, actions );
	}

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

	public static function IsAvailable( device : DoorControllerPS ) : Bool
	{
		if( !( device.IsON() ) || device.IsSealed() )
		{
			return false;
		}
		return true;
	}

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

	public override function GetTweakDBChoiceRecord() : String
	{
		if( m_isLiftDoor )
		{
			return "UnauthorizedElevator";
		}
		else
		{
			return "Unauthorized";
		}
	}

}

class QuestForceOpen extends ActionBool
{

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

}

class QuestForceClose extends ActionFloat
{

	public export override function GetProperties() : array< DeviceActionProperty >
	{
		var arr : array< DeviceActionProperty >;
		arr.PushBack( prop );
		return arr;
	}

	public function SetProperties( speedMultiplier : Float )
	{
		actionName = 'ForceClose';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Float( 'ClosingSpeedMultiplier', speedMultiplier );
	}

	public function GetValue() : Float
	{
		return ( ( Float )prop.first );
	}

}

class QuestForceCloseImmediate extends ActionBool
{

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

}

class QuestForceOpenScene extends ActionBool
{

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

}

class QuestForceCloseScene extends ActionBool
{

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

}

class QuestForceLock extends ActionBool
{

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

}

class QuestForceUnlock extends ActionBool
{

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

}

class QuestForceSeal extends ActionBool
{

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

}

class QuestForceUnseal extends ActionBool
{

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

}

