| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "scene/2d/skeleton_2d.h" |
| 34 |
#include "scene/resources/2d/skeleton/skeleton_modification_2d.h" |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
class SkeletonModification2DLookAt : public SkeletonModification2D { |
| 41 |
GDCLASS(SkeletonModification2DLookAt, SkeletonModification2D); |
| 42 |
|
| 43 |
private: |
| 44 |
int bone_idx = -1; |
| 45 |
NodePath bone2d_node; |
| 46 |
ObjectID bone2d_node_cache; |
| 47 |
|
| 48 |
NodePath target_node; |
| 49 |
ObjectID target_node_cache; |
| 50 |
Node2D *target_node_reference = nullptr; |
| 51 |
|
| 52 |
float additional_rotation = 0; |
| 53 |
bool enable_constraint = false; |
| 54 |
float constraint_angle_min = 0; |
| 55 |
float constraint_angle_max = (2.0 * Math::PI); |
| 56 |
bool constraint_angle_invert = false; |
| 57 |
bool constraint_in_localspace = true; |
| 58 |
|
| 59 |
void update_bone2d_cache(); |
| 60 |
void update_target_cache(); |
| 61 |
|
| 62 |
protected: |
| 63 |
static void _bind_methods(); |
| 64 |
bool _set(const StringName &p_path, const Variant &p_value); |
| 65 |
bool _get(const StringName &p_path, Variant &r_ret) const; |
| 66 |
void _get_property_list(List<PropertyInfo> *p_list) const; |
| 67 |
|
| 68 |
public: |
| 69 |
void _execute(float p_delta) override; |
| 70 |
void _setup_modification(SkeletonModificationStack2D *p_stack) override; |
| 71 |
void _draw_editor_gizmo() override; |
| 72 |
|
| 73 |
void set_bone2d_node(const NodePath &p_target_node); |
| 74 |
NodePath get_bone2d_node() const; |
| 75 |
void set_bone_index(int p_idx); |
| 76 |
int get_bone_index() const; |
| 77 |
|
| 78 |
void set_target_node(const NodePath &p_target_node); |
| 79 |
NodePath get_target_node() const; |
| 80 |
|
| 81 |
void set_additional_rotation(float p_rotation); |
| 82 |
float get_additional_rotation() const; |
| 83 |
|
| 84 |
void set_enable_constraint(bool p_constraint); |
| 85 |
bool get_enable_constraint() const; |
| 86 |
void set_constraint_angle_min(float p_angle_min); |
| 87 |
float get_constraint_angle_min() const; |
| 88 |
void set_constraint_angle_max(float p_angle_max); |
| 89 |
float get_constraint_angle_max() const; |
| 90 |
void set_constraint_angle_invert(bool p_invert); |
| 91 |
bool get_constraint_angle_invert() const; |
| 92 |
void set_constraint_in_localspace(bool p_constraint_in_localspace); |
| 93 |
bool get_constraint_in_localspace() const; |
| 94 |
|
| 95 |
SkeletonModification2DLookAt(); |
| 96 |
~SkeletonModification2DLookAt(); |
| 97 |
}; |