| 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/node_2d.h" |
| 34 |
#include "scene/resources/curve.h" |
| 35 |
|
| 36 |
class Timer; |
| 37 |
|
| 38 |
class Path2D : public Node2D { |
| 39 |
GDCLASS(Path2D, Node2D); |
| 40 |
|
| 41 |
Ref<Curve2D> curve; |
| 42 |
|
| 43 |
void _curve_changed(); |
| 44 |
|
| 45 |
#ifdef DEBUG_ENABLED |
| 46 |
RID debug_mesh_rid; |
| 47 |
RID debug_instance; |
| 48 |
|
| 49 |
void _debug_create(); |
| 50 |
void _debug_update(); |
| 51 |
void _debug_free(); |
| 52 |
#endif |
| 53 |
|
| 54 |
protected: |
| 55 |
void _notification(int p_what); |
| 56 |
static void _bind_methods(); |
| 57 |
|
| 58 |
public: |
| 59 |
#ifdef DEBUG_ENABLED |
| 60 |
virtual Rect2 _edit_get_rect() const override; |
| 61 |
virtual bool _edit_use_rect() const override; |
| 62 |
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override; |
| 63 |
#endif |
| 64 |
|
| 65 |
void set_curve(const Ref<Curve2D> &p_curve); |
| 66 |
Ref<Curve2D> get_curve() const; |
| 67 |
}; |
| 68 |
|
| 69 |
class PathFollow2D : public Node2D { |
| 70 |
GDCLASS(PathFollow2D, Node2D); |
| 71 |
|
| 72 |
public: |
| 73 |
private: |
| 74 |
Path2D *path = nullptr; |
| 75 |
real_t progress = 0.0; |
| 76 |
Timer *update_timer = nullptr; |
| 77 |
real_t h_offset = 0.0; |
| 78 |
real_t v_offset = 0.0; |
| 79 |
bool cubic = true; |
| 80 |
bool loop = true; |
| 81 |
bool rotates = true; |
| 82 |
|
| 83 |
void _update_transform(); |
| 84 |
|
| 85 |
protected: |
| 86 |
void _validate_property(PropertyInfo &p_property) const; |
| 87 |
|
| 88 |
void _notification(int p_what); |
| 89 |
static void _bind_methods(); |
| 90 |
|
| 91 |
public: |
| 92 |
void path_changed(); |
| 93 |
|
| 94 |
void set_progress(real_t p_progress); |
| 95 |
real_t get_progress() const; |
| 96 |
|
| 97 |
void set_h_offset(real_t p_h_offset); |
| 98 |
real_t get_h_offset() const; |
| 99 |
|
| 100 |
void set_v_offset(real_t p_v_offset); |
| 101 |
real_t get_v_offset() const; |
| 102 |
|
| 103 |
void set_progress_ratio(real_t p_ratio); |
| 104 |
real_t get_progress_ratio() const; |
| 105 |
|
| 106 |
void set_loop(bool p_loop); |
| 107 |
bool has_loop() const; |
| 108 |
|
| 109 |
void set_rotation_enabled(bool p_enabled); |
| 110 |
bool is_rotation_enabled() const; |
| 111 |
|
| 112 |
void set_cubic_interpolation_enabled(bool p_enabled); |
| 113 |
bool is_cubic_interpolation_enabled() const; |
| 114 |
|
| 115 |
PackedStringArray get_configuration_warnings() const override; |
| 116 |
}; |