]> git.lizzy.rs Git - minetest.git/blobdiff - src/player.h
Merge pull request #503 from RealBadAngel/master
[minetest.git] / src / player.h
index c3ccc960dfb0ec1e41a714707b92983398fdb6a6..770afdb37eab0aa27e7051a4cefc6a944e391dcc 100644 (file)
@@ -28,6 +28,61 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #define PLAYERNAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
 
+struct PlayerControl
+{
+       PlayerControl()
+       {
+               up = false;
+               down = false;
+               left = false;
+               right = false;
+               jump = false;
+               aux1 = false;
+               sneak = false;
+               LMB = false;
+               RMB = false;
+               pitch = 0;
+               yaw = 0;
+       }
+       PlayerControl(
+               bool a_up,
+               bool a_down,
+               bool a_left,
+               bool a_right,
+               bool a_jump,
+               bool a_aux1,
+               bool a_sneak,
+               bool a_LMB,
+               bool a_RMB,
+               float a_pitch,
+               float a_yaw
+       )
+       {
+               up = a_up;
+               down = a_down;
+               left = a_left;
+               right = a_right;
+               jump = a_jump;
+               aux1 = a_aux1;
+               sneak = a_sneak;
+               LMB = a_LMB;
+               RMB = a_RMB;
+               pitch = a_pitch;
+               yaw = a_yaw;
+       }
+       bool up;
+       bool down;
+       bool left;
+       bool right;
+       bool jump;
+       bool aux1;
+       bool sneak;
+       bool LMB;
+       bool RMB;
+       float pitch;
+       float yaw;
+};
+
 class Map;
 class IGameDef;
 struct CollisionInfo;
@@ -53,8 +108,8 @@ class Player
                m_speed = speed;
        }
        
-       // Y direction is ignored
-       void accelerate(v3f target_speed, f32 max_increase);
+       void accelerateHorizontal(v3f target_speed, f32 max_increase);
+       void accelerateVertical(v3f target_speed, f32 max_increase);
 
        v3f getPosition()
        {
@@ -141,21 +196,48 @@ class Player
 
        bool touching_ground;
        // This oscillates so that the player jumps a bit above the surface
-       bool in_water;
+       bool in_liquid;
        // This is more stable and defines the maximum speed of the player
-       bool in_water_stable;
+       bool in_liquid_stable;
+       // Gets the viscosity of water to calculate friction
+       u8 liquid_viscosity;
        bool is_climbing;
-       bool swimming_up;
+       bool swimming_vertical;
        bool camera_barely_in_ceiling;
        
        u8 light;
 
-       // In creative mode, this is the invisible backup inventory
        Inventory inventory;
 
+       f32 movement_acceleration_default;
+       f32 movement_acceleration_air;
+       f32 movement_acceleration_fast;
+       f32 movement_speed_walk;
+       f32 movement_speed_crouch;
+       f32 movement_speed_fast;
+       f32 movement_speed_climb;
+       f32 movement_speed_jump;
+       f32 movement_liquid_fluidity;
+       f32 movement_liquid_fluidity_smooth;
+       f32 movement_liquid_sink;
+       f32 movement_gravity;
+
        u16 hp;
 
+       float hurt_tilt_timer;
+       float hurt_tilt_strength;
+
        u16 peer_id;
+       
+       std::string inventory_formspec;
+       
+       PlayerControl control;
+       PlayerControl getPlayerControl()
+       {
+               return control;
+       }
+       
+       u32 keyPressed;
 
 protected:
        IGameDef *m_gamedef;
@@ -181,7 +263,7 @@ class RemotePlayer : public Player
        void setPlayerSAO(PlayerSAO *sao)
        { m_sao = sao; }
        void setPosition(const v3f &position);
-
+       
 private:
        PlayerSAO *m_sao;
 };