struct MovableDeviceSetup
{
	instanceeditable persistent var m_numberOfUses : Int32;
	default m_numberOfUses = 1;
}

class MoveObstacle extends ActionBool
{

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

	public constexpr static function IsDefaultConditionMet( device : ScriptableDeviceComponentPS, const context : ref< GetActionsContext > ) : Bool
	{
		return true;
	}

}

class MovableDeviceController extends ScriptableDeviceComponent
{

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

}

class MovableDeviceControllerPS extends ScriptableDeviceComponentPS
{
	default m_deviceName = "MovableDevice";
	default m_tweakDBRecord = T"Devices.MovableDevice";
	default m_tweakDBDescriptionRecord = T"device_descriptions.MovableDevice";
	default m_shouldScannerShowStatus = false;
	default m_shouldScannerShowNetwork = false;
	default m_shouldScannerShowRole = true;
	private instanceeditable persistent var m_MovableDeviceSetup : MovableDeviceSetup;
	protected instanceeditable inlined var m_movableDeviceSkillChecks : DemolitionContainer;

	public function GetActionName() : String
	{
		return TDBID.ToStringDEBUG( m_movableDeviceSkillChecks.m_demolitionCheck.GetAlternativeName() );
	}

	protected override function GetSkillCheckContainerForSetup() : BaseSkillCheckContainer
	{
		return m_movableDeviceSkillChecks;
	}

	public override function GetActions( out actions : array< DeviceAction >, context : GetActionsContext ) : Bool
	{
		var shouldGetAction : Bool;
		var demolitionAction : ActionDemolition;
		shouldGetAction = true;
		if( m_MovableDeviceSetup.m_numberOfUses <= 0 )
		{
			shouldGetAction = false;
		}
		if( shouldGetAction )
		{
			if( m_movableDeviceSkillChecks.m_demolitionCheck.GetDifficulty() == EGameplayChallengeLevel.NONE )
			{
				actions.PushBack( ActionMoveObstacle( m_movableDeviceSkillChecks.m_demolitionCheck.GetAlternativeName() ) );
			}
			else
			{
				demolitionAction = ActionDemolition( context );
				demolitionAction.ResetCaption();
				demolitionAction.CreateInteraction( context.processInitiatorObject, , , m_movableDeviceSkillChecks.m_demolitionCheck.GetAlternativeName() );
				actions.PushBack( demolitionAction );
			}
		}
		SetActionIllegality( actions, m_illegalActions.regularActions );
		return true;
	}

	protected virtual function ActionMoveObstacle( interactionTweak : TweakDBID ) : MoveObstacle
	{
		var action : MoveObstacle;
		action = new MoveObstacle;
		action.clearanceLevel = 2;
		action.SetUp( this );
		action.SetProperties();
		action.AddDeviceName( m_deviceName );
		action.CreateInteraction( , , interactionTweak );
		return action;
	}

	public function OnActionMoveObstacle( evt : MoveObstacle ) : EntityNotificationType
	{
		var notifier : ActionNotifier;
		notifier = new ActionNotifier;
		notifier.SetNone();
		m_MovableDeviceSetup.m_numberOfUses = m_MovableDeviceSetup.m_numberOfUses - 1;
		Notify( notifier, evt );
		return EntityNotificationType.SendThisEventToEntity;
	}

	public override function OnActionDemolition( evt : ActionDemolition ) : EntityNotificationType
	{
		var notifier : ActionNotifier;
		notifier = new ActionNotifier;
		notifier.SetNone();
		super.OnActionDemolition( evt );
		if( evt.IsCompleted() )
		{
			m_MovableDeviceSetup.m_numberOfUses = m_MovableDeviceSetup.m_numberOfUses - 1;
		}
		Notify( notifier, evt );
		return EntityNotificationType.SendThisEventToEntity;
	}

	public function WasDeviceMoved() : Bool
	{
		if( m_MovableDeviceSetup.m_numberOfUses == 0 )
		{
			return true;
		}
		else
		{
			return false;
		}
	}

}

