class CandleDevice extends InteractiveDevice
{

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

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

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

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

	protected override function TurnOffDevice()
	{
		GameObjectEffectHelper.BreakEffectLoopEvent( this, 'fx_candles_lightup' );
		GameObjectEffectHelper.StopEffectEvent( this, 'fx_candles' );
	}

	protected override function TurnOnDevice()
	{
		GameObjectEffectHelper.StartEffectEvent( this, 'fx_candles', false );
	}

	protected event OnAreaEnter( evt : AreaEnteredEvent )
	{
		var puppet : weak< ScriptedPuppet >;
		if( GetDevicePS().IsOFF() )
		{
			return false;
		}
		puppet = ( ( ScriptedPuppet )( EntityGameInterface.GetEntity( evt.activator ) ) );
		if( puppet && puppet.IsBoss() )
		{
			GameObjectEffectHelper.StartEffectEvent( this, 'fx_candles_lightup', false );
		}
	}

	protected event OnAreaExit( evt : AreaExitedEvent )
	{
		var puppet : weak< ScriptedPuppet >;
		if( GetDevicePS().IsOFF() )
		{
			return false;
		}
		puppet = ( ( ScriptedPuppet )( EntityGameInterface.GetEntity( evt.activator ) ) );
		if( puppet && puppet.IsBoss() )
		{
			GameObjectEffectHelper.BreakEffectLoopEvent( this, 'fx_candles_lightup' );
		}
	}

}

