class ActivatedDeviceNPC extends ActivatedDeviceTransfromAnim
{
	default m_controllerTypeName = 'ActivatedDeviceNPCController';
	instanceeditable var m_hasProperAnimations : Bool;

	protected event OnRequestComponents( ri : EntityRequestComponentsInterface )
	{
		super.OnRequestComponents( ri );
		EntityRequestComponentsInterface.RequestComponent( ri, 'ui', 'worlduiWidgetComponent', false );
	}

	protected event OnTakeControl( ri : EntityResolveComponentsInterface )
	{
		m_uiComponent = ( ( worlduiWidgetComponent )( EntityResolveComponentsInterface.GetComponent( ri, 'ui' ) ) );
		super.OnTakeControl( ri );
		m_controller = ( ( ActivatedDeviceNPCController )( EntityResolveComponentsInterface.GetComponent( ri, 'controller' ) ) );
	}

	protected const override function GetController() : ActivatedDeviceNPCController
	{
		return ( ( ActivatedDeviceNPCController )( m_controller ) );
	}

	public const override function GetDevicePS() : ActivatedDeviceNPCControllerPS
	{
		return GetController().GetPS();
	}

	protected event OnActivateDevice( evt : ActivateDevice )
	{
		super.OnActivateDevice( evt );
		EnterWorkspot( GetDevicePS().GetSpawnedNPC(), false, , , 'activated' );
	}

	protected event OnSpiderbotOrderCompletedEvent( evt : SpiderbotOrderCompletedEvent )
	{
		super.OnSpiderbotOrderCompletedEvent( evt );
		EnterWorkspot( GetDevicePS().GetSpawnedNPC(), false, , , 'activated' );
		if( m_uiComponent != NULL )
		{
			m_uiComponent.Toggle( false );
		}
	}

	protected event OnGameEntitySpawnerEvent( evt : gameEntitySpawnerEvent )
	{
		EnterWorkspot( GetDevicePS().GetSpawnedNPC(), false, , , 'idle' );
	}

	protected virtual function EnterWorkspot( activator : GameObject, optional freeCamera : Bool, optional componentName : CName, optional deviceData : CName, optional typeOfEvent : CName )
	{
		var workspotSystem : WorkspotGameSystem;
		workspotSystem = GameInstance.GetWorkspotSystem( activator.GetGame() );
		if( typeOfEvent == 'idle' )
		{
			workspotSystem.PlayInDevice( this, activator, 'lockedCamera', 'npcIdleWorkspot', 'deviceIdleWorkspot', , 0.01 );
		}
		else if( typeOfEvent == 'activated' )
		{
			workspotSystem.PlayInDevice( this, activator, 'lockedCamera', 'npcActivatedWorkspot', 'deviceActivatedWorkspot', , 0.01 );
			if( !( m_hasProperAnimations ) )
			{
				GetDevicePS().GetSpawnedNPC().HideIrreversibly();
			}
		}
	}

	protected event OnWorkspotFinished( componentName : CName )
	{
		super.OnWorkspotFinished( componentName );
	}

	public const override function DeterminGameplayRole() : EGameplayRole
	{
		return EGameplayRole.Distract;
	}

}

