// Core
#include "Core/Asura.h"

#ifdef AVP_USE_INPUT_SIMULATOR

// File's header
#include "InputSimulator/behaviours/AVP_InputSimulator_Behaviour_Predator_Idle.h"

// AVP
#include "InputSimulator/AVP_InputSimulator_behaviour_Types.h"

// behaviours
#include "InputSimulator/Behaviours/AVP_InputSimulator_Behaviour_Predator_Patrol.h"

AVP_InputSimulator_Behaviour_Predator_Idle::AVP_InputSimulator_Behaviour_Predator_Idle()
: m_eUpdateState( PATROL )
{
}

void AVP_InputSimulator_Behaviour_Predator_Idle::Update( u_char* ucCurrentInput, float* pfAxisValue ) 
{
	switch( m_eUpdateState )
	{
		case IDLE:
		{
			// Find a child behaviour.
			AVP_InputSimulator_Behaviour* pxBehaviour = GetChildWithType( AVP_INPUTSIMULATOR_BEHAVIOUR_TYPE_PREDATOR_PATROL );
			if( !pxBehaviour )
			{
				// We did not find it, let's create it.
				CreateChildWithType( AVP_INPUTSIMULATOR_BEHAVIOUR_TYPE_PREDATOR_PATROL );
			} 
			else
			{
				// The behaviour is currently running. 
				if( pxBehaviour->IsFinished() )
				{
					// The behaviour has SetFinished(), remove it.
					DestroyAllChildren();
					SetUpdateState( PATROL );
				}
			}
			break;
		}

		case PATROL:
		{
			// Find a child behaviour
			AVP_InputSimulator_Behaviour* pxBehaviour = GetChildWithType( AVP_INPUTSIMULATOR_BEHAVIOUR_TYPE_PREDATOR_PATROL );
			if( !pxBehaviour )
			{
				// We did not find it, let's create it.
				CreateChildWithType( AVP_INPUTSIMULATOR_BEHAVIOUR_TYPE_PREDATOR_PATROL );
			} 
			else
			{
				// The behaviour is currently running. 
				if( pxBehaviour->IsFinished() )
				{
					// The behaviour has SetFinished(), remove it.
					DestroyAllChildren();
					SetUpdateState( PATROL );
				}
			}
			break;
		}
		
		case NOT_SET:
		{
			break;
		}
	}
	
}

#endif // AVP_USE_INPUT_SIMULATOR
