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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-12-21 06:04:08 -05:00
|
|
|
// tolua_begin
|
|
|
|
class cPlayer :
|
|
|
|
public cPawn
|
|
|
|
{
|
2012-12-21 07:21:20 -05:00
|
|
|
typedef cPawn super;
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
public:
|
2012-12-21 06:04:08 -05:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
MAX_HEALTH = 20,
|
|
|
|
} ;
|
|
|
|
// tolua_end
|
|
|
|
|
2012-12-21 07:21:20 -05:00
|
|
|
CLASS_PROTODEF(cPlayer)
|
2013-05-30 04:40:13 -04:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
cPlayer(cClientHandle * a_Client, const AString & a_PlayerName);
|
|
|
|
virtual ~cPlayer();
|
|
|
|
|
2013-04-13 17:02:10 -04:00
|
|
|
virtual void Initialize(cWorld * a_World); // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2012-08-24 03:58:26 -04:00
|
|
|
virtual void SpawnOn(cClientHandle & a_Client) override;
|
|
|
|
|
2013-04-13 17:02:10 -04:00
|
|
|
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-04-22 03:18:03 -04:00
|
|
|
virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override { };
|
|
|
|
|
2012-12-21 06:04:08 -05:00
|
|
|
/// Returns the curently equipped weapon; empty item if none
|
|
|
|
virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); }
|
|
|
|
|
|
|
|
/// Returns the currently equipped helmet; empty item if nonte
|
|
|
|
virtual cItem GetEquippedHelmet(void) const override { return m_Inventory.GetEquippedHelmet(); }
|
|
|
|
|
|
|
|
/// Returns the currently equipped chestplate; empty item if none
|
|
|
|
virtual cItem GetEquippedChestplate(void) const override { return m_Inventory.GetEquippedChestplate(); }
|
|
|
|
|
|
|
|
/// Returns the currently equipped leggings; empty item if none
|
|
|
|
virtual cItem GetEquippedLeggings(void) const override { return m_Inventory.GetEquippedLeggings(); }
|
|
|
|
|
|
|
|
/// Returns the currently equipped boots; empty item if none
|
|
|
|
virtual cItem GetEquippedBoots(void) const override { return m_Inventory.GetEquippedBoots(); }
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
void SetTouchGround( bool a_bTouchGround );
|
2012-08-19 15:42:32 -04:00
|
|
|
inline void SetStance( const double a_Stance ) { m_Stance = a_Stance; }
|
2013-07-01 06:39:56 -04:00
|
|
|
double GetEyeHeight(void) const; // tolua_export
|
|
|
|
Vector3d GetEyePosition(void) const; // tolua_export
|
2012-08-18 05:56:28 -04:00
|
|
|
inline bool IsOnGround(void) const {return m_bTouchGround; } // tolua_export
|
2013-03-22 02:33:10 -04:00
|
|
|
inline const double GetStance(void) const { return GetPosY() + 1.62; } // tolua_export // TODO: Proper stance when crouching etc.
|
2013-01-11 23:46:01 -05:00
|
|
|
inline cInventory & GetInventory(void) { return m_Inventory; } // tolua_export
|
2012-09-20 09:25:54 -04:00
|
|
|
inline const cInventory & GetInventory(void) const { return m_Inventory; }
|
2012-08-24 03:58:26 -04:00
|
|
|
|
2013-05-19 14:22:37 -04:00
|
|
|
inline const cItem & GetEquippedItem(void) const { return GetInventory().GetEquippedItem(); } // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-07-01 06:39:56 -04:00
|
|
|
virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) override;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
eGameMode GetGameMode(void) const { 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( eGameMode a_GameMode ); // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
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
|
|
|
|
2013-05-24 03:30:39 -04:00
|
|
|
/// Tries to move to a new position, with collision checks and stuff
|
2013-01-11 23:46:01 -05:00
|
|
|
virtual void MoveTo( const Vector3d & a_NewPos ); // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-05-30 15:34:09 -04:00
|
|
|
cWindow * GetWindow(void) { return m_CurrentWindow; } // tolua_export
|
2013-05-24 03:30:39 -04:00
|
|
|
const cWindow * GetWindow(void) const { return m_CurrentWindow; }
|
|
|
|
|
2013-05-30 15:34:09 -04:00
|
|
|
/// Opens the specified window; closes the current one first using CloseWindow()
|
|
|
|
void OpenWindow(cWindow * a_Window); // Exported in ManualBindings.cpp
|
|
|
|
|
|
|
|
// tolua_begin
|
|
|
|
|
2013-06-02 17:59:25 -04:00
|
|
|
/// Closes the current window, resets current window to m_InventoryWindow. A plugin may refuse the closing if a_CanRefuse is true
|
|
|
|
void CloseWindow(bool a_CanRefuse = true);
|
2013-05-30 15:34:09 -04:00
|
|
|
|
|
|
|
/// Closes the current window if it matches the specified ID, resets current window to m_InventoryWindow
|
2013-06-02 17:59:25 -04:00
|
|
|
void CloseWindowIfID(char a_WindowID, bool a_CanRefuse = true);
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-05-30 15:34:09 -04:00
|
|
|
cClientHandle * GetClientHandle(void) const { return m_ClientHandle; }
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-05-30 15:34:09 -04:00
|
|
|
void SendMessage(const AString & a_Message);
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-05-30 15:34:09 -04:00
|
|
|
const AString & GetName(void) const { return m_PlayerName; }
|
|
|
|
void SetName(const AString & a_Name) { m_PlayerName = a_Name; }
|
|
|
|
|
|
|
|
// tolua_end
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
typedef std::list< cGroup* > GroupList;
|
|
|
|
typedef std::list< std::string > StringList;
|
2012-10-18 17:54:56 -04:00
|
|
|
|
|
|
|
/// Adds a player to existing group or creates a new group when it doesn't exist
|
2013-01-11 23:46:01 -05:00
|
|
|
void AddToGroup( const AString & a_GroupName ); // tolua_export
|
2012-10-18 17:54:56 -04:00
|
|
|
/// Removes a player from the group, resolves permissions and group inheritance (case sensitive)
|
2013-01-11 23:46:01 -05:00
|
|
|
void RemoveFromGroup( const AString & a_GroupName ); // tolua_export
|
|
|
|
bool CanUseCommand( const AString & a_Command ); // tolua_export
|
|
|
|
bool HasPermission( const AString & a_Permission ); // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
const GroupList & GetGroups() { return m_Groups; } // >> EXPORTED IN MANUALBINDINGS <<
|
|
|
|
StringList GetResolvedPermissions(); // >> EXPORTED IN MANUALBINDINGS <<
|
2013-01-11 23:46:01 -05:00
|
|
|
bool IsInGroup( const AString & a_Group ); // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
AString GetColor(void) const; // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-01-11 23:46:01 -05: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
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
void Heal( int a_Health ); // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
/// Returns true if any food has been consumed, false if player "full"
|
2013-01-11 23:46:01 -05:00
|
|
|
bool Feed(short a_Food, float a_Saturation); // tolua_export
|
2012-07-17 08:02:03 -04:00
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
short GetMaxFoodLevel() { return m_MaxFoodLevel; } // tolua_export
|
|
|
|
short GetFoodLevel() { return m_FoodLevel; } // tolua_export
|
2012-07-17 08:02:03 -04:00
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
float GetMaxFoodSaturationLevel() { return m_MaxFoodSaturationLevel; } // tolua_export
|
|
|
|
float GetFoodSaturationLevel() { return m_FoodSaturationLevel; } // tolua_export
|
2012-07-17 08:02:03 -04:00
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
void AddFoodExhaustion(float a_Exhaustion) { m_FoodExhaustionLevel += a_Exhaustion; } // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-07-01 06:39:56 -04:00
|
|
|
virtual void KilledBy(cEntity * a_Killer) override;
|
2012-12-21 06:04:08 -05:00
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
void Respawn(void); // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
void SetVisible( bool a_bVisible ); // tolua_export
|
|
|
|
bool IsVisible(void) const { return m_bVisible; } // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-07-03 03:47:35 -04:00
|
|
|
bool MoveToWorld(const char * a_WorldName); // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2012-12-21 06:04:08 -05:00
|
|
|
bool SaveToDisk(void);
|
|
|
|
bool LoadFromDisk(void);
|
2013-01-11 23:46:01 -05:00
|
|
|
void LoadPermissionsFromDisk(void); // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
const AString & GetLoadedWorldName() { return m_LoadedWorldName; }
|
|
|
|
|
|
|
|
void UseEquippedItem(void);
|
|
|
|
|
2013-05-30 04:40:13 -04:00
|
|
|
void SendHealth(void);
|
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; }
|
2013-05-30 04:40:13 -04:00
|
|
|
|
|
|
|
// In UI windows, when inventory-painting:
|
|
|
|
/// Clears the list of slots that are being inventory-painted. To be used by cWindow only
|
|
|
|
void ClearInventoryPaintSlots(void);
|
|
|
|
|
|
|
|
/// Adds a slot to the list for inventory painting. To be used by cWindow only
|
|
|
|
void AddInventoryPaintSlot(int a_SlotNum);
|
|
|
|
|
|
|
|
/// Returns the list of slots currently stored for inventory painting. To be used by cWindow only
|
|
|
|
const cSlotNums & GetInventoryPaintSlots(void) const;
|
2013-06-04 10:18:03 -04:00
|
|
|
|
|
|
|
/// Sets the crouch status, broadcasts to all visible players
|
|
|
|
void SetCrouch(bool a_IsCrouched);
|
|
|
|
|
|
|
|
// cEntity overrides:
|
|
|
|
virtual bool IsCrouched(void) const { return m_IsCrouched; }
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
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-11-27 14:55:23 -05:00
|
|
|
float m_LastJumpHeight;
|
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
|
|
|
|
|
2013-05-30 04:40:13 -04:00
|
|
|
cClientHandle * m_ClientHandle;
|
|
|
|
|
|
|
|
cSlotNums m_InventoryPaintSlots;
|
2013-06-04 10:18:03 -04:00
|
|
|
|
|
|
|
bool m_IsCrouched;
|
2013-05-30 04:40:13 -04:00
|
|
|
|
|
|
|
|
|
|
|
virtual void Destroyed(void);
|
2012-12-21 06:04:08 -05:00
|
|
|
|
|
|
|
/// Filters out damage for creative mode
|
|
|
|
virtual void DoTakeDamage(TakeDamageInfo & TDI) override;
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
} ; // tolua_export
|
2012-12-21 06:04:08 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|