3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "irrlichttypes_bloated.h"
24 #include "inventory.h"
25 #include "constants.h" // BS
26 #include "threading/mutex.h"
29 #define PLAYERNAME_SIZE 20
31 #define PLAYERNAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
32 #define PLAYERNAME_ALLOWED_CHARS_USER_EXPL "'a' to 'z', 'A' to 'Z', '0' to '9', '-', '_'"
49 sidew_move_joystick_axis = .0f;
50 forw_move_joystick_axis = .0f;
66 float a_sidew_move_joystick_axis,
67 float a_forw_move_joystick_axis
82 sidew_move_joystick_axis = a_sidew_move_joystick_axis;
83 forw_move_joystick_axis = a_forw_move_joystick_axis;
97 float sidew_move_joystick_axis;
98 float forw_move_joystick_axis;
102 struct CollisionInfo;
107 // Do *not* perform an assignment or copy operation on a Player or
108 // RemotePlayer object! This will copy the lock held for HUD synchronization
113 Player(const char *name, IItemDefManager *idef);
114 virtual ~Player() = 0;
116 virtual void move(f32 dtime, Environment *env, f32 pos_max_d)
118 virtual void move(f32 dtime, Environment *env, f32 pos_max_d,
119 std::vector<CollisionInfo> *collision_info)
127 void setSpeed(v3f speed)
137 v3s16 getLightPosition() const;
141 float eye_height = camera_barely_in_ceiling ? 1.5f : 1.625f;
142 return v3f(0, BS * eye_height, 0);
147 return m_position + getEyeOffset();
150 virtual void setPosition(const v3f &position)
152 m_position = position;
155 virtual void setPitch(f32 pitch)
160 virtual void setYaw(f32 yaw)
165 f32 getPitch() const { return m_pitch; }
166 f32 getYaw() const { return m_yaw; }
167 u16 getBreath() const { return m_breath; }
169 virtual void setBreath(u16 breath) { m_breath = breath; }
171 f32 getRadPitch() const { return m_pitch * core::DEGTORAD; }
172 f32 getRadYaw() const { return m_yaw * core::DEGTORAD; }
173 const char *getName() const { return m_name; }
174 aabb3f getCollisionbox() const { return m_collisionbox; }
178 size_t size = hud.size();
179 for (size_t i = 0; i != size; i++) {
186 bool camera_barely_in_ceiling;
187 v3f eye_offset_first;
188 v3f eye_offset_third;
192 f32 movement_acceleration_default;
193 f32 movement_acceleration_air;
194 f32 movement_acceleration_fast;
195 f32 movement_speed_walk;
196 f32 movement_speed_crouch;
197 f32 movement_speed_fast;
198 f32 movement_speed_climb;
199 f32 movement_speed_jump;
200 f32 movement_liquid_fluidity;
201 f32 movement_liquid_fluidity_smooth;
202 f32 movement_liquid_sink;
203 f32 movement_gravity;
205 v2s32 local_animations[4];
206 float local_animation_speed;
212 std::string inventory_formspec;
214 PlayerControl control;
215 const PlayerControl& getPlayerControl() { return control; }
219 HudElement* getHud(u32 id);
220 u32 addHud(HudElement* hud);
221 HudElement* removeHud(u32 id);
225 s32 hud_hotbar_itemcount;
227 char m_name[PLAYERNAME_SIZE];
233 aabb3f m_collisionbox;
235 std::vector<HudElement *> hud;
237 // Protect some critical areas
238 // hud for example can be modified by EmergeThread