
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_Human_JumpHandler.h
// Author : Anthony Gregson
// Date   : 30/07/08
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
	#pragma once
#endif   // ifdef ASURA_USE_PRAGMA_ONCE

#ifndef __AVP_HUMAN_JUMPHANDLER_H__
#define __AVP_HUMAN_JUMPHANDLER_H__

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

#include "Blueprint/Asura_Blueprint_System.h"

#include "Actor/Vertebrates/AVP_Vertebrate_JumpHandler.h"

////////////////////////////////////////////////////////////////////////////////
// Class declaration...
////////////////////////////////////////////////////////////////////////////////
class Asura_Attractor_Compiled;
class Asura_Blueprint;
class AVP_ClientActor_Human;

class AVP_Human_JumpHandler : public AVP_Vertebrate_JumpHandler
{
public:
	struct MantleDefinition
	{
		float m_fMaxHeight;
		Asura_Hash_ID m_uFirstPersonAnim;
		Asura_Hash_ID m_uThirdPersonAnim;
		bool m_bRequiresJump; // Probably only relevant to the player (it means they have to press the jump button to use the mantle), and may always be true.
	};

	AVP_Human_JumpHandler(AVP_ClientActor_Human& xOwner);
	virtual ~AVP_Human_JumpHandler();

	virtual	void Update();

	virtual bool HandleJump(const float fJumpValue);

	bool IsMantleAvailable() const { return m_bMantleAvailable; }
	bool GetMantleRequiresJump() const { return m_bCurrentMantleRequiresJump; }

	void GetCurrentMantleTargetPosition(Asura_Vector_3& xTargetPos) const { xTargetPos = m_xCurrentMantleTargetPosition; }
	void GetCurrentMantleTargetOrientation(Asura_Quat& xTargetOri) const { xTargetOri = m_xCurrentMantleTargetOrientation; }

	void SendMantleMoveRequest() const;

	bool GetJumpRequestMantleAvailable() const;
	bool GetNonJumpRequestMantleAvailable() const;

	// This is static with a load of parameters so AIs (who don't create an instance of this class) can still make use of the same search functionality.
	// TODO - potentially, we can pass in the mantle definitions instead of the blueprint, so that then individual entities can cache the data. Probably depends on how often this gets called.
	static bool GetMantleTarget(const Asura_Vector_3& xCurrentPosition, const Asura_Quat& xCurrentOrientation, const Asura_Blueprint* pxCurrentWeaponBlueprint, Asura_Vector_3& xTargetPosition, Asura_Quat& xTargetOrientation, Asura_Hash_ID& uFirstPersonAnim, Asura_Hash_ID& uThirdPersonAnim, bool& bRequiresJump);

protected:
	Asura_Hash_ID m_uCurrentMantleFirstPersonAnim;
	Asura_Hash_ID m_uCurrentMantleThirdPersonAnim;
	Asura_Vector_3 m_xCurrentMantleTargetPosition;
	Asura_Quat m_xCurrentMantleTargetOrientation;
	bool m_bCurrentMantleRequiresJump;
	bool m_bMantleAvailable;

private:
	struct CallbackData
	{
		Asura_Vector_3 m_xInitialPosition;
		Asura_Vector_3 m_xFacingDirection;
		MantleDefinition* m_pxMantleDefinitions;
		int m_iNumMantleDefinitions;
		int m_iBestMantleDefinition;
		Asura_Vector_3 m_xBestTargetPosition;
		Asura_Quat m_xBestTargetOri;
	};

	static void GetMantleTarget_Callback(void* pData, const Asura_Attractor_Compiled* const pxAttractor);

	typedef AVP_Vertebrate_JumpHandler PARENT;
};   // End of class 'AVP_Human_JumpHandler'.


// Parameter enumerator for a mantle set.
class AVP_Blueprint_ParameterEnumerator_MantleDefinitions : public Asura_Blueprint_ParameterEnumerator
{
	typedef Asura_Blueprint_ParameterEnumerator PARENT;

public:
	AVP_Blueprint_ParameterEnumerator_MantleDefinitions(AVP_Human_JumpHandler::MantleDefinition* pxMantleStorage, int iMaxEntries);

	virtual void BeginEnumeration();
	virtual bool Enumerate(const u_int uIndex, char const* const szName, const Asura_Value& xValue);
	virtual void EndEnumeration(const bool bSuccess);

protected:
	AVP_Human_JumpHandler::MantleDefinition* m_pxMantleDefinitions;
	int m_iMaximumMantles;
	int m_iCurrentNumMantles;
};

#endif   // ifndef __AVP_HUMAN_JUMPHANDLER_H__


/// End of file. ///
