2014-02-10 09:10:30 +08:00
|
|
|
/*************************************************************************/
|
|
|
|
/* node.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 20:16:55 +08:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 09:10:30 +08:00
|
|
|
/*************************************************************************/
|
2021-01-02 03:13:46 +08:00
|
|
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
2014-02-10 09:10:30 +08:00
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/*************************************************************************/
|
2018-01-05 07:50:27 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
#ifndef NODE_H
|
|
|
|
#define NODE_H
|
|
|
|
|
2020-11-08 06:33:38 +08:00
|
|
|
#include "core/config/project_settings.h"
|
|
|
|
#include "core/object/class_db.h"
|
|
|
|
#include "core/object/script_language.h"
|
|
|
|
#include "core/string/node_path.h"
|
|
|
|
#include "core/templates/map.h"
|
|
|
|
#include "core/variant/typed_array.h"
|
2017-06-27 09:58:03 +08:00
|
|
|
#include "scene/main/scene_tree.h"
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2014-04-10 11:18:27 +08:00
|
|
|
class Viewport;
|
2015-10-10 20:09:09 +08:00
|
|
|
class SceneState;
|
2014-02-10 09:10:30 +08:00
|
|
|
class Node : public Object {
|
2017-03-05 23:44:50 +08:00
|
|
|
GDCLASS(Node, Object);
|
2014-02-10 09:10:30 +08:00
|
|
|
OBJ_CATEGORY("Nodes");
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
public:
|
|
|
|
enum PauseMode {
|
|
|
|
PAUSE_MODE_INHERIT,
|
|
|
|
PAUSE_MODE_STOP,
|
|
|
|
PAUSE_MODE_PROCESS
|
|
|
|
};
|
|
|
|
|
2017-02-21 03:05:01 +08:00
|
|
|
enum DuplicateFlags {
|
2017-03-05 23:44:50 +08:00
|
|
|
DUPLICATE_SIGNALS = 1,
|
|
|
|
DUPLICATE_GROUPS = 2,
|
|
|
|
DUPLICATE_SCRIPTS = 4,
|
2017-11-19 21:32:10 +08:00
|
|
|
DUPLICATE_USE_INSTANCING = 8,
|
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
|
DUPLICATE_FROM_EDITOR = 16,
|
|
|
|
#endif
|
2017-02-21 03:05:01 +08:00
|
|
|
};
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
struct Comparator {
|
2017-03-05 23:44:50 +08:00
|
|
|
bool operator()(const Node *p_a, const Node *p_b) const { return p_b->is_greater_than(p_a); }
|
2014-02-10 09:10:30 +08:00
|
|
|
};
|
|
|
|
|
2018-07-02 13:30:40 +08:00
|
|
|
struct ComparatorWithPriority {
|
2018-07-25 22:48:18 +08:00
|
|
|
bool operator()(const Node *p_a, const Node *p_b) const { return p_b->data.process_priority == p_a->data.process_priority ? p_b->is_greater_than(p_a) : p_b->data.process_priority > p_a->data.process_priority; }
|
2018-07-02 13:30:40 +08:00
|
|
|
};
|
|
|
|
|
2019-04-18 04:46:21 +08:00
|
|
|
static int orphan_node_count;
|
|
|
|
|
2016-03-09 07:00:52 +08:00
|
|
|
private:
|
2014-02-10 09:10:30 +08:00
|
|
|
struct GroupData {
|
2020-12-09 02:58:49 +08:00
|
|
|
bool persistent = false;
|
|
|
|
SceneTree::Group *group = nullptr;
|
2014-02-10 09:10:30 +08:00
|
|
|
};
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2020-02-12 18:51:50 +08:00
|
|
|
struct NetData {
|
|
|
|
StringName name;
|
|
|
|
MultiplayerAPI::RPCMode mode;
|
|
|
|
};
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
struct Data {
|
|
|
|
String filename;
|
2015-10-10 20:09:09 +08:00
|
|
|
Ref<SceneState> instance_state;
|
|
|
|
Ref<SceneState> inherited_state;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
HashMap<NodePath, int> editable_instances;
|
2015-10-10 20:09:09 +08:00
|
|
|
|
2020-12-11 22:54:03 +08:00
|
|
|
Node *parent = nullptr;
|
|
|
|
Node *owner = nullptr;
|
|
|
|
Vector<Node *> children;
|
|
|
|
int pos = -1;
|
|
|
|
int depth = -1;
|
|
|
|
int blocked = 0; // Safeguard that throws an error when attempting to modify the tree in a harmful way while being traversed.
|
2014-02-10 09:10:30 +08:00
|
|
|
StringName name;
|
2020-12-11 22:54:03 +08:00
|
|
|
SceneTree *tree = nullptr;
|
|
|
|
bool inside_tree = false;
|
|
|
|
bool ready_notified = false; // This is a small hack, so if a node is added during _ready() to the tree, it correctly gets the _ready() notification.
|
|
|
|
bool ready_first = true;
|
2014-06-19 13:23:03 +08:00
|
|
|
#ifdef TOOLS_ENABLED
|
2020-12-11 22:54:03 +08:00
|
|
|
NodePath import_path; // Path used when imported, used by scene editors to keep tracking.
|
2014-06-19 13:23:03 +08:00
|
|
|
#endif
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2020-12-11 22:54:03 +08:00
|
|
|
Viewport *viewport = nullptr;
|
2014-04-10 11:18:27 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Map<StringName, GroupData> grouped;
|
2020-12-11 22:54:03 +08:00
|
|
|
List<Node *>::Element *OW = nullptr; // Owned element.
|
2017-03-05 23:44:50 +08:00
|
|
|
List<Node *> owned;
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2020-12-11 22:54:03 +08:00
|
|
|
PauseMode pause_mode = PAUSE_MODE_INHERIT;
|
|
|
|
Node *pause_owner = nullptr;
|
2016-08-15 05:49:50 +08:00
|
|
|
|
2020-12-11 22:54:03 +08:00
|
|
|
int network_master = 1; // Server by default.
|
2020-02-12 18:51:50 +08:00
|
|
|
Vector<NetData> rpc_methods;
|
|
|
|
Vector<NetData> rpc_properties;
|
2016-08-15 05:49:50 +08:00
|
|
|
|
2020-12-11 22:54:03 +08:00
|
|
|
// Variables used to properly sort the node when processing, ignored otherwise.
|
|
|
|
// TODO: Should move all the stuff below to bits.
|
|
|
|
bool physics_process = false;
|
2020-12-22 17:50:29 +08:00
|
|
|
bool process = false;
|
2020-12-11 22:54:03 +08:00
|
|
|
int process_priority = 0;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2020-12-11 22:54:03 +08:00
|
|
|
bool physics_process_internal = false;
|
2020-12-22 17:50:29 +08:00
|
|
|
bool process_internal = false;
|
2017-01-11 05:02:19 +08:00
|
|
|
|
2020-12-11 22:54:03 +08:00
|
|
|
bool input = false;
|
|
|
|
bool unhandled_input = false;
|
|
|
|
bool unhandled_key_input = false;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2020-12-11 22:54:03 +08:00
|
|
|
bool parent_owned = false;
|
|
|
|
bool in_constructor = true;
|
|
|
|
bool use_placeholder = false;
|
2015-10-17 06:11:23 +08:00
|
|
|
|
2020-12-11 22:54:03 +08:00
|
|
|
bool display_folded = false;
|
2015-10-10 20:09:09 +08:00
|
|
|
|
2020-12-11 22:54:03 +08:00
|
|
|
mutable NodePath *path_cache = nullptr;
|
2016-08-15 05:49:50 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
} data;
|
|
|
|
|
2017-01-13 02:13:09 +08:00
|
|
|
enum NameCasing {
|
|
|
|
NAME_CASING_PASCAL_CASE,
|
|
|
|
NAME_CASING_CAMEL_CASE,
|
|
|
|
NAME_CASING_SNAKE_CASE
|
|
|
|
};
|
|
|
|
|
2018-05-08 16:51:04 +08:00
|
|
|
Ref<MultiplayerAPI> multiplayer;
|
2018-03-04 01:30:11 +08:00
|
|
|
|
2019-07-10 17:54:12 +08:00
|
|
|
void _print_tree_pretty(const String &prefix, const bool last);
|
2016-03-09 07:00:52 +08:00
|
|
|
void _print_tree(const Node *p_node);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Node *_get_child_by_name(const StringName &p_name) const;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void _replace_connections_target(Node *p_new_target);
|
2015-06-08 11:33:10 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void _validate_child_name(Node *p_child, bool p_force_human_readable = false);
|
2019-01-11 05:52:47 +08:00
|
|
|
void _generate_serial_child_name(const Node *p_child, StringName &name) const;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2016-03-09 07:00:52 +08:00
|
|
|
void _propagate_reverse_notification(int p_notification);
|
2014-02-10 09:10:30 +08:00
|
|
|
void _propagate_deferred_notification(int p_notification, bool p_reverse);
|
2014-11-06 08:20:42 +08:00
|
|
|
void _propagate_enter_tree();
|
2014-02-10 09:10:30 +08:00
|
|
|
void _propagate_ready();
|
2014-11-06 08:20:42 +08:00
|
|
|
void _propagate_exit_tree();
|
2018-09-08 02:31:19 +08:00
|
|
|
void _propagate_after_exit_tree();
|
2014-02-10 09:10:30 +08:00
|
|
|
void _propagate_validate_owner();
|
|
|
|
void _print_stray_nodes();
|
2017-03-05 23:44:50 +08:00
|
|
|
void _propagate_pause_owner(Node *p_owner);
|
|
|
|
Array _get_node_and_resource(const NodePath &p_path);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void _duplicate_signals(const Node *p_original, Node *p_copy) const;
|
|
|
|
void _duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p_reown_map) const;
|
2020-04-02 07:20:12 +08:00
|
|
|
Node *_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap = nullptr) const;
|
2016-07-07 08:43:31 +08:00
|
|
|
|
2020-04-21 06:06:00 +08:00
|
|
|
TypedArray<Node> _get_children() const;
|
2014-06-16 21:22:26 +08:00
|
|
|
Array _get_groups() const;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2020-02-20 03:27:19 +08:00
|
|
|
Variant _rpc_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
|
|
|
|
Variant _rpc_unreliable_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
|
|
|
|
Variant _rpc_id_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
|
|
|
|
Variant _rpc_unreliable_id_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
|
2016-08-15 05:49:50 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
friend class SceneTree;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2014-11-06 08:20:42 +08:00
|
|
|
void _set_tree(SceneTree *p_tree);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2018-04-27 00:42:15 +08:00
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
|
friend class SceneTreeEditor;
|
|
|
|
#endif
|
|
|
|
static String invalid_character;
|
|
|
|
static bool _validate_node_name(String &p_name);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
protected:
|
2014-02-10 09:10:30 +08:00
|
|
|
void _block() { data.blocked++; }
|
2017-03-05 23:44:50 +08:00
|
|
|
void _unblock() { data.blocked--; }
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2016-03-09 07:00:52 +08:00
|
|
|
void _notification(int p_notification);
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
virtual void add_child_notify(Node *p_child);
|
|
|
|
virtual void remove_child_notify(Node *p_child);
|
2014-12-03 12:17:23 +08:00
|
|
|
virtual void move_child_notify(Node *p_child);
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void _propagate_replace_owner(Node *p_owner, Node *p_by_owner);
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
static void _bind_methods();
|
2016-10-08 02:25:29 +08:00
|
|
|
static String _get_name_num_separator();
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
friend class SceneState;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void _add_child_nocheck(Node *p_child, const StringName &p_name);
|
|
|
|
void _set_owner_nocheck(Node *p_owner);
|
|
|
|
void _set_name_nocheck(const StringName &p_name);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
enum {
|
|
|
|
// you can make your own, but don't use the same numbers as other notifications in other nodes
|
2017-03-05 23:44:50 +08:00
|
|
|
NOTIFICATION_ENTER_TREE = 10,
|
|
|
|
NOTIFICATION_EXIT_TREE = 11,
|
|
|
|
NOTIFICATION_MOVED_IN_PARENT = 12,
|
|
|
|
NOTIFICATION_READY = 13,
|
|
|
|
NOTIFICATION_PAUSED = 14,
|
|
|
|
NOTIFICATION_UNPAUSED = 15,
|
2017-09-30 22:19:07 +08:00
|
|
|
NOTIFICATION_PHYSICS_PROCESS = 16,
|
2014-02-10 09:10:30 +08:00
|
|
|
NOTIFICATION_PROCESS = 17,
|
2017-03-05 23:44:50 +08:00
|
|
|
NOTIFICATION_PARENTED = 18,
|
|
|
|
NOTIFICATION_UNPARENTED = 19,
|
|
|
|
NOTIFICATION_INSTANCED = 20,
|
|
|
|
NOTIFICATION_DRAG_BEGIN = 21,
|
|
|
|
NOTIFICATION_DRAG_END = 22,
|
|
|
|
NOTIFICATION_PATH_CHANGED = 23,
|
2019-04-04 21:34:03 +08:00
|
|
|
//NOTIFICATION_TRANSLATION_CHANGED = 24, moved below
|
2017-01-11 05:02:19 +08:00
|
|
|
NOTIFICATION_INTERNAL_PROCESS = 25,
|
2017-09-30 22:19:07 +08:00
|
|
|
NOTIFICATION_INTERNAL_PHYSICS_PROCESS = 26,
|
2018-05-16 04:12:35 +08:00
|
|
|
NOTIFICATION_POST_ENTER_TREE = 27,
|
2019-04-04 21:34:03 +08:00
|
|
|
//keep these linked to node
|
2020-03-05 00:36:09 +08:00
|
|
|
|
|
|
|
NOTIFICATION_WM_MOUSE_ENTER = 1002,
|
|
|
|
NOTIFICATION_WM_MOUSE_EXIT = 1003,
|
2020-06-30 07:47:18 +08:00
|
|
|
NOTIFICATION_WM_WINDOW_FOCUS_IN = 1004,
|
|
|
|
NOTIFICATION_WM_WINDOW_FOCUS_OUT = 1005,
|
2020-03-05 00:36:09 +08:00
|
|
|
NOTIFICATION_WM_CLOSE_REQUEST = 1006,
|
|
|
|
NOTIFICATION_WM_GO_BACK_REQUEST = 1007,
|
2020-03-07 01:00:16 +08:00
|
|
|
NOTIFICATION_WM_SIZE_CHANGED = 1008,
|
2020-03-08 00:02:54 +08:00
|
|
|
NOTIFICATION_WM_DPI_CHANGE = 1009,
|
2020-03-05 00:36:09 +08:00
|
|
|
|
2019-04-04 21:34:03 +08:00
|
|
|
NOTIFICATION_OS_MEMORY_WARNING = MainLoop::NOTIFICATION_OS_MEMORY_WARNING,
|
|
|
|
NOTIFICATION_TRANSLATION_CHANGED = MainLoop::NOTIFICATION_TRANSLATION_CHANGED,
|
|
|
|
NOTIFICATION_WM_ABOUT = MainLoop::NOTIFICATION_WM_ABOUT,
|
|
|
|
NOTIFICATION_CRASH = MainLoop::NOTIFICATION_CRASH,
|
2019-09-10 05:42:17 +08:00
|
|
|
NOTIFICATION_OS_IME_UPDATE = MainLoop::NOTIFICATION_OS_IME_UPDATE,
|
2020-06-30 07:47:18 +08:00
|
|
|
NOTIFICATION_APPLICATION_RESUMED = MainLoop::NOTIFICATION_APPLICATION_RESUMED,
|
|
|
|
NOTIFICATION_APPLICATION_PAUSED = MainLoop::NOTIFICATION_APPLICATION_PAUSED,
|
|
|
|
NOTIFICATION_APPLICATION_FOCUS_IN = MainLoop::NOTIFICATION_APPLICATION_FOCUS_IN,
|
2020-09-03 19:22:16 +08:00
|
|
|
NOTIFICATION_APPLICATION_FOCUS_OUT = MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT,
|
|
|
|
NOTIFICATION_TEXT_SERVER_CHANGED = MainLoop::NOTIFICATION_TEXT_SERVER_CHANGED,
|
2014-02-10 09:10:30 +08:00
|
|
|
};
|
2016-03-09 07:00:52 +08:00
|
|
|
|
|
|
|
/* NODE/TREE */
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
StringName get_name() const;
|
2017-03-05 23:44:50 +08:00
|
|
|
void set_name(const String &p_name);
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void add_child(Node *p_child, bool p_legible_unique_name = false);
|
2020-05-12 14:12:08 +08:00
|
|
|
void add_sibling(Node *p_sibling, bool p_legible_unique_name = false);
|
2014-02-10 09:10:30 +08:00
|
|
|
void remove_child(Node *p_child);
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
int get_child_count() const;
|
|
|
|
Node *get_child(int p_index) const;
|
2017-03-05 23:44:50 +08:00
|
|
|
bool has_node(const NodePath &p_path) const;
|
|
|
|
Node *get_node(const NodePath &p_path) const;
|
2019-01-30 00:15:34 +08:00
|
|
|
Node *get_node_or_null(const NodePath &p_path) const;
|
2017-03-05 23:44:50 +08:00
|
|
|
Node *find_node(const String &p_mask, bool p_recursive = true, bool p_owned = true) const;
|
|
|
|
bool has_node_and_resource(const NodePath &p_path) const;
|
2017-05-31 04:20:15 +08:00
|
|
|
Node *get_node_and_resource(const NodePath &p_path, RES &r_res, Vector<StringName> &r_leftover_subpath, bool p_last_is_property = true) const;
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
Node *get_parent() const;
|
2018-09-16 00:22:06 +08:00
|
|
|
Node *find_parent(const String &p_mask) const;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
_FORCE_INLINE_ SceneTree *get_tree() const {
|
2020-04-02 07:20:12 +08:00
|
|
|
ERR_FAIL_COND_V(!data.tree, nullptr);
|
2017-03-05 23:44:50 +08:00
|
|
|
return data.tree;
|
|
|
|
}
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2014-11-06 08:20:42 +08:00
|
|
|
_FORCE_INLINE_ bool is_inside_tree() const { return data.inside_tree; }
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
bool is_a_parent_of(const Node *p_node) const;
|
|
|
|
bool is_greater_than(const Node *p_node) const;
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
NodePath get_path() const;
|
|
|
|
NodePath get_path_to(const Node *p_node) const;
|
2017-03-05 23:44:50 +08:00
|
|
|
Node *find_common_parent_with(const Node *p_node) const;
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void add_to_group(const StringName &p_identifier, bool p_persistent = false);
|
|
|
|
void remove_from_group(const StringName &p_identifier);
|
|
|
|
bool is_in_group(const StringName &p_identifier) const;
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
struct GroupInfo {
|
2015-10-10 20:09:09 +08:00
|
|
|
StringName name;
|
2014-02-10 09:10:30 +08:00
|
|
|
bool persistent;
|
|
|
|
};
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
void get_groups(List<GroupInfo> *p_groups) const;
|
2019-08-17 04:30:31 +08:00
|
|
|
int get_persistent_group_count() const;
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void move_child(Node *p_child, int p_pos);
|
2014-02-10 09:10:30 +08:00
|
|
|
void raise();
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
void set_owner(Node *p_owner);
|
|
|
|
Node *get_owner() const;
|
2017-03-05 23:44:50 +08:00
|
|
|
void get_owned_by(Node *p_by, List<Node *> *p_owned);
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
void remove_and_skip();
|
|
|
|
int get_index() const;
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
void print_tree();
|
2018-02-28 17:12:06 +08:00
|
|
|
void print_tree_pretty();
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void set_filename(const String &p_filename);
|
2014-02-10 09:10:30 +08:00
|
|
|
String get_filename() const;
|
2015-10-10 20:09:09 +08:00
|
|
|
|
2019-08-15 20:50:26 +08:00
|
|
|
void set_editor_description(const String &p_editor_description);
|
|
|
|
String get_editor_description() const;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void set_editable_instance(Node *p_node, bool p_editable);
|
2018-10-30 03:36:31 +08:00
|
|
|
bool is_editable_instance(const Node *p_node) const;
|
2017-03-05 23:44:50 +08:00
|
|
|
void set_editable_instances(const HashMap<NodePath, int> &p_editable_instances);
|
|
|
|
HashMap<NodePath, int> get_editable_instances() const;
|
2015-10-17 06:11:23 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
/* NOTIFICATIONS */
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
void propagate_notification(int p_notification);
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2017-08-19 21:17:06 +08:00
|
|
|
void propagate_call(const StringName &p_method, const Array &p_args = Array(), const bool p_parent_first = false);
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
/* PROCESSING */
|
2017-09-30 22:19:07 +08:00
|
|
|
void set_physics_process(bool p_process);
|
|
|
|
float get_physics_process_delta_time() const;
|
|
|
|
bool is_physics_processing() const;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2020-12-22 17:50:29 +08:00
|
|
|
void set_process(bool p_process);
|
2014-02-10 09:10:30 +08:00
|
|
|
float get_process_delta_time() const;
|
|
|
|
bool is_processing() const;
|
|
|
|
|
2017-09-30 22:19:07 +08:00
|
|
|
void set_physics_process_internal(bool p_process_internal);
|
|
|
|
bool is_physics_processing_internal() const;
|
2017-01-11 05:02:19 +08:00
|
|
|
|
2020-12-22 17:50:29 +08:00
|
|
|
void set_process_internal(bool p_process_internal);
|
2017-01-11 05:02:19 +08:00
|
|
|
bool is_processing_internal() const;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2018-07-02 13:30:40 +08:00
|
|
|
void set_process_priority(int p_priority);
|
2019-11-17 05:07:02 +08:00
|
|
|
int get_process_priority() const;
|
2018-07-02 13:30:40 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
void set_process_input(bool p_enable);
|
|
|
|
bool is_processing_input() const;
|
|
|
|
|
|
|
|
void set_process_unhandled_input(bool p_enable);
|
|
|
|
bool is_processing_unhandled_input() const;
|
|
|
|
|
2014-04-10 11:18:27 +08:00
|
|
|
void set_process_unhandled_key_input(bool p_enable);
|
|
|
|
bool is_processing_unhandled_key_input() const;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Node *duplicate(int p_flags = DUPLICATE_GROUPS | DUPLICATE_SIGNALS | DUPLICATE_SCRIPTS) const;
|
|
|
|
Node *duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const;
|
2017-11-19 21:32:10 +08:00
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
|
Node *duplicate_from_editor(Map<const Node *, Node *> &r_duplimap) const;
|
|
|
|
#endif
|
2015-08-02 23:29:37 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
// used by editors, to save what has changed only
|
2017-03-05 23:44:50 +08:00
|
|
|
void set_scene_instance_state(const Ref<SceneState> &p_state);
|
2015-10-10 20:09:09 +08:00
|
|
|
Ref<SceneState> get_scene_instance_state() const;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void set_scene_inherited_state(const Ref<SceneState> &p_state);
|
2015-10-10 20:09:09 +08:00
|
|
|
Ref<SceneState> get_scene_inherited_state() const;
|
|
|
|
|
2015-10-17 06:11:23 +08:00
|
|
|
void set_scene_instance_load_placeholder(bool p_enable);
|
|
|
|
bool get_scene_instance_load_placeholder() const;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
static Vector<Variant> make_binds(VARIANT_ARG_LIST);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void replace_by(Node *p_node, bool p_keep_data = false);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
void set_pause_mode(PauseMode p_mode);
|
|
|
|
PauseMode get_pause_mode() const;
|
|
|
|
bool can_process() const;
|
2018-07-30 08:20:41 +08:00
|
|
|
bool can_process_notification(int p_what) const;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-01-11 05:02:19 +08:00
|
|
|
void request_ready();
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
static void print_stray_nodes();
|
|
|
|
|
2016-10-08 02:25:29 +08:00
|
|
|
#ifdef TOOLS_ENABLED
|
2017-03-05 23:44:50 +08:00
|
|
|
String validate_child_name(Node *p_child);
|
2016-10-08 02:25:29 +08:00
|
|
|
#endif
|
2015-08-02 23:29:37 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
void queue_delete();
|
|
|
|
|
2018-02-17 21:00:39 +08:00
|
|
|
//hacks for speed
|
2014-02-23 07:28:19 +08:00
|
|
|
static void set_human_readable_collision_renaming(bool p_enabled);
|
|
|
|
static void init_node_hrcr();
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void force_parent_owned() { data.parent_owned = true; } //hack to avoid duplicate nodes
|
2014-04-05 23:39:30 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void set_import_path(const NodePath &p_import_path); //path used when imported, used by scene editors to keep tracking
|
2014-06-19 13:23:03 +08:00
|
|
|
NodePath get_import_path() const;
|
|
|
|
|
2016-06-21 09:57:07 +08:00
|
|
|
bool is_owned_by_parent() const;
|
|
|
|
|
2020-07-10 18:34:39 +08:00
|
|
|
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
|
2014-06-19 13:23:03 +08:00
|
|
|
|
2015-06-22 11:03:19 +08:00
|
|
|
void clear_internal_tree_resource_paths();
|
|
|
|
|
2014-04-10 11:18:27 +08:00
|
|
|
_FORCE_INLINE_ Viewport *get_viewport() const { return data.viewport; }
|
|
|
|
|
2016-05-18 05:27:15 +08:00
|
|
|
virtual String get_configuration_warning() const;
|
|
|
|
|
|
|
|
void update_configuration_warning();
|
|
|
|
|
2016-06-29 00:10:15 +08:00
|
|
|
void set_display_folded(bool p_folded);
|
|
|
|
bool is_displayed_folded() const;
|
2016-08-15 05:49:50 +08:00
|
|
|
/* NETWORK */
|
|
|
|
|
2017-07-03 21:44:45 +08:00
|
|
|
void set_network_master(int p_peer_id, bool p_recursive = true);
|
|
|
|
int get_network_master() const;
|
2016-08-15 05:49:50 +08:00
|
|
|
bool is_network_master() const;
|
|
|
|
|
2020-02-12 18:51:50 +08:00
|
|
|
uint16_t rpc_config(const StringName &p_method, MultiplayerAPI::RPCMode p_mode); // config a local method for RPC
|
|
|
|
uint16_t rset_config(const StringName &p_property, MultiplayerAPI::RPCMode p_mode); // config a local property for RPC
|
2016-08-15 05:49:50 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void rpc(const StringName &p_method, VARIANT_ARG_LIST); //rpc call, honors RPCMode
|
|
|
|
void rpc_unreliable(const StringName &p_method, VARIANT_ARG_LIST); //rpc call, honors RPCMode
|
|
|
|
void rpc_id(int p_peer_id, const StringName &p_method, VARIANT_ARG_LIST); //rpc call, honors RPCMode
|
|
|
|
void rpc_unreliable_id(int p_peer_id, const StringName &p_method, VARIANT_ARG_LIST); //rpc call, honors RPCMode
|
2016-08-15 05:49:50 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void rset(const StringName &p_property, const Variant &p_value); //remote set call, honors RPCMode
|
|
|
|
void rset_unreliable(const StringName &p_property, const Variant &p_value); //remote set call, honors RPCMode
|
|
|
|
void rset_id(int p_peer_id, const StringName &p_property, const Variant &p_value); //remote set call, honors RPCMode
|
|
|
|
void rset_unreliable_id(int p_peer_id, const StringName &p_property, const Variant &p_value); //remote set call, honors RPCMode
|
2016-08-15 05:49:50 +08:00
|
|
|
|
2018-03-04 01:30:11 +08:00
|
|
|
void rpcp(int p_peer_id, bool p_unreliable, const StringName &p_method, const Variant **p_arg, int p_argcount);
|
2017-03-05 23:44:50 +08:00
|
|
|
void rsetp(int p_peer_id, bool p_unreliable, const StringName &p_property, const Variant &p_value);
|
2016-08-15 05:49:50 +08:00
|
|
|
|
2018-05-08 16:51:04 +08:00
|
|
|
Ref<MultiplayerAPI> get_multiplayer() const;
|
|
|
|
Ref<MultiplayerAPI> get_custom_multiplayer() const;
|
|
|
|
void set_custom_multiplayer(Ref<MultiplayerAPI> p_multiplayer);
|
2020-02-12 18:51:50 +08:00
|
|
|
|
|
|
|
/// Returns the rpc method ID, otherwise UINT32_MAX
|
|
|
|
uint16_t get_node_rpc_method_id(const StringName &p_method) const;
|
|
|
|
StringName get_node_rpc_method(const uint16_t p_rpc_method_id) const;
|
|
|
|
MultiplayerAPI::RPCMode get_node_rpc_mode_by_id(const uint16_t p_rpc_method_id) const;
|
|
|
|
MultiplayerAPI::RPCMode get_node_rpc_mode(const StringName &p_method) const;
|
|
|
|
|
|
|
|
/// Returns the rpc property ID, otherwise UINT32_MAX
|
|
|
|
uint16_t get_node_rset_property_id(const StringName &p_property) const;
|
|
|
|
StringName get_node_rset_property(const uint16_t p_rset_property_id) const;
|
|
|
|
MultiplayerAPI::RPCMode get_node_rset_mode_by_id(const uint16_t p_rpc_method_id) const;
|
|
|
|
MultiplayerAPI::RPCMode get_node_rset_mode(const StringName &p_property) const;
|
|
|
|
|
|
|
|
/// Can be used to check if the rpc methods and the rset properties are the
|
|
|
|
/// same across the peers.
|
|
|
|
String get_rpc_md5() const;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
Node();
|
|
|
|
~Node();
|
|
|
|
};
|
|
|
|
|
2017-08-20 23:45:01 +08:00
|
|
|
VARIANT_ENUM_CAST(Node::DuplicateFlags);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
typedef Set<Node *, Node::Comparator> NodeSet;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
#endif
|