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-_"
95 Player(IGameDef *gamedef);
96 virtual ~Player() = 0;
98 virtual void move(f32 dtime, Map &map, f32 pos_max_d)
106 void setSpeed(v3f speed)
111 void accelerateHorizontal(v3f target_speed, f32 max_increase);
112 void accelerateVertical(v3f target_speed, f32 max_increase);
119 v3s16 getLightPosition() const;
123 // This is at the height of the eyes of the current figure
124 // return v3f(0, BS*1.5, 0);
125 // This is more like in minecraft
126 if(camera_barely_in_ceiling)
127 return v3f(0,BS*1.5,0);
129 return v3f(0,BS*1.625,0);
134 return m_position + getEyeOffset();
137 virtual void setPosition(const v3f &position)
139 m_position = position;
142 void setPitch(f32 pitch)
147 virtual void setYaw(f32 yaw)
164 return -1.0 * m_pitch * core::DEGTORAD;
169 return (m_yaw + 90.) * core::DEGTORAD;
172 void updateName(const char *name)
174 snprintf(m_name, PLAYERNAME_SIZE, "%s", name);
177 const char * getName() const
182 virtual bool isLocal() const
184 virtual PlayerSAO *getPlayerSAO()
186 virtual void setPlayerSAO(PlayerSAO *sao)
190 serialize() writes a bunch of text that can contain
191 any characters except a '\0', and such an ending that
192 deSerialize stops reading exactly at the right point.
194 void serialize(std::ostream &os);
195 void deSerialize(std::istream &is);
197 bool touching_ground;
198 // This oscillates so that the player jumps a bit above the surface
200 // This is more stable and defines the maximum speed of the player
201 bool in_liquid_stable;
202 // Gets the viscosity of water to calculate friction
205 bool swimming_vertical;
206 bool camera_barely_in_ceiling;
212 f32 movement_acceleration_default;
213 f32 movement_acceleration_air;
214 f32 movement_acceleration_fast;
215 f32 movement_speed_walk;
216 f32 movement_speed_crouch;
217 f32 movement_speed_fast;
218 f32 movement_speed_climb;
219 f32 movement_speed_jump;
220 f32 movement_liquid_fluidity;
221 f32 movement_liquid_fluidity_smooth;
222 f32 movement_liquid_sink;
223 f32 movement_gravity;
227 float hurt_tilt_timer;
228 float hurt_tilt_strength;
232 std::string inventory_formspec;
234 PlayerControl control;
235 PlayerControl getPlayerControl()
245 char m_name[PLAYERNAME_SIZE];
255 class RemotePlayer : public Player
258 RemotePlayer(IGameDef *gamedef): Player(gamedef), m_sao(0) {}
259 virtual ~RemotePlayer() {}
261 PlayerSAO *getPlayerSAO()
263 void setPlayerSAO(PlayerSAO *sao)
265 void setPosition(const v3f &position);