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.
20 #ifndef LOCALPLAYER_HEADER
21 #define LOCALPLAYER_HEADER
24 #include "environment.h"
30 class ClientActiveObject;
33 enum LocalPlayerAnimations {NO_ANIM, WALK_ANIM, DIG_ANIM, WD_ANIM}; // no local animation, walking, digging, both
35 class LocalPlayer : public Player
38 LocalPlayer(Client *client, const char *name);
39 virtual ~LocalPlayer();
41 ClientActiveObject *parent;
47 // This oscillates so that the player jumps a bit above the surface
49 // This is more stable and defines the maximum speed of the player
50 bool in_liquid_stable;
51 // Gets the viscosity of water to calculate friction
54 bool swimming_vertical;
56 float physics_override_speed;
57 float physics_override_jump;
58 float physics_override_gravity;
59 bool physics_override_sneak;
60 bool physics_override_sneak_glitch;
64 void move(f32 dtime, Environment *env, f32 pos_max_d);
65 void move(f32 dtime, Environment *env, f32 pos_max_d,
66 std::vector<CollisionInfo> *collision_info);
68 void applyControl(float dtime);
70 v3s16 getStandingNodePos();
71 v3s16 getFootstepNodePos();
73 // Used to check if anything changed and prevent sending packets if not
78 unsigned int last_keyPressed;
85 float last_animation_speed;
87 std::string hotbar_image;
88 std::string hotbar_selected_image;
90 video::SColor light_color;
92 float hurt_tilt_timer;
93 float hurt_tilt_strength;
95 GenericCAO* getCAO() const {
99 void setCAO(GenericCAO* toset) {
100 assert( m_cao == NULL ); // Pre-condition
104 u32 maxHudId() const { return hud.size(); }
106 u16 getBreath() const { return m_breath; }
107 void setBreath(u16 breath) { m_breath = breath; }
109 v3s16 getLightPosition() const;
116 f32 getYaw() const { return m_yaw; }
118 void setPitch(f32 pitch)
123 f32 getPitch() const { return m_pitch; }
125 void setPosition(const v3f &position)
127 m_position = position;
130 v3f getPosition() const { return m_position; }
131 v3f getEyePosition() const { return m_position + getEyeOffset(); }
132 v3f getEyeOffset() const;
134 void accelerateHorizontal(const v3f &target_speed, const f32 max_increase);
135 void accelerateVertical(const v3f &target_speed, const f32 max_increase);
140 // Stores the top bounding box of m_sneak_node
141 aabb3f m_sneak_node_bb_top;
142 // Whether the player is allowed to sneak
143 bool m_sneak_node_exists;
144 // Whether recalculation of m_sneak_node and its top bbox is needed
145 bool m_need_to_get_new_sneak_node;
146 // Whether a "sneak ladder" structure is detected at the players pos
147 // see detectSneakLadder() in the .cpp for more info (always false if disabled)
148 bool m_sneak_ladder_detected;
150 // Node below player, used to determine whether it has been removed,
152 v3s16 m_old_node_below;
153 std::string m_old_node_below_type;
158 bool camera_barely_in_ceiling;
159 aabb3f m_collisionbox;