class GameplayLight extends InteractiveDevice
{
	default m_controllerTypeName = 'GameplayLightController';

	protected event OnRequestComponents( ri : EntityRequestComponentsInterface )
	{
		super.OnRequestComponents( ri );
	}

	protected event OnTakeControl( ri : EntityResolveComponentsInterface )
	{
		super.OnTakeControl( ri );
		m_controller = ( ( GameplayLightController )( EntityResolveComponentsInterface.GetComponent( ri, 'controller' ) ) );
	}

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

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

	protected override function CutPower()
	{
		TurnOffLights();
	}

	protected override function TurnOnDevice()
	{
		TurnOnLights();
	}

	protected override function TurnOffDevice()
	{
		TurnOffLights();
	}

	protected override function StartGlitching( glitchState : EGlitchState, optional intensity : Float )
	{
		if( !( GetDevicePS().IsON() ) )
		{
			TurnOnLights();
		}
		StartBlinking();
	}

	protected override function StopGlitching()
	{
		if( !( GetDevicePS().IsON() ) )
		{
			TurnOffLights();
		}
		StopBlinking();
	}

	private function TurnOnLights()
	{
		var evt : ToggleLightEvent;
		evt = new ToggleLightEvent;
		evt.toggle = true;
		QueueEvent( evt );
	}

	private function TurnOffLights()
	{
		var evt : ToggleLightEvent;
		evt = new ToggleLightEvent;
		evt.toggle = false;
		QueueEvent( evt );
	}

	protected function StartBlinking()
	{
		var evt : ChangeCurveEvent;
		evt = new ChangeCurveEvent;
		evt.time = 3.0;
		evt.curve = 'BrokenLamp3';
		evt.loop = true;
		QueueEvent( evt );
	}

	protected function StopBlinking()
	{
		var evt : ChangeCurveEvent;
		evt = new ChangeCurveEvent;
		evt.curve = '';
		evt.loop = false;
		QueueEvent( evt );
	}

	protected export override function IncludeLightsInVisibilityBoundsScript() : Bool
	{
		return true;
	}

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

}

