
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_Vehicle_InputHandler.cpp
// Author : Chris Wallace
// Date   : 17-Apr-2007
//
// Copyright (C) 2007 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// Include files...
////////////////////////////////////////////////////////////////////////////////

#include "Core/Asura.h"

// This file's header...
#include "Actor/Vehicles/AVP_Vehicle_InputHandler.h"

#include "Actor/AVP_Actor_CameraHandler.h"
#include "Entity/PhysicalObject/Actor/Vehicles/AVP_ClientActor_Vehicle.h"
#include "Moves/AVP_Movement_System.h"
#include "Moves/AVP_Moves.h"


////////////////////////////////////////////////////////////////////////////////
// Function     : AVP_Actor_InputHandler::UpdateMovementInput
// Author       : Chris Wallace
// Date         : 17-Apr-2007
////////////////////////////////////////////////////////////////////////////////

void AVP_Vehicle_InputHandler::UpdateMovementInput(AVP_ClientEntity_Actor& xClient)
{
	const AVP_Movement_System*	pxMovementSystem	= static_cast<const AVP_Movement_System*>(xClient.GetMovementSystem());
	const AVP_Move*				pxCurrentMove		= (pxMovementSystem == NULL) ? NULL : static_cast<const AVP_Move*>(pxMovementSystem->GetCurrentMove());
	const float					fForwardsBackwards	= GetControlMapValue(FORWARDS_BACKWARDS);
	const float					fStrafe				= GetControlMapValue(STRAFE_LEFT_RIGHT);

	float						fMagnitude;

	// Create the vector from the control-map...
	m_xMovementInput.x		= fStrafe;
	m_xMovementInput.y		= 0.0f;
	m_xMovementInput.z		= fForwardsBackwards;

	// Normalise the movement AND re-apply the scale...
	fMagnitude	= m_xMovementInput.Normalise();
	if(fMagnitude == 0.0f || (pxCurrentMove && pxCurrentMove->IsDisableMovement()))
	{
		m_xMovementInput.Zero();
	}
	else if(fMagnitude < 1.0f)
	{
		m_xMovementInput	*= fMagnitude;
	}
}

/// End of function 'AVP_Actor_InputHandler::UpdateMovementInput'. ///



////////////////////////////////////////////////////////////////////////////////
// Public functions...
////////////////////////////////////////////////////////////////////////////////


/// End of file. ///
