summaryrefslogtreecommitdiff
path: root/scene/main/node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main/node.cpp')
-rw-r--r--scene/main/node.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index e1abea81ef..baf185c847 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -35,6 +35,7 @@
#include "core/object/message_queue.h"
#include "core/string/print_string.h"
#include "instance_placeholder.h"
+#include "scene/animation/tween.h"
#include "scene/debugger/scene_debugger.h"
#include "scene/resources/packed_scene.h"
#include "scene/scene_string_names.h"
@@ -1686,6 +1687,13 @@ int Node::get_index() const {
return data.pos;
}
+Ref<Tween> Node::create_tween() {
+ ERR_FAIL_COND_V_MSG(!data.tree, nullptr, "Can't create Tween when not inside scene tree.");
+ Ref<Tween> tween = get_tree()->create_tween();
+ tween->bind_node(this);
+ return tween;
+}
+
void Node::remove_and_skip() {
ERR_FAIL_COND(!data.parent);
@@ -1805,7 +1813,7 @@ bool Node::get_scene_instance_load_placeholder() const {
Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const {
Node *node = nullptr;
- bool instanced = false;
+ bool instantiated = false;
if (Object::cast_to<InstancePlaceholder>(this)) {
const InstancePlaceholder *ip = Object::cast_to<const InstancePlaceholder>(this);
@@ -1822,13 +1830,13 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
ges = PackedScene::GEN_EDIT_STATE_INSTANCE;
}
#endif
- node = res->instance(ges);
+ node = res->instantiate(ges);
ERR_FAIL_COND_V(!node, nullptr);
- instanced = true;
+ instantiated = true;
} else {
- Object *obj = ClassDB::instance(get_class());
+ Object *obj = ClassDB::instantiate(get_class());
ERR_FAIL_COND_V(!obj, nullptr);
node = Object::cast_to<Node>(obj);
if (!node) {
@@ -1848,9 +1856,9 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
List<const Node *> node_tree;
node_tree.push_front(this);
- if (instanced) {
- // Since nodes in the instanced hierarchy won't be duplicated explicitly, we need to make an inventory
- // of all the nodes in the tree of the instanced scene in order to transfer the values of the properties
+ if (instantiated) {
+ // Since nodes in the instantiated hierarchy won't be duplicated explicitly, we need to make an inventory
+ // of all the nodes in the tree of the instantiated scene in order to transfer the values of the properties
Vector<const Node *> instance_roots;
instance_roots.push_back(this);
@@ -1858,8 +1866,8 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
for (List<const Node *>::Element *N = node_tree.front(); N; N = N->next()) {
for (int i = 0; i < N->get()->get_child_count(); ++i) {
Node *descendant = N->get()->get_child(i);
- // Skip nodes not really belonging to the instanced hierarchy; they'll be processed normally later
- // but remember non-instanced nodes that are hidden below instanced ones
+ // Skip nodes not really belonging to the instantiated hierarchy; they'll be processed normally later
+ // but remember non-instantiated nodes that are hidden below instantiated ones
if (!instance_roots.has(descendant->get_owner())) {
if (descendant->get_parent() && descendant->get_parent() != this && descendant->data.owner != descendant->get_parent()) {
hidden_roots.push_back(descendant);
@@ -1942,7 +1950,7 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
if (get_child(i)->data.parent_owned) {
continue;
}
- if (instanced && get_child(i)->data.owner == this) {
+ if (instantiated && get_child(i)->data.owner == this) {
continue; //part of instance
}
@@ -2555,6 +2563,7 @@ void Node::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_physics_processing_internal"), &Node::is_physics_processing_internal);
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_groups"), &Node::replace_by, DEFVAL(false));