///////////////////////////////////////////////////////////////////////////////
//
// File      : AVP_Rumble_System.h
// Author    : Ali Jakamy
// Created   : 25/03/2009
//
// Copyright (C) 2009 Rebellion. All Rights Reserved
//
///////////////////////////////////////////////////////////////////////////////

#ifndef __AVP_RUMBLE_SYSTEM_H__
#define __AVP_RUMBLE_SYSTEM_H__

#include "Core/Asura_LinkList.h"
#include "Input/Asura_Rumble_System.h"

class AVP_Rumble;

class AVP_Rumble_System
{
public:

	enum AVP_Rumble_Priority
	{
		RUMBLE_PLAY_ALWAYS,
		RUMBLE_PLAY_EXCLUSIVE,

		RUMBLE_PLAY_TOTAL
	};

	enum AVP_Rumble_Motor
	{
		AVP_RUMBLE_MOTOR1,
		AVP_RUMBLE_MOTOR2,
	};

	static void AddPlayer(int iController, Asura_Guid uPlayer);
	static void Initialise();
	static void InitFromBlueprint(Asura_Hash_ID uBlueprintHash);
	static void PlatformSetupRumbleMotor( AVP_Rumble* pxRumble, AVP_Rumble_Motor eMotor, Asura_Handle iRumble);
	static bool FillRumbleStepFromBlueprint(   RUMBLE_BASE_EFFECT& eEffect
											 , RUMBLE_ADJUST&      eAdjust
											 , float&              fMaxMagnitude
											 , float&              fMinMagnitude
											 , float&              fDecay
											 , int&                uNumPlays
											 , Asura_Hash_ID       uBlueprint );

	static void CreateRumbleStep(  RUMBLE_BASE_EFFECT eEffect
								 , RUMBLE_ADJUST      eAdjust
								 , float              fMaxMagnitude
								 , float              fMinMagnitude
								 , float              fDecay
								 , int                uNumPlays
								 , Asura_Handle&      iRumble );

	static AVP_Rumble* CreateRumble( Asura_Hash_ID uBlueprintHash );

	static Asura_Handle SetupRumble (Asura_Hash_ID uPlatformBlueprintHash, Asura_Hash_ID uBlueprintHash, AVP_Rumble_Motor eMotor, Asura_Hash_ID uStep1, Asura_Hash_ID uStep2, Asura_Hash_ID uStep3, Asura_Hash_ID uBlueprinthash );
	
	static void SetupRumblePriority( Asura_Hash_ID uPlatformBlueprintHash, Asura_Hash_ID uBlueprintHash);

	static void Reset();
	static void Shutdown();
	static void FreeRumbleList();
	static void Update(bool bForced = false);
	static void Pause();
	static void Unpause();
	static void StopAll();

	static void PauseRumble(Asura_Handle iHandle);
	static void UnpauseRumble(Asura_Handle iHandle);
	static void StopRumble(Asura_Handle iHandle);
	static void StopHUDRumble(Asura_Handle iHandle);

	static bool IsHUDRumbleActive(Asura_Handle iHandle);

	static Asura_Handle  AddHUDRumble(Asura_Hash_ID uBlueprintHash, bool bPause = false, float fDecay = 1.0f);
	static Asura_Handle  AddExclusiveHUDRumble(AVP_Rumble* pxRumble, bool bPause = false, float fDecay = 1.0f);
	static Asura_Handle  AddWorldRumble( Asura_Hash_ID uBlueprintHash, const Asura_Vector_3& xPosition, 
										 float fOuterRadius,           float fInnerRadius, 
										 int   iEffectPlays = 1,       float fMaxMagnitude = 1.0f, 
										 float fMinMagnitude = 0.0f,   float fDecay = 1.0f,  bool bPause = false );
	static Asura_Hash_ID GetPlatformBuleprint( Asura_Hash_ID uBlueprint );
	static bool          GetPlatformSupport2Motors();
	static AVP_Rumble*   GetRumbleWithHash(Asura_Hash_ID uRumbleHash);

protected:
	static float s_fUpdateInterval;
	static Asura_LinkList <AVP_Rumble*> s_xRumbleList;

	static Asura_Hash_ID s_uStep1Motor1; 
	static Asura_Hash_ID s_uStep2Motor1; // "Step2 Small"
	static Asura_Hash_ID s_uStep3Motor1; // "Step3 Small"

	static Asura_Hash_ID s_uStep1Motor2; // "Step1 Large"
	static Asura_Hash_ID s_uStep2Motor2; // "Step2 Large"
	static Asura_Hash_ID s_uStep3Motor2; // "Step3 Large"

};

class AVP_Rumble : public Asura_Platform_Rumble
{
public:
	AVP_Rumble_System::AVP_Rumble_Priority m_ePriority;
	Asura_Hash_ID                          m_uRumbleHash;
	Asura_Handle                           iHandle;
	void PlatformSetup();
};

#endif //__AVP_RUMBLE_SYSTEM_H__


