2012-02-13 16:47:03 -05:00
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "cPawn.h"
|
2011-12-31 23:55:17 -05:00
|
|
|
#include "cSurvivalInventory.h"
|
|
|
|
#include "cCreativeInventory.h"
|
2012-01-29 14:28:19 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
class cGroup;
|
|
|
|
class cWindow;
|
|
|
|
class cInventory;
|
|
|
|
class cClientHandle;
|
2011-12-31 23:55:17 -05:00
|
|
|
|
|
|
|
|
2012-02-13 16:47:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cPlayer : public cPawn //tolua_export
|
2011-10-03 14:41:19 -04:00
|
|
|
{ //tolua_export
|
|
|
|
public:
|
|
|
|
CLASS_PROTOTYPE();
|
|
|
|
|
2012-02-01 17:38:03 -05:00
|
|
|
cPlayer(cClientHandle* a_Client, const AString & a_PlayerName);
|
2011-10-03 14:41:19 -04:00
|
|
|
virtual ~cPlayer();
|
|
|
|
|
2011-11-01 17:57:08 -04:00
|
|
|
virtual void Initialize( cWorld* a_World ); //tolua_export
|
|
|
|
|
2012-02-13 16:47:03 -05:00
|
|
|
virtual cPacket * GetSpawnPacket(void) const override;
|
|
|
|
virtual void Tick(float a_Dt) override;
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
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 13:45:28 -05:00
|
|
|
inline cInventory & GetInventory() { if(GetGameMode() == 0) return *m_Inventory; else return *m_CreativeInventory; } //tolua_export
|
2011-12-27 21:10:05 -05: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 13:28:21 -05:00
|
|
|
void LoginSetGameMode( int a_GameMode );
|
2011-11-09 17:17:30 -05:00
|
|
|
void SetIP( std::string a_IP );
|
2011-11-01 16:09:13 -04:00
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
// Tries to move to a new position, with collision checks and stuff
|
2011-12-27 21:10:05 -05:00
|
|
|
virtual void MoveTo( const Vector3d & a_NewPos ); //tolua_export
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
cWindow* GetWindow() { return m_CurrentWindow; }
|
|
|
|
void OpenWindow( cWindow* a_Window );
|
2011-12-25 20:07:35 -05:00
|
|
|
void CloseWindow(char a_WindowType);
|
2011-10-03 14:41:19 -04: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 17:38:03 -05:00
|
|
|
const AString & GetName(void) const; //tolua_export
|
|
|
|
void SetName(const AString & a_Name); //tolua_export
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
typedef std::list< cGroup* > GroupList;
|
2012-01-30 11:47:26 -05:00
|
|
|
typedef std::list< std::string > StringList;
|
2011-10-03 14:41:19 -04: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 15:56:42 -05:00
|
|
|
StringList GetResolvedPermissions(); // >> EXPORTED IN MANUALBINDINGS <<
|
2011-11-02 16:19:57 -04:00
|
|
|
bool IsInGroup( const char* a_Group ); //tolua_export
|
2011-10-03 14:41:19 -04:00
|
|
|
|
2012-02-13 16:47:03 -05:00
|
|
|
AString GetColor(void) const; //tolua_export
|
2011-10-03 14:41:19 -04:00
|
|
|
|
|
|
|
void TossItem( bool a_bDraggingItem, int a_Amount = 1 ); //tolua_export
|
|
|
|
|
|
|
|
void Heal( int a_Health ); //tolua_export
|
2011-12-29 10:31:48 -05:00
|
|
|
void Feed( short a_Food );
|
2011-10-03 14:41:19 -04: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 16:54:08 -05:00
|
|
|
bool MoveToWorld( const char* a_WorldName ); //tolua_export
|
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
bool SaveToDisk();
|
|
|
|
bool LoadFromDisk();
|
2012-01-30 11:47:26 -05:00
|
|
|
void LoadPermissionsFromDisk(); //tolua_export
|
2011-11-01 16:09:13 -04:00
|
|
|
|
2011-11-02 16:19:57 -04:00
|
|
|
const char* GetLoadedWorldName();
|
2011-12-28 16:00:35 -05:00
|
|
|
|
|
|
|
void UseEquippedItem();
|
2011-12-27 21:10:05 -05:00
|
|
|
|
2011-11-01 16:09:13 -04:00
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
protected:
|
|
|
|
struct sPlayerState;
|
|
|
|
sPlayerState* m_pState;
|
|
|
|
|
|
|
|
bool m_bVisible;
|
|
|
|
|
|
|
|
float m_LastGroundHeight;
|
|
|
|
bool m_bTouchGround;
|
|
|
|
double m_Stance;
|
2011-12-31 23:55:17 -05:00
|
|
|
cSurvivalInventory* m_Inventory;
|
|
|
|
cCreativeInventory* m_CreativeInventory;
|
2011-10-03 14:41:19 -04:00
|
|
|
cWindow* m_CurrentWindow;
|
|
|
|
|
|
|
|
float m_TimeLastPickupCheck;
|
|
|
|
|
|
|
|
void ResolvePermissions();
|
|
|
|
|
|
|
|
void ResolveGroups();
|
|
|
|
char m_Color;
|
|
|
|
|
2011-11-01 16:09:13 -04:00
|
|
|
float m_LastBlockActionTime;
|
2011-11-10 11:30:14 -05:00
|
|
|
int m_LastBlockActionCnt;
|
2011-11-01 16:09:13 -04:00
|
|
|
int m_GameMode;
|
2011-11-09 17:17:30 -05:00
|
|
|
std::string m_IP;
|
2011-11-01 16:09:13 -04:00
|
|
|
|
2011-12-25 23:06:29 -05:00
|
|
|
long long m_LastPlayerListTime;
|
2011-12-27 13:39:06 -05:00
|
|
|
static const unsigned short PLAYER_LIST_TIME_MS = 1000; // 1000 = once per second
|
2011-12-25 23:06:29 -05:00
|
|
|
|
2011-10-03 14:41:19 -04:00
|
|
|
cClientHandle* m_ClientHandle;
|
|
|
|
}; //tolua_export
|