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
27 #define PLAYERNAME_SIZE 20
29 #define PLAYERNAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
96 Player(IGameDef *gamedef);
97 virtual ~Player() = 0;
99 virtual void move(f32 dtime, Map &map, f32 pos_max_d)
107 void setSpeed(v3f speed)
112 void accelerateHorizontal(v3f target_speed, f32 max_increase);
113 void accelerateVertical(v3f target_speed, f32 max_increase);
120 v3s16 getLightPosition() const;
124 // This is at the height of the eyes of the current figure
125 // return v3f(0, BS*1.5, 0);
126 // This is more like in minecraft
127 if(camera_barely_in_ceiling)
128 return v3f(0,BS*1.5,0);
130 return v3f(0,BS*1.625,0);
135 return m_position + getEyeOffset();
138 virtual void setPosition(const v3f &position)
140 m_position = position;
143 void setPitch(f32 pitch)
148 virtual void setYaw(f32 yaw)
165 return -1.0 * m_pitch * core::DEGTORAD;
170 return (m_yaw + 90.) * core::DEGTORAD;
173 void updateName(const char *name)
175 snprintf(m_name, PLAYERNAME_SIZE, "%s", name);
178 const char * getName() const
183 virtual bool isLocal() const
185 virtual PlayerSAO *getPlayerSAO()
187 virtual void setPlayerSAO(PlayerSAO *sao)
191 serialize() writes a bunch of text that can contain
192 any characters except a '\0', and such an ending that
193 deSerialize stops reading exactly at the right point.
195 void serialize(std::ostream &os);
196 void deSerialize(std::istream &is);
198 bool touching_ground;
199 // This oscillates so that the player jumps a bit above the surface
201 // This is more stable and defines the maximum speed of the player
202 bool in_liquid_stable;
203 // Gets the viscosity of water to calculate friction
206 bool swimming_vertical;
207 bool camera_barely_in_ceiling;
213 f32 movement_acceleration_default;
214 f32 movement_acceleration_air;
215 f32 movement_acceleration_fast;
216 f32 movement_speed_walk;
217 f32 movement_speed_crouch;
218 f32 movement_speed_fast;
219 f32 movement_speed_climb;
220 f32 movement_speed_jump;
221 f32 movement_liquid_fluidity;
222 f32 movement_liquid_fluidity_smooth;
223 f32 movement_liquid_sink;
224 f32 movement_gravity;
226 float physics_override_speed;
227 float physics_override_jump;
228 float physics_override_gravity;
232 float hurt_tilt_timer;
233 float hurt_tilt_strength;
237 std::string inventory_formspec;
239 PlayerControl control;
240 PlayerControl getPlayerControl()
247 std::vector<HudElement *> hud;
252 char m_name[PLAYERNAME_SIZE];
263 class RemotePlayer : public Player
266 RemotePlayer(IGameDef *gamedef): Player(gamedef), m_sao(0) {}
267 virtual ~RemotePlayer() {}
269 PlayerSAO *getPlayerSAO()
271 void setPlayerSAO(PlayerSAO *sao)
273 void setPosition(const v3f &position);