Resolve "Toggle Free Look with Hotkey"
[ryzomcore.git] / ryzom / client / src / player_cl.h
blob406af38899eda1b704f801ad9bad42c696ef95dd
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef CL_PLAYER_CL_H
20 #define CL_PLAYER_CL_H
23 /////////////
24 // INCLUDE //
25 /////////////
26 // Misc.
27 #include "nel/misc/types_nl.h"
28 // 3d
29 #include "nel/3d/u_point_light.h"
30 // Client.
31 #include "character_cl.h"
32 // Client Sheets
33 #include "client_sheets/race_stats_sheet.h"
34 // Game Share
35 #include "game_share/people.h"
38 ///////////
39 // CLASS //
40 ///////////
41 class CPlayerSheet;
43 /**
44 * Class to manage a player.
45 * \author Guillaume PUZIN
46 * \author Nevrax France
47 * \date 2001
49 class CPlayerCL : public CCharacterCL
51 public:
52 NLMISC_DECLARE_CLASS(CPlayerCL);
54 /// Constructor
55 CPlayerCL();
56 /// Destructor
57 virtual ~CPlayerCL();
59 /// Build the entity from a sheet.
60 virtual bool build(const CEntitySheet *sheet);
62 /// Method to return the attack radius of an entity
63 virtual double attackRadius() const;
64 /** Return the position the attacker should have to combat according to the attack angle.
65 * \param ang : 0 = the front, >0 and <Pi = left side, <0 and >-Pi = right side.
67 virtual NLMISC::CVectorD getAttackerPos(double ang, double dist) const;
69 /** \name DEBUG
70 * Methods only here for the debug.
72 //@{
73 /// Display Debug Information.
74 virtual void displayDebug(float x, float &y, float lineStep);
75 //@}
77 /// Return the People for the entity.
78 virtual EGSPD::CPeople::TPeople people() const;
79 virtual void setPeople(EGSPD::CPeople::TPeople people);
81 /// Return a pointer on the sheet used to create this player.
82 const CRaceStatsSheet *playerSheet() const {return _PlayerSheet;}
84 // from CEntityCL
85 virtual void computePrimitive();
87 /// Return the entity scale. (return 1.0 if there is any problem).
88 virtual float getScale() const;
89 // return vector of ground fxs sorted by ground type, or NULL is ground fxs are not supported for the entity
90 virtual const std::vector<CGroundFXSheet> *getGroundFX() const;
91 virtual bool supportGroundFX() const { return true; }
93 // Return true if this entity is a neutral entity.
94 virtual bool isNeutral () const;
95 // Return true if this entity is a user's friend.
96 virtual bool isFriend () const;
97 // Return true if this entity is a user's enemy.
98 virtual bool isEnemy () const;
99 // Return true if this entity is a user's ally.
100 virtual bool isAlly() const;
101 // Return true if this entity is neutral pvp.
102 virtual bool isNeutralPVP() const;
104 /// Ask if the entity is afk (a character is never afk but players can be)
105 virtual bool isAFK() const {return (_Mode == MBEHAV::REST || properties().afk());}
107 /// Return true if this player is in the same faction as the user's (except if neutral)
108 bool isFromSameNonNeutralPvpClanAsUser() const;
110 // From CEntityCL
111 const char *getBoneNameFromBodyPart(BODY::TBodyPart part, BODY::TSide side) const;
113 // retrieve right hand item sheet
114 virtual const CItemSheet *getRightHandItemSheet() const;
115 virtual const CItemSheet *getLeftHandItemSheet() const;
117 virtual const CAttack *getAttack(const CAttackIDSheet &id) const;
119 virtual float getScaleRef() const;
121 protected:
122 /// Pointer on the Sheet with basic parameters.
123 const CPlayerSheet *_Sheet;
124 /// Pointer on the Sheet with basic parameters.
125 const CRaceStatsSheet *_PlayerSheet;
126 /// Player Face
127 SInstanceCL _Face;
128 /// Default Look
129 std::string _DefaultChest;
130 std::string _DefaultLegs;
131 std::string _DefaultArms;
132 std::string _DefaultHands;
133 std::string _DefaultFeet;
134 std::string _DefaultHair;
135 sint32 _HairColor;
136 sint32 _EyesColor;
137 /// 'true' while the entity is not ready to be displayed.
138 bool _WaitForAppearance;
139 // AsyncTexturing: true if all instances are not loaded.
140 bool _PlayerCLAsyncTextureLoading;
141 // Is the light On or Off.
142 bool _LightOn;
143 // Light
144 NL3D::UPointLight _Light;
146 std::string _CacheSkeletonShapeName;
148 protected:
149 // Return the automaton type of the entity (homin, creature, etc.)
150 virtual std::string automatonType() const;
152 // Initialize the graphic for the player.
153 void init3d();
155 /// Initialize properties of the entity (according to the class).
156 virtual void initProperties();
158 /// Set the equipmenent worn.
159 void equip(SLOTTYPE::EVisualSlot slot, const std::string &shapeName, const CItemSheet *item = 0, sint color = -1);
160 /// Compute the equipmenent worn.
161 void equip(SLOTTYPE::EVisualSlot slot, uint index, uint color);
163 /// Compute the animation set to use according to weapons, mode and race.
164 virtual void computeAnimSet();
166 /// Update the Visual Property A
167 virtual void updateVisualPropertyVpa(const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
168 /// Update the Visual Property B
169 virtual void updateVisualPropertyVpb(const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
170 /// Update the Visual Property C
171 virtual void updateVisualPropertyVpc(const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
172 /// Update the Visual Property PVP Mode (need special imp for player because of PVP consider)
173 virtual void updateVisualPropertyPvpMode(const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
175 // Get The Entity Skin
176 virtual sint skin() const;
178 /// Update blink
179 virtual SInstanceCL *getFace ();
181 // Draw the name.
182 virtual void drawName(const NLMISC::CMatrix &mat);
184 /** \name 3D System
185 * Methods to manage basics 3D systems
187 //@{
188 /** update the display of the AsyncTexture of the entity. called in updateDisplay()
189 * Deriver: See CPlayerCL implementation
190 * \return distance from entity to camera computed (helper for deriver)
192 virtual float updateAsyncTexture();
194 /// Update the Lod Texture When needed
195 virtual void updateLodTexture();
196 //@}
197 /// Return the basic max speed for the entity in meter per sec
198 virtual double getMaxSpeed() const;
200 // Read/Write Variables from/to the stream.
201 virtual void readWrite(NLMISC::IStream &f);
202 // To call after a read from a stream to re-initialize the entity.
203 virtual void load();
205 /// Return name position on Z axis defined in sheet
206 virtual float getNamePosZ() const;
208 // virtual for special PlayerCL _Face mgt
209 virtual void doSetVisualSelectionBlink(bool bOnOff, NLMISC::CRGBA emitColor);
214 #endif // CL_PLAYER_CL_H
216 /* End of player_cl.h */