/**
*
* \file AVP_Player.h
*
* Created by Anthony Gregson - 30/08/06
*
* Copyright (C) 2006 Rebellion, All Rights Reserved.
*
* \brief
*
**/

#ifdef ASURA_USE_PRAGMA_ONCE
	#pragma once
#endif

#ifndef __AVP_PLAYER_H__
#define __AVP_PLAYER_H__

#include "Network/Asura_Player.h"

#include "Camera/AVP_External_Camera.h"
#include "Core/AVP_Settings.h"

// Forward declarations
class AVP_ClientEntity_Actor; 

class AVP_Player : public Asura_Entity_Player
{
public:
	AVP_Player();
	virtual ~AVP_Player();

	void Render(void);
	
	void SetCamera(void);
	void SetExternalCameraTarget(Asura_Guid uPrimaryTargetGuid, Asura_Guid uSecondaryTargetGuid, float fInitialDistance);  

	void Update();
	void Reset();

	bool IsLocalPlayer(Asura_Guid uGuid);

	virtual bool HandleMessage(const Asura_Message* pxMessage);

	// This function sets the actor guid here, and also ensures the appropriate MakePlayer (and equivalent unset of predecessor actor) is called.
	void SetPuppetGuid(Asura_Guid uGuid);
	Asura_Guid GetPuppetGuid() const { return m_uPuppetGuid; }

	AVP_Settings::Species GetPuppetSpecies() const;

	// This helper function looks for the multiplayer team in this player's player info
	AVP_Settings::Team GetMultiplayerTeam() const; 

	// Sets how much time the player has to wait before next respawn (probably only relevant to multiplayer games)
	void SetRespawnTimer(float fTimeDelayBeforeRespawning)		 { m_fRespawnTimer = fTimeDelayBeforeRespawning; }

	void SendActorCreateMessage(bool bRespawn);

	static AVP_Player* Create();

private:
	void MakeCommandMessageForServer(void);
	void UpdateAutoCenter(AVP_ClientEntity_Actor* pxActor);
	void UpdateCommandPostCapture(AVP_ClientEntity_Actor* pxActor); 

	Asura_Guid m_uPuppetGuid;
	float m_fIdleTimer;
	float m_fRespawnTimer;

	// Camera to use when in multiplayer limbo states.
	// TODO: Better as a pointer we new only when needed? Seems riskier, although maybe "when needed" just means only in multiplayer, which should be fine.
	AVP_External_Camera m_xExternalCamera;

public:
	/* static members */
	static AVP_Player* FindEntity(Asura_Guid uGuid) { return s_xList.FindEntity(uGuid); }
	static const Asura_Hashed_List<AVP_Player>* GetList() { return &s_xList; }

private:
	/* static data */
	static Asura_Hashed_List<AVP_Player> s_xList;

	typedef Asura_Entity_Player PARENT;
};

#endif//__AVP_PLAYER_H__
