//////////////////////////////////////////////////////////////////////////////
//
// AVP_ServerEntity_PlayerProxy.h
//
// Copyright (C) 2007 Rebellion. All Rights Reserved.
//
//////////////////////////////////////////////////////////////////////////////

// B E G I N   F I L E   W R A P P E R ///////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef __AVP_SERVERENTITY_PLAYERPROXY_H__
#define __AVP_SERVERENTITY_PLAYERPROXY_H__ 1

// E N D   F I L E   W R A P P E R ///////////////////////////////////////////

// I N C L U D E S ///////////////////////////////////////////////////////////

// asura
#include "Entity/Asura_Entity.h"
#include "Network/Asura_Guid.h"

// F O R W A R D   D E C L A R A T I O N S ///////////////////////////////////

class AVP_ServerEntity_Actor;

//////////////////////////////////////////////////////////////////////////////
//
// AVP_ServerEntity_PlayerProxy
//
//////////////////////////////////////////////////////////////////////////////

class AVP_ServerEntity_PlayerProxy : public Asura_Entity_Server
{
    typedef Asura_Entity_Server PARENT;

public:
    AVP_ServerEntity_PlayerProxy( Asura_Guid uGuid );
    virtual ~AVP_ServerEntity_PlayerProxy();

    virtual bool HasClientEntities() const { return false; }
    virtual bool IsFilledFromChunkBuffer() const { return false; }
    virtual bool CanBeSavedToChunk()       const { return true;  }
    virtual void ReadFromChunkStream( Asura_Chunk_Stream& xStream );
    virtual void WriteToChunkStream( Asura_Chunk_Stream& xStream ) const;

	virtual void PostLoadInitialise();

#ifdef ASURA_TOOLS
	virtual bool SupportsCustomEvents() const { return false; }
	virtual int GetNumCustomEvents() const { return 0; }
	virtual unsigned short* GetCustomEvent(int iIndex) { return NULL; }
	virtual void GetCustomEventName(int iEventIndex, Asura_String& xEventName) {}
#endif

	static AVP_ServerEntity_PlayerProxy* Create( const Asura_Guid uGuid );
	static AVP_ServerEntity_PlayerProxy* FindEntity(const Asura_Guid uGuid) { return s_xList.FindEntity(uGuid); }
	static const Asura_Hashed_List<AVP_ServerEntity_PlayerProxy>*	GetList(void) { return &s_xList ; }

protected:

	virtual void Update();

	virtual	void OnEntityActivate();
	virtual	void OnEntityDeactivate();

protected:

	virtual void MakeClientUpdateMessage() {}

private:

	void GetAmmoStatus(const AVP_ServerEntity_Actor* pxPlayerActor,  bool& bCurrentWeaponLowAmmo, bool& bBothWeaponLowAmmo, bool& bPrimaryWeaponNoAmmo);

private:
    // Member data.
	u_int m_uPlayerNumber;

	union
	{
		u_int m_uFlagsNotChunked;
		struct
		{
			u_int m_bCurrentWeponLowAmmo	: 1,
				  m_bBothWeaponsLowAmmo		: 1,
				  m_bPrimaryWeaponNoAmmo	: 1,
				  m_bCloaked             	: 1;
		};
	};

	static Asura_Hashed_List<AVP_ServerEntity_PlayerProxy> s_xList;

    enum { CURRENT_CHUNK_VERSION = 0 };

	friend class ToolsAVP_Entity_PlayerProxy;
};

//////////////////////////////////////////////////////////////////////////////
//
// 
//
//////////////////////////////////////////////////////////////////////////////

#endif //__AVP_SERVERENTITY_PLAYERPROXY_H__
