class SecurityGateLock extends InteractiveDevice
{
	default m_controllerTypeName = 'SecurityGateLockController';
	private var m_enteringArea : TriggerComponent;
	private var m_centeredArea : TriggerComponent;
	private var m_leavingArea : TriggerComponent;

	protected event OnRequestComponents( ri : EntityRequestComponentsInterface )
	{
		super.OnRequestComponents( ri );
		EntityRequestComponentsInterface.RequestComponent( ri, 'enteringArea', 'gameStaticTriggerAreaComponent', false );
		EntityRequestComponentsInterface.RequestComponent( ri, 'centeredArea', 'gameStaticTriggerAreaComponent', false );
		EntityRequestComponentsInterface.RequestComponent( ri, 'leavingArea', 'gameStaticTriggerAreaComponent', false );
	}

	protected event OnTakeControl( ri : EntityResolveComponentsInterface )
	{
		m_enteringArea = ( ( TriggerComponent )( EntityResolveComponentsInterface.GetComponent( ri, 'enteringArea' ) ) );
		m_centeredArea = ( ( TriggerComponent )( EntityResolveComponentsInterface.GetComponent( ri, 'centeredArea' ) ) );
		m_leavingArea = ( ( TriggerComponent )( EntityResolveComponentsInterface.GetComponent( ri, 'leavingArea' ) ) );
		super.OnTakeControl( ri );
		m_controller = ( ( SecurityGateLockController )( EntityResolveComponentsInterface.GetComponent( ri, 'controller' ) ) );
	}

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

	private const override function GetController() : SecurityGateLockController
	{
		return ( ( SecurityGateLockController )( m_controller ) );
	}

	protected event OnAreaEnter( evt : AreaEnteredEvent )
	{
		GetDevicePS().UpdateTrespassersList( evt, true );
	}

	protected event OnAreaExit( evt : AreaExitedEvent )
	{
		GetDevicePS().UpdateTrespassersList( evt, false );
	}

	protected event OnUpdateGatePosition( evt : UpdateGatePosition )
	{
		UpdateGatePosition();
	}

	private function UpdateGatePosition()
	{
		var playEvent : gameTransformAnimationPlayEvent;
		var animationName : CName;
		playEvent = new gameTransformAnimationPlayEvent;
		if( GetDevicePS().IsLocked() )
		{
			animationName = 'lock';
		}
		else
		{
			animationName = 'unlock';
		}
		playEvent.timeScale = 1.0;
		playEvent.looping = false;
		playEvent.timesPlayed = 1;
		playEvent.animationName = animationName;
		QueueEvent( playEvent );
	}

}

