2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2012-09-23 18:09:57 -04:00
|
|
|
#include "Pawn.h"
|
|
|
|
#include "Inventory.h"
|
2012-06-14 09:06:06 -04:00
|
|
|
#include "Defines.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cGroup;
|
|
|
|
class cWindow;
|
|
|
|
class cClientHandle;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cPlayer : public cPawn //tolua_export
|
|
|
|
{ //tolua_export
|
|
|
|
public:
|
|
|
|
typedef cPawn super;
|
2012-08-03 07:53:11 -04:00
|
|
|
|
|
|
|
CLASS_PROTOTYPE()
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
cPlayer(cClientHandle * a_Client, const AString & a_PlayerName);
|
|
|
|
virtual ~cPlayer();
|
|
|
|
|
|
|
|
virtual void Initialize( cWorld* a_World ); //tolua_export
|
|
|
|
|
2012-08-24 03:58:26 -04:00
|
|
|
virtual void SpawnOn(cClientHandle & a_Client) override;
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
virtual void Tick(float a_Dt) override;
|
|
|
|
|
|
|
|
void SetTouchGround( bool a_bTouchGround );
|
2012-08-19 15:42:32 -04:00
|
|
|
inline void SetStance( const double a_Stance ) { m_Stance = a_Stance; }
|
2012-06-14 09:06:06 -04:00
|
|
|
double GetEyeHeight(); //tolua_export
|
|
|
|
Vector3d GetEyePosition(); //tolua_export
|
2012-08-19 15:42:32 -04:00
|
|
|
OBSOLETE
|
2012-06-14 09:06:06 -04:00
|
|
|
inline bool GetFlying() { return m_bTouchGround; } //tolua_export
|
2012-08-18 05:56:28 -04:00
|
|
|
inline bool IsOnGround(void) const {return m_bTouchGround; } // tolua_export
|
2012-08-19 15:42:32 -04:00
|
|
|
inline const double GetStance(void) const { return m_Pos.y + 1.62; } //tolua_export // TODO: Proper stance when crouching etc.
|
2012-09-20 09:25:54 -04:00
|
|
|
inline cInventory & GetInventory(void) { return m_Inventory; } //tolua_export
|
|
|
|
inline const cInventory & GetInventory(void) const { return m_Inventory; }
|
2012-08-24 03:58:26 -04:00
|
|
|
|
2012-10-06 12:57:28 -04:00
|
|
|
inline const cItem & GetEquippedItem(void) const {return GetInventory().GetEquippedItem(); } // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
virtual void TeleportTo( const double & a_PosX, const double & a_PosY, const double & a_PosZ ); //tolua_export
|
|
|
|
|
2012-08-24 03:58:26 -04:00
|
|
|
eGameMode GetGameMode(void) const { return m_GameMode; } //tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
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( eGameMode a_GameMode ); //tolua_export
|
|
|
|
void LoginSetGameMode( eGameMode a_GameMode );
|
2012-08-19 15:42:32 -04:00
|
|
|
void SetIP(const AString & a_IP);
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
// Tries to move to a new position, with collision checks and stuff
|
|
|
|
virtual void MoveTo( const Vector3d & a_NewPos ); //tolua_export
|
|
|
|
|
|
|
|
cWindow* GetWindow() { return m_CurrentWindow; }
|
|
|
|
void OpenWindow( cWindow* a_Window );
|
|
|
|
void CloseWindow(char a_WindowType);
|
|
|
|
|
2012-08-19 15:42:32 -04:00
|
|
|
cClientHandle * GetClientHandle(void) const { return m_ClientHandle; } //tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2012-08-19 15:42:32 -04:00
|
|
|
void SendMessage(const AString & a_Message); //tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
const AString & GetName(void) const { return m_PlayerName; } //tolua_export
|
|
|
|
void SetName(const AString & a_Name) { m_PlayerName = a_Name; } //tolua_export
|
|
|
|
|
|
|
|
typedef std::list< cGroup* > GroupList;
|
|
|
|
typedef std::list< std::string > StringList;
|
|
|
|
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() { return m_Groups; } // >> EXPORTED IN MANUALBINDINGS <<
|
|
|
|
StringList GetResolvedPermissions(); // >> EXPORTED IN MANUALBINDINGS <<
|
|
|
|
bool IsInGroup( const char* a_Group ); //tolua_export
|
|
|
|
|
|
|
|
AString GetColor(void) const; //tolua_export
|
|
|
|
|
2012-08-28 17:59:49 -04:00
|
|
|
void TossItem(bool a_bDraggingItem, char a_Amount = 1, short a_CreateType = 0, short a_CreateHealth = 0); //tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
void Heal( int a_Health ); //tolua_export
|
|
|
|
|
|
|
|
/// Returns true if any food has been consumed, false if player "full"
|
2012-07-17 08:02:03 -04:00
|
|
|
bool Feed(short a_Food, float a_Saturation);
|
|
|
|
|
|
|
|
short GetMaxFoodLevel() { return m_MaxFoodLevel; }
|
|
|
|
short GetFoodLevel() { return m_FoodLevel; }
|
|
|
|
|
|
|
|
float GetMaxFoodSaturationLevel() { return m_MaxFoodSaturationLevel; }
|
|
|
|
float GetFoodSaturationLevel() { return m_FoodSaturationLevel; }
|
|
|
|
|
|
|
|
void AddFoodExhaustion(float a_Exhaustion) { m_FoodExhaustionLevel += a_Exhaustion; }
|
2012-06-14 09:06:06 -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
|
|
|
|
|
|
|
|
bool MoveToWorld( const char* a_WorldName ); //tolua_export
|
|
|
|
|
|
|
|
bool SaveToDisk();
|
|
|
|
bool LoadFromDisk();
|
|
|
|
void LoadPermissionsFromDisk(); //tolua_export
|
|
|
|
|
|
|
|
const AString & GetLoadedWorldName() { return m_LoadedWorldName; }
|
|
|
|
|
|
|
|
void UseEquippedItem(void);
|
|
|
|
|
2012-07-17 08:02:03 -04:00
|
|
|
void SendHealth();
|
2012-09-20 09:25:54 -04:00
|
|
|
|
|
|
|
// In UI windows, the item that the player is dragging:
|
|
|
|
bool IsDraggingItem(void) const { return !m_DraggingItem.IsEmpty(); }
|
|
|
|
cItem & GetDraggingItem(void) {return m_DraggingItem; }
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void Destroyed();
|
|
|
|
|
|
|
|
typedef std::map< std::string, bool > PermissionMap;
|
|
|
|
PermissionMap m_ResolvedPermissions;
|
|
|
|
PermissionMap m_Permissions;
|
|
|
|
|
|
|
|
GroupList m_ResolvedGroups;
|
|
|
|
GroupList m_Groups;
|
|
|
|
|
|
|
|
std::string m_PlayerName;
|
|
|
|
std::string m_LoadedWorldName;
|
|
|
|
|
|
|
|
bool m_bVisible;
|
|
|
|
|
2012-07-17 08:02:03 -04:00
|
|
|
short m_FoodLevel;
|
|
|
|
short m_MaxFoodLevel;
|
|
|
|
float m_FoodSaturationLevel;
|
|
|
|
float m_MaxFoodSaturationLevel;
|
|
|
|
float m_FoodExhaustionLevel;
|
|
|
|
char m_FoodTickTimer;
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
float m_LastGroundHeight;
|
|
|
|
bool m_bTouchGround;
|
|
|
|
double m_Stance;
|
2012-09-20 09:25:54 -04:00
|
|
|
cInventory m_Inventory;
|
|
|
|
cWindow * m_CurrentWindow;
|
|
|
|
cWindow * m_InventoryWindow;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
float m_TimeLastPickupCheck;
|
|
|
|
|
|
|
|
void ResolvePermissions();
|
|
|
|
|
|
|
|
void ResolveGroups();
|
|
|
|
char m_Color;
|
|
|
|
|
|
|
|
float m_LastBlockActionTime;
|
|
|
|
int m_LastBlockActionCnt;
|
|
|
|
eGameMode m_GameMode;
|
|
|
|
std::string m_IP;
|
2012-09-20 09:25:54 -04:00
|
|
|
|
|
|
|
cItem m_DraggingItem;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
long long m_LastPlayerListTime;
|
|
|
|
static const unsigned short PLAYER_LIST_TIME_MS = 1000; // 1000 = once per second
|
|
|
|
|
|
|
|
cClientHandle* m_ClientHandle;
|
|
|
|
}; //tolua_export
|