class LaserDetector extends ProximityDetector
{
	default m_controllerTypeName = 'LaserDetectorController';
	private var m_lasers : MeshComponent[ 2 ];

	protected event OnRequestComponents( ri : EntityRequestComponentsInterface )
	{
		EntityRequestComponentsInterface.RequestComponent( ri, 'laserBottom', 'MeshComponent', false );
		EntityRequestComponentsInterface.RequestComponent( ri, 'laserTop', 'MeshComponent', false );
		EntityRequestComponentsInterface.RequestComponent( ri, m_scanningAreaName, 'gameStaticTriggerAreaComponent', false );
		EntityRequestComponentsInterface.RequestComponent( ri, m_surroundingAreaName, 'gameStaticTriggerAreaComponent', false );
		super.OnRequestComponents( ri );
	}

	protected event OnTakeControl( ri : EntityResolveComponentsInterface )
	{
		m_lasers[ 0 ] = ( ( MeshComponent )( EntityResolveComponentsInterface.GetComponent( ri, 'laserBottom' ) ) );
		m_lasers[ 1 ] = ( ( MeshComponent )( EntityResolveComponentsInterface.GetComponent( ri, 'laserTop' ) ) );
		super.OnTakeControl( ri );
		m_controller = ( ( LaserDetectorController )( EntityResolveComponentsInterface.GetComponent( ri, 'controller' ) ) );
	}

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

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

	protected override function TurnOffDevice()
	{
		var i : Int32;
		super.TurnOffDevice();
		for( i = 0; i < m_lasers.Size(); i += 1 )
		{
			m_lasers[ i ].Toggle( false );
		}
	}

	protected override function TurnOnDevice()
	{
		var i : Int32;
		super.TurnOnDevice();
		for( i = 0; i < m_lasers.Size(); i += 1 )
		{
			m_lasers[ i ].Toggle( true );
		}
	}

	protected override function LockDevice( on : Bool )
	{
		ChangeLasersColor( !( on ) );
	}

	private function ChangeLasersColor( toGreen : Bool )
	{
		if( toGreen )
		{
			SetMeshAppearance( 'hologram' );
		}
		else
		{
			SetMeshAppearance( 'hologram_red' );
		}
	}

}

