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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256 | /**************************************************************************/
/* scene_tree_tween.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SCENE_TREE_TWEEN_H
#define SCENE_TREE_TWEEN_H
#include "core/reference.h"
#include "scene/animation/tween.h"
class SceneTreeTween;
class Tweener : public Reference {
GDCLASS(Tweener, Reference);
public:
virtual void set_tween(Ref<SceneTreeTween> p_tween);<--- Virtual function in base class<--- Virtual function in base class
virtual void start() = 0;<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class
virtual bool step(float &r_delta) = 0;<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class<--- Virtual function in base class
void clear_tween();
protected:
static void _bind_methods();
Ref<SceneTreeTween> tween;<--- Parent variable 'Tweener::tween'
float elapsed_time = 0;
bool finished = false;
};
class PropertyTweener;
class IntervalTweener;
class CallbackTweener;
class MethodTweener;
class SceneTreeTween : public Reference {
GDCLASS(SceneTreeTween, Reference);
public:
enum TweenPauseMode {
TWEEN_PAUSE_BOUND,
TWEEN_PAUSE_STOP,
TWEEN_PAUSE_PROCESS,
};
private:
Tween::TweenProcessMode process_mode = Tween::TWEEN_PROCESS_IDLE;
TweenPauseMode pause_mode = TweenPauseMode::TWEEN_PAUSE_BOUND;
Tween::TransitionType default_transition = Tween::TRANS_LINEAR;
Tween::EaseType default_ease = Tween::EASE_IN_OUT;
ObjectID bound_node;
Vector<List<Ref<Tweener>>> tweeners;
float total_time = 0;
int current_step = -1;
int loops = 1;
int loops_done = 0;
float speed_scale = 1;
bool is_bound = false;
bool started = false;
bool running = true;
bool dead = false;
bool valid = false;
bool default_parallel = false;
bool parallel_enabled = false;
#ifdef DEBUG_ENABLED
bool is_infinite = false;
#endif
void start_tweeners();
protected:
static void _bind_methods();
public:
Ref<PropertyTweener> tween_property(Object *p_target, NodePath p_property, Variant p_to, float p_duration);
Ref<IntervalTweener> tween_interval(float p_time);
Ref<CallbackTweener> tween_callback(Object *p_target, StringName p_method, const Vector<Variant> &p_binds = Vector<Variant>());
Ref<MethodTweener> tween_method(Object *p_target, StringName p_method, Variant p_from, Variant p_to, float p_duration, const Vector<Variant> &p_binds = Vector<Variant>());
void append(Ref<Tweener> p_tweener);
bool custom_step(float p_delta);
void stop();
void pause();
void play();
void kill();
bool is_running() const;
bool is_valid() const;
void clear();
Tween::TweenProcessMode get_process_mode() const;
TweenPauseMode get_pause_mode() const;
Tween::TransitionType get_trans() const;
Tween::EaseType get_ease() const;
Ref<SceneTreeTween> bind_node(Node *p_node);
Ref<SceneTreeTween> set_process_mode(Tween::TweenProcessMode p_mode);
Ref<SceneTreeTween> set_pause_mode(TweenPauseMode p_mode);
Ref<SceneTreeTween> set_parallel(bool p_parallel);
Ref<SceneTreeTween> set_loops(int p_loops);
Ref<SceneTreeTween> set_speed_scale(float p_speed);
Ref<SceneTreeTween> set_trans(Tween::TransitionType p_trans);
Ref<SceneTreeTween> set_ease(Tween::EaseType p_ease);
Ref<SceneTreeTween> parallel();
Ref<SceneTreeTween> chain();
Variant interpolate_variant(Variant p_initial_val, Variant p_delta_val, float p_time, float p_duration, Tween::TransitionType p_trans, Tween::EaseType p_ease) const;
Variant calculate_delta_value(Variant p_intial_val, Variant p_final_val);
bool step(float p_delta);
bool can_process(bool p_tree_paused) const;
Node *get_bound_node() const;
float get_total_time() const;
SceneTreeTween() = default;
SceneTreeTween(bool p_valid);<--- Class 'SceneTreeTween' has a constructor with 1 argument that is not explicit. [+]Class 'SceneTreeTween' has a constructor with 1 argument that is not explicit. Such constructors should in general be explicit for type safety reasons. Using the explicit keyword in the constructor means some mistakes when using the class can be avoided.
};
VARIANT_ENUM_CAST(SceneTreeTween::TweenPauseMode);
class PropertyTweener : public Tweener {
GDCLASS(PropertyTweener, Tweener);
public:
Ref<PropertyTweener> from(Variant p_value);
Ref<PropertyTweener> from_current();
Ref<PropertyTweener> as_relative();
Ref<PropertyTweener> set_trans(Tween::TransitionType p_trans);
Ref<PropertyTweener> set_ease(Tween::EaseType p_ease);
Ref<PropertyTweener> set_delay(float p_delay);
virtual void set_tween(Ref<SceneTreeTween> p_tween);<--- Function in derived class
virtual void start();<--- Function in derived class
virtual bool step(float &r_delta);<--- Function in derived class
PropertyTweener(Object *p_target, NodePath p_property, Variant p_to, float p_duration);
PropertyTweener();
protected:
static void _bind_methods();
private:
ObjectID target;
Vector<StringName> property;
Variant initial_val;
Variant base_final_val;
Variant final_val;
Variant delta_val;
float duration = 0;
Tween::TransitionType trans_type = Tween::TRANS_COUNT; // This is set inside set_tween();
Tween::EaseType ease_type = Tween::EASE_COUNT;
float delay = 0;
bool do_continue = true;
bool relative = false;
};
class IntervalTweener : public Tweener {
GDCLASS(IntervalTweener, Tweener);
public:
virtual void start();<--- Function in derived class
virtual bool step(float &r_delta);<--- Function in derived class
IntervalTweener(float p_time);<--- Class 'IntervalTweener' has a constructor with 1 argument that is not explicit. [+]Class 'IntervalTweener' has a constructor with 1 argument that is not explicit. Such constructors should in general be explicit for type safety reasons. Using the explicit keyword in the constructor means some mistakes when using the class can be avoided.
IntervalTweener();
private:
float duration = 0;
};
class CallbackTweener : public Tweener {
GDCLASS(CallbackTweener, Tweener);
public:
Ref<CallbackTweener> set_delay(float p_delay);
virtual void start();<--- Function in derived class
virtual bool step(float &r_delta);<--- Function in derived class
CallbackTweener(Object *p_target, StringName p_method, const Vector<Variant> &p_binds);
CallbackTweener();
protected:
static void _bind_methods();
private:
ObjectID target;
StringName method;
Vector<Variant> binds;
int args = 0;
float delay = 0;
};
class MethodTweener : public Tweener {
GDCLASS(MethodTweener, Tweener);
public:
Ref<MethodTweener> set_trans(Tween::TransitionType p_trans);
Ref<MethodTweener> set_ease(Tween::EaseType p_ease);
Ref<MethodTweener> set_delay(float p_delay);
virtual void set_tween(Ref<SceneTreeTween> p_tween);<--- Function in derived class
virtual void start();<--- Function in derived class
virtual bool step(float &r_delta);<--- Function in derived class
MethodTweener(Object *p_target, StringName p_method, Variant p_from, Variant p_to, float p_duration, const Vector<Variant> &p_binds);
MethodTweener();
protected:
static void _bind_methods();
private:
float duration = 0;
float delay = 0;
Tween::TransitionType trans_type = Tween::TRANS_COUNT;
Tween::EaseType ease_type = Tween::EASE_COUNT;
Ref<SceneTreeTween> tween;<--- Derived variable 'MethodTweener::tween'
Variant initial_val;
Variant delta_val;
Variant final_val;
ObjectID target;
StringName method;
Vector<Variant> binds;
};
#endif // SCENE_TREE_TWEEN_H
|