abstract class TurretTransition extends DefaultTransition
{

	protected virtual function EnterWorkspot( game : GameInstance, turret : GameObject, activator : GameObject, optional freeCamera : Bool, optional componentName : CName, optional deviceData : CName )
	{
		var workspotSystem : WorkspotGameSystem;
		var playerStateMachineBlackboard : IBlackboard;
		playerStateMachineBlackboard = GameInstance.GetBlackboardSystem( game ).GetLocalInstanced( activator.GetEntityID(), GetAllBlackboardDefs().PlayerStateMachine );
		playerStateMachineBlackboard.SetBool( GetAllBlackboardDefs().PlayerStateMachine.IsInteractingWithDevice, true );
		workspotSystem = GameInstance.GetWorkspotSystem( game );
		workspotSystem.PlayInDevice( turret, activator, 'lockedCamera', componentName, deviceData, , 0.5, WorkspotSlidingBehaviour.DontPlayAtResourcePosition );
	}

	protected const function GetTurretEquippedWeapon( const initData : TurretInitData ) : WeaponObject
	{
		var turret : SecurityTurret;
		var weapon : weak< WeaponObject >;
		turret = ( ( SecurityTurret )( initData.turret ) );
		weapon = turret.GetTurretWeapon();
		return weapon;
	}

}

class TurretBeginEvents extends TurretTransition
{
	const var stateMachineInitData : weak< TurretInitData >;

	public function OnEnter( stateContext : StateContext, scriptInterface : StateGameScriptInterface )
	{
		var turret : SecurityTurret;
		var triggerSide : EDoorTriggerSide;
		turret = ( ( SecurityTurret )( stateMachineInitData.turret ) );
		if( turret )
		{
			triggerSide = turret.GetRipOffTriggerSide( scriptInterface.executionOwner );
			if( triggerSide == EDoorTriggerSide.TWO )
			{
				EnterWorkspot( scriptInterface.executionOwner.GetGame(), stateMachineInitData.turret, scriptInterface.executionOwner, false, 'playerDetachWorkspot', 'deviceWorkspot' );
			}
			else
			{
				EnterWorkspot( scriptInterface.executionOwner.GetGame(), stateMachineInitData.turret, scriptInterface.executionOwner, false, 'playerDetachWorkspotBack', 'deviceDetachWorkspotBack' );
			}
		}
	}

}

class TurretBeginDecisions extends TurretTransition
{

	public const function ExitCondition( const stateContext : StateContext, const scriptInterface : StateGameScriptInterface ) : Bool
	{
		return GetInStateTime() > GetStaticFloatParameterDefault( "durationTime", 3.0 );
	}

}

class TurretRipOffEvents extends TurretTransition
{
	const var stateMachineInitData : weak< TurretInitData >;

	public function OnEnter( stateContext : StateContext, scriptInterface : StateGameScriptInterface )
	{
		var transactionSystem : TransactionSystem;
		transactionSystem = scriptInterface.GetTransactionSystem();
		transactionSystem.TransferItem( ( ( SecurityTurret )( stateMachineInitData.turret ) ), ( ( PlayerPuppet )( scriptInterface.executionOwner ) ), GetTurretEquippedWeapon( stateMachineInitData ).GetItemID(), 1 );
		SendDrawItemRequest( scriptInterface, GetTurretEquippedWeapon( stateMachineInitData ).GetItemID() );
	}

}

class TurretRipOffDecisions extends TurretTransition
{
}

class TurretEndEvents extends TurretTransition
{

	public function OnEnter( stateContext : StateContext, scriptInterface : StateGameScriptInterface )
	{
		var removeEvent : PSMRemoveOnDemandStateMachine;
		var stateMachineIdentifier : StateMachineIdentifier;
		stateMachineIdentifier.definitionName = 'Turret';
		removeEvent = new PSMRemoveOnDemandStateMachine;
		removeEvent.stateMachineIdentifier = stateMachineIdentifier;
		scriptInterface.executionOwner.QueueEvent( removeEvent );
	}

}

class TurretEndDecisions extends TurretTransition
{
}

