2011-10-03 11:41:19 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "cPawn.h"
|
2011-12-31 20:55:17 -08:00
|
|
|
#include "cSurvivalInventory.h"
|
|
|
|
#include "cCreativeInventory.h"
|
2012-01-29 11:28:19 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-03 11:41:19 -07:00
|
|
|
|
|
|
|
class cGroup;
|
|
|
|
class cWindow;
|
|
|
|
class cInventory;
|
|
|
|
class cClientHandle;
|
2011-12-31 20:55:17 -08:00
|
|
|
|
|
|
|
|
2011-10-03 11:41:19 -07:00
|
|
|
class cPlayer : public cPawn //tolua_export
|
|
|
|
{ //tolua_export
|
|
|
|
public:
|
|
|
|
CLASS_PROTOTYPE();
|
|
|
|
|
2012-02-01 14:38:03 -08:00
|
|
|
cPlayer(cClientHandle* a_Client, const AString & a_PlayerName);
|
2011-10-03 11:41:19 -07:00
|
|
|
virtual ~cPlayer();
|
|
|
|
|
2011-11-01 14:57:08 -07:00
|
|
|
virtual void Initialize( cWorld* a_World ); //tolua_export
|
|
|
|
|
2011-10-03 11:41:19 -07:00
|
|
|
virtual void SpawnOn( cClientHandle* a_Target );
|
|
|
|
virtual void Tick(float a_Dt);
|
|
|
|
|
|
|
|
void SetTouchGround( bool a_bTouchGround );
|
|
|
|
inline void SetStance( const double & a_Stance ) { m_Stance = a_Stance; }
|
|
|
|
double GetEyeHeight(); //tolua_export
|
|
|
|
Vector3d GetEyePosition(); //tolua_export
|
|
|
|
inline bool GetFlying() { return m_bTouchGround; } //tolua_export
|
|
|
|
inline const double & GetStance() { return m_Stance; } //tolua_export
|
2012-01-01 10:45:28 -08:00
|
|
|
inline cInventory & GetInventory() { if(GetGameMode() == 0) return *m_Inventory; else return *m_CreativeInventory; } //tolua_export
|
2011-12-27 18:10:05 -08:00
|
|
|
|
|
|
|
virtual void TeleportTo( const double & a_PosX, const double & a_PosY, const double & a_PosZ ); //tolua_export
|
|
|
|
|
|
|
|
int GetGameMode() { return m_GameMode; } //tolua_export
|
|
|
|
std::string GetIP() { return m_IP; } //tolua_export
|
|
|
|
float GetLastBlockActionTime() { return m_LastBlockActionTime; } //tolua_export
|
|
|
|
int GetLastBlockActionCnt() { return m_LastBlockActionCnt; } //tolua_export
|
|
|
|
void SetLastBlockActionCnt( int ); //tolua_export
|
|
|
|
void SetLastBlockActionTime(); //tolua_export
|
|
|
|
void SetGameMode( int a_GameMode ); //tolua_export
|
2011-11-10 10:28:21 -08:00
|
|
|
void LoginSetGameMode( int a_GameMode );
|
2011-11-09 14:17:30 -08:00
|
|
|
void SetIP( std::string a_IP );
|
2011-11-01 13:09:13 -07:00
|
|
|
|
2011-10-03 11:41:19 -07:00
|
|
|
// Tries to move to a new position, with collision checks and stuff
|
2011-12-27 18:10:05 -08:00
|
|
|
virtual void MoveTo( const Vector3d & a_NewPos ); //tolua_export
|
2011-10-03 11:41:19 -07:00
|
|
|
|
|
|
|
cWindow* GetWindow() { return m_CurrentWindow; }
|
|
|
|
void OpenWindow( cWindow* a_Window );
|
2011-12-25 17:07:35 -08:00
|
|
|
void CloseWindow(char a_WindowType);
|
2011-10-03 11:41:19 -07:00
|
|
|
|
|
|
|
cClientHandle* GetClientHandle() { return m_ClientHandle; } //tolua_export
|
|
|
|
void SetClientHandle( cClientHandle* a_Client ) { m_ClientHandle = a_Client; }
|
|
|
|
|
|
|
|
void SendMessage( const char* a_Message ); //tolua_export
|
|
|
|
|
2012-02-01 14:38:03 -08:00
|
|
|
const AString & GetName(void) const; //tolua_export
|
|
|
|
void SetName(const AString & a_Name); //tolua_export
|
2011-10-03 11:41:19 -07:00
|
|
|
|
|
|
|
typedef std::list< cGroup* > GroupList;
|
2012-01-30 08:47:26 -08:00
|
|
|
typedef std::list< std::string > StringList;
|
2011-10-03 11:41:19 -07:00
|
|
|
void AddToGroup( const char* a_GroupName ); //tolua_export
|
|
|
|
bool CanUseCommand( const char* a_Command ); //tolua_export
|
|
|
|
bool HasPermission( const char* a_Permission ); //tolua_export
|
|
|
|
const GroupList & GetGroups(); // >> EXPORTED IN MANUALBINDINGS <<
|
2012-01-31 12:56:42 -08:00
|
|
|
StringList GetResolvedPermissions(); // >> EXPORTED IN MANUALBINDINGS <<
|
2011-11-02 13:19:57 -07:00
|
|
|
bool IsInGroup( const char* a_Group ); //tolua_export
|
2011-10-03 11:41:19 -07:00
|
|
|
|
|
|
|
std::string GetColor(); //tolua_export
|
|
|
|
|
|
|
|
void TossItem( bool a_bDraggingItem, int a_Amount = 1 ); //tolua_export
|
|
|
|
|
|
|
|
void Heal( int a_Health ); //tolua_export
|
2011-12-29 07:31:48 -08:00
|
|
|
void Feed( short a_Food );
|
2011-10-03 11:41:19 -07:00
|
|
|
void TakeDamage( int a_Damage, cEntity* a_Instigator ); //tolua_export
|
|
|
|
void KilledBy( cEntity* a_Killer ); //tolua_export
|
|
|
|
void Respawn(); //tolua_export
|
|
|
|
|
|
|
|
void SetVisible( bool a_bVisible ); //tolua_export
|
|
|
|
bool IsVisible() { return m_bVisible; } //tolua_export
|
|
|
|
|
2011-12-26 13:54:08 -08:00
|
|
|
bool MoveToWorld( const char* a_WorldName ); //tolua_export
|
|
|
|
|
2011-10-03 11:41:19 -07:00
|
|
|
bool SaveToDisk();
|
|
|
|
bool LoadFromDisk();
|
2012-01-30 08:47:26 -08:00
|
|
|
void LoadPermissionsFromDisk(); //tolua_export
|
2011-11-01 13:09:13 -07:00
|
|
|
|
2011-11-02 13:19:57 -07:00
|
|
|
const char* GetLoadedWorldName();
|
2011-12-28 13:00:35 -08:00
|
|
|
|
|
|
|
void UseEquippedItem();
|
2011-12-27 18:10:05 -08:00
|
|
|
|
2011-11-01 13:09:13 -07:00
|
|
|
|
2011-10-03 11:41:19 -07:00
|
|
|
protected:
|
|
|
|
struct sPlayerState;
|
|
|
|
sPlayerState* m_pState;
|
|
|
|
|
|
|
|
bool m_bVisible;
|
|
|
|
|
|
|
|
float m_LastGroundHeight;
|
|
|
|
bool m_bTouchGround;
|
|
|
|
double m_Stance;
|
2011-12-31 20:55:17 -08:00
|
|
|
cSurvivalInventory* m_Inventory;
|
|
|
|
cCreativeInventory* m_CreativeInventory;
|
2011-10-03 11:41:19 -07:00
|
|
|
cWindow* m_CurrentWindow;
|
|
|
|
|
|
|
|
float m_TimeLastPickupCheck;
|
|
|
|
|
|
|
|
void ResolvePermissions();
|
|
|
|
|
|
|
|
void ResolveGroups();
|
|
|
|
char m_Color;
|
|
|
|
|
2011-11-01 13:09:13 -07:00
|
|
|
float m_LastBlockActionTime;
|
2011-11-10 08:30:14 -08:00
|
|
|
int m_LastBlockActionCnt;
|
2011-11-01 13:09:13 -07:00
|
|
|
int m_GameMode;
|
2011-11-09 14:17:30 -08:00
|
|
|
std::string m_IP;
|
2011-11-01 13:09:13 -07:00
|
|
|
|
2011-12-25 20:06:29 -08:00
|
|
|
long long m_LastPlayerListTime;
|
2011-12-27 10:39:06 -08:00
|
|
|
static const unsigned short PLAYER_LIST_TIME_MS = 1000; // 1000 = once per second
|
2011-12-25 20:06:29 -08:00
|
|
|
|
2011-10-03 11:41:19 -07:00
|
|
|
cClientHandle* m_ClientHandle;
|
|
|
|
}; //tolua_export
|