summaryrefslogtreecommitdiffstats
path: root/source/cPlayer.h
blob: d2d1e91d799f5241bf7f3eb699b3cd4459a186ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#pragma once

#include "cPawn.h"
#include "cSurvivalInventory.h"
#include "cCreativeInventory.h"
#include <list>
#include <string> // TODO - use const char*

class cGroup;
class cWindow;
class cInventory;
class cClientHandle;


class cPlayer :	public cPawn												//tolua_export
{																			//tolua_export
public:
	CLASS_PROTOTYPE();

	cPlayer(cClientHandle* a_Client, const char* a_PlayerName);
	virtual ~cPlayer();

	virtual void Initialize( cWorld* a_World );								//tolua_export

	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
	cInventory & GetInventory() { if(GetGameMode() == 0) return *m_Inventory; else return *m_CreativeInventory; }					//tolua_export
	cSurvivalInventory & GetSurvivalInventory() { return *m_Inventory; }					//tolua_export

	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
	void LoginSetGameMode( int a_GameMode );
	void SetIP( std::string a_IP );

	// 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);

	cClientHandle* GetClientHandle() { return m_ClientHandle; }				//tolua_export
	void SetClientHandle( cClientHandle* a_Client ) { m_ClientHandle = a_Client; }

	void SendMessage( const char* a_Message );								//tolua_export

	const char* GetName();													//tolua_export
	void SetName( const char* a_Name );										//tolua_export

	typedef std::list< cGroup* > GroupList;
	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 <<
	bool IsInGroup( const char* a_Group );									//tolua_export

	std::string GetColor();													//tolua_export

	void TossItem( bool a_bDraggingItem, int a_Amount = 1 );				//tolua_export

	void Heal( int a_Health );												//tolua_export
	void Feed( short a_Food );
	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();

	const char* GetLoadedWorldName();

	void UseEquippedItem();
	

protected:
	struct sPlayerState;
	sPlayerState* m_pState;

	bool m_bVisible;

	float m_LastGroundHeight;
	bool m_bTouchGround;
	double m_Stance;
	cSurvivalInventory* m_Inventory;
	cCreativeInventory* m_CreativeInventory;
	cWindow* m_CurrentWindow;

	float m_TimeLastPickupCheck;

	void ResolvePermissions();

	void ResolveGroups();
	char m_Color;

	float m_LastBlockActionTime;
	int m_LastBlockActionCnt;
	int m_GameMode;
	std::string m_IP;

	long long m_LastPlayerListTime;
	static const unsigned short PLAYER_LIST_TIME_MS = 1000; // 1000 = once per second

	cClientHandle* m_ClientHandle;
}; //tolua_export