Backport the new Tween system as SceneTreeTween

Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>
This commit is contained in:
Haoyu Qiu
2022-04-28 17:00:23 +08:00
parent 036f36b5f1
commit 153dc4d57e
25 changed files with 2221 additions and 351 deletions

View File

@@ -35,6 +35,7 @@
#include "core/message_queue.h"
#include "core/print_string.h"
#include "instance_placeholder.h"
#include "scene/animation/scene_tree_tween.h"
#include "scene/resources/packed_scene.h"
#include "scene/scene_string_names.h"
#include "viewport.h"
@@ -1810,6 +1811,14 @@ void Node::_propagate_replace_owner(Node *p_owner, Node *p_by_owner) {
int Node::get_index() const {
return data.pos;
}
Ref<SceneTreeTween> Node::create_tween() {
ERR_FAIL_COND_V_MSG(!data.tree, nullptr, "Can't create SceneTreeTween when not inside scene tree.");
Ref<SceneTreeTween> tween = get_tree()->create_tween();
tween->bind_node(this);
return tween;
}
void Node::remove_and_skip() {
ERR_FAIL_COND(!data.parent);
@@ -2873,6 +2882,7 @@ void Node::_bind_methods() {
ClassDB::bind_method(D_METHOD("reset_physics_interpolation"), &Node::reset_physics_interpolation);
ClassDB::bind_method(D_METHOD("get_tree"), &Node::get_tree);
ClassDB::bind_method(D_METHOD("create_tween"), &Node::create_tween);
ClassDB::bind_method(D_METHOD("duplicate", "flags"), &Node::duplicate, DEFVAL(DUPLICATE_USE_INSTANCING | DUPLICATE_SIGNALS | DUPLICATE_GROUPS | DUPLICATE_SCRIPTS));
ClassDB::bind_method(D_METHOD("replace_by", "node", "keep_data"), &Node::replace_by, DEFVAL(false));