localplayer.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. Minetest
  3. Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #ifndef LOCALPLAYER_HEADER
  17. #define LOCALPLAYER_HEADER
  18. #include "player.h"
  19. #include <list>
  20. class Environment;
  21. class GenericCAO;
  22. class ClientActiveObject;
  23. enum LocalPlayerAnimations {NO_ANIM, WALK_ANIM, DIG_ANIM, WD_ANIM}; // no local animation, walking, digging, both
  24. class LocalPlayer : public Player
  25. {
  26. public:
  27. LocalPlayer(IGameDef *gamedef);
  28. virtual ~LocalPlayer();
  29. bool isLocal() const
  30. {
  31. return true;
  32. }
  33. ClientActiveObject *parent;
  34. bool isAttached;
  35. v3f overridePosition;
  36. void move(f32 dtime, Environment *env, f32 pos_max_d);
  37. void move(f32 dtime, Environment *env, f32 pos_max_d,
  38. std::list<CollisionInfo> *collision_info);
  39. void applyControl(float dtime);
  40. v3s16 getStandingNodePos();
  41. // Used to check if anything changed and prevent sending packets if not
  42. v3f last_position;
  43. v3f last_speed;
  44. float last_pitch;
  45. float last_yaw;
  46. unsigned int last_keyPressed;
  47. float camera_impact;
  48. v3f eye_offset_first;
  49. v3f eye_offset_third;
  50. int last_animation;
  51. float last_animation_speed;
  52. std::string hotbar_image;
  53. std::string hotbar_selected_image;
  54. GenericCAO* getCAO() const {
  55. return m_cao;
  56. }
  57. void setCAO(GenericCAO* toset) {
  58. assert( m_cao == NULL );
  59. m_cao = toset;
  60. }
  61. private:
  62. // This is used for determining the sneaking range
  63. v3s16 m_sneak_node;
  64. // Whether the player is allowed to sneak
  65. bool m_sneak_node_exists;
  66. // Node below player, used to determine whether it has been removed,
  67. // and its old type
  68. v3s16 m_old_node_below;
  69. std::string m_old_node_below_type;
  70. // Whether recalculation of the sneak node is needed
  71. bool m_need_to_get_new_sneak_node;
  72. bool m_can_jump;
  73. GenericCAO* m_cao;
  74. };
  75. #endif