class ToiletController extends ScriptableDeviceComponent
{

	public const override function GetPS() : ToiletControllerPS
	{
		return ( ( ToiletControllerPS )( GetBasePS() ) );
	}

}

class ToiletControllerPS extends ScriptableDeviceComponentPS
{
	protected editable var m_flushDuration : Float;
	default m_flushDuration = 5.0f;
	[ customEditor = "AudioEvent" ]
	protected instanceeditable var m_flushSFX : CName;
	protected instanceeditable var m_flushVFXname : CName;
	protected var m_isFlushing : Bool;

	public override function GetActions( out actions : array< DeviceAction >, context : GetActionsContext ) : Bool
	{
		super.GetActions( actions, context );
		if( !( m_isFlushing ) )
		{
			actions.PushBack( ActionFlush() );
		}
		SetActionIllegality( actions, m_illegalActions.regularActions );
		return true;
	}

	public function GetFlushSFX() : CName
	{
		return m_flushSFX;
	}

	public function GetFlushVFX() : CName
	{
		return m_flushVFXname;
	}

	protected function ActionFlush() : Flush
	{
		var action : Flush;
		action = new Flush;
		action.SetUp( this );
		action.SetProperties();
		action.AddDeviceName( GetDeviceName() );
		action.SetDurationValue( m_flushDuration );
		action.CreateInteraction();
		return action;
	}

	public function OnFlush( evt : Flush ) : EntityNotificationType
	{
		UseNotifier( evt );
		if( evt.IsStarted() )
		{
			m_isFlushing = true;
			ExecutePSActionWithDelay( evt, this, evt.GetDurationValue() );
		}
		else
		{
			m_isFlushing = false;
		}
		return EntityNotificationType.SendThisEventToEntity;
	}

}

