physical_bone_2d.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**************************************************************************/
  2. /* physical_bone_2d.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef PHYSICAL_BONE_2D_H
  31. #define PHYSICAL_BONE_2D_H
  32. #include "scene/2d/physics/rigid_body_2d.h"
  33. #include "scene/2d/skeleton_2d.h"
  34. class Joint2D;
  35. class PhysicalBone2D : public RigidBody2D {
  36. GDCLASS(PhysicalBone2D, RigidBody2D);
  37. protected:
  38. void _notification(int p_what);
  39. static void _bind_methods();
  40. private:
  41. Skeleton2D *parent_skeleton = nullptr;
  42. int bone2d_index = -1;
  43. NodePath bone2d_nodepath;
  44. bool follow_bone_when_simulating = false;
  45. Joint2D *child_joint = nullptr;
  46. bool auto_configure_joint = true;
  47. bool simulate_physics = false;
  48. bool _internal_simulate_physics = false;
  49. void _find_skeleton_parent();
  50. void _find_joint_child();
  51. void _auto_configure_joint();
  52. void _start_physics_simulation();
  53. void _stop_physics_simulation();
  54. void _position_at_bone2d();
  55. public:
  56. Joint2D *get_joint() const;
  57. bool get_auto_configure_joint() const;
  58. void set_auto_configure_joint(bool p_auto_configure);
  59. void set_simulate_physics(bool p_simulate);
  60. bool get_simulate_physics() const;
  61. bool is_simulating_physics() const;
  62. void set_bone2d_nodepath(const NodePath &p_nodepath);
  63. NodePath get_bone2d_nodepath() const;
  64. void set_bone2d_index(int p_bone_idx);
  65. int get_bone2d_index() const;
  66. void set_follow_bone_when_simulating(bool p_follow);
  67. bool get_follow_bone_when_simulating() const;
  68. PackedStringArray get_configuration_warnings() const override;
  69. PhysicalBone2D();
  70. ~PhysicalBone2D();
  71. };
  72. #endif // PHYSICAL_BONE_2D_H