1 /** 2 Base class for all $(I scene) objects. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.node; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 import godot.classdb; 24 import godot.inputevent; 25 import godot.inputeventkey; 26 import godot.multiplayerapi; 27 import godot.scenetree; 28 import godot.viewport; 29 /** 30 Base class for all $(I scene) objects. 31 32 Nodes are Godot's building blocks. They can be assigned as the child of another node, resulting in a tree arrangement. A given node can contain any number of nodes as children with the requirement that all siblings (direct children of a node) should have unique names. 33 A tree of nodes is called a $(I scene). Scenes can be saved to the disk and then instanced into other scenes. This allows for very high flexibility in the architecture and data model of Godot projects. 34 $(B Scene tree:) The $(D SceneTree) contains the active tree of nodes. When a node is added to the scene tree, it receives the $(D constant NOTIFICATION_ENTER_TREE) notification and its $(D _enterTree) callback is triggered. Child nodes are always added $(I after) their parent node, i.e. the $(D _enterTree) callback of a parent node will be triggered before its child's. 35 Once all nodes have been added in the scene tree, they receive the $(D constant NOTIFICATION_READY) notification and their respective $(D _ready) callbacks are triggered. For groups of nodes, the $(D _ready) callback is called in reverse order, starting with the children and moving up to the parent nodes. 36 This means that when adding a node to the scene tree, the following order will be used for the callbacks: $(D _enterTree) of the parent, $(D _enterTree) of the children, $(D _ready) of the children and finally $(D _ready) of the parent (recursively for the entire scene tree). 37 $(B Processing:) Nodes can override the "process" state, so that they receive a callback on each frame requesting them to process (do something). Normal processing (callback $(D _process), toggled with $(D setProcess)) happens as fast as possible and is dependent on the frame rate, so the processing time $(I delta) (in seconds) is passed as an argument. Physics processing (callback $(D _physicsProcess), toggled with $(D setPhysicsProcess)) happens a fixed number of times per second (60 by default) and is useful for code related to the physics engine. 38 Nodes can also process input events. When present, the $(D _input) function will be called for each input that the program receives. In many cases, this can be overkill (unless used for simple projects), and the $(D _unhandledInput) function might be preferred; it is called when the input event was not handled by anyone else (typically, GUI $(D Control) nodes), ensuring that the node only receives the events that were meant for it. 39 To keep track of the scene hierarchy (especially when instancing scenes into other scenes), an "owner" can be set for the node with the $(D owner) property. This keeps track of who instanced what. This is mostly useful when writing editors and tools, though. 40 Finally, when a node is freed with $(D GodotObject.free) or $(D queueFree), it will also free all its children. 41 $(B Groups:) Nodes can be added to as many groups as you want to be easy to manage, you could create groups like "enemies" or "collectables" for example, depending on your game. See $(D addToGroup), $(D isInGroup) and $(D removeFromGroup). You can then retrieve all nodes in these groups, iterate them and even call methods on groups via the methods on $(D SceneTree). 42 $(B Networking with nodes:) After connecting to a server (or making one, see $(D NetworkedMultiplayerENet)), it is possible to use the built-in RPC (remote procedure call) system to communicate over the network. By calling $(D rpc) with a method name, it will be called locally and in all connected peers (peers = clients and the server that accepts connections). To identify which node receives the RPC call, Godot will use its $(D NodePath) (make sure node names are the same on all peers). Also, take a look at the high-level networking tutorial and corresponding demos. 43 */ 44 @GodotBaseClass struct Node 45 { 46 package(godot) enum string _GODOT_internal_name = "Node"; 47 public: 48 @nogc nothrow: 49 union { /** */ godot_object _godot_object; /** */ GodotObject _GODOT_base; } 50 alias _GODOT_base this; 51 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 52 package(godot) __gshared bool _classBindingInitialized = false; 53 package(godot) static struct GDNativeClassBinding 54 { 55 __gshared: 56 @GodotName("_enter_tree") GodotMethod!(void) _enterTree; 57 @GodotName("_exit_tree") GodotMethod!(void) _exitTree; 58 @GodotName("_get_configuration_warning") GodotMethod!(String) _getConfigurationWarning; 59 @GodotName("_get_editor_description") GodotMethod!(String) _getEditorDescription; 60 @GodotName("_get_import_path") GodotMethod!(NodePath) _getImportPath; 61 @GodotName("_input") GodotMethod!(void, InputEvent) _input; 62 @GodotName("_physics_process") GodotMethod!(void, double) _physicsProcess; 63 @GodotName("_process") GodotMethod!(void, double) _process; 64 @GodotName("_ready") GodotMethod!(void) _ready; 65 @GodotName("_set_editor_description") GodotMethod!(void, String) _setEditorDescription; 66 @GodotName("_set_import_path") GodotMethod!(void, NodePath) _setImportPath; 67 @GodotName("_unhandled_input") GodotMethod!(void, InputEvent) _unhandledInput; 68 @GodotName("_unhandled_key_input") GodotMethod!(void, InputEventKey) _unhandledKeyInput; 69 @GodotName("add_child") GodotMethod!(void, Node, bool) addChild; 70 @GodotName("add_child_below_node") GodotMethod!(void, Node, Node, bool) addChildBelowNode; 71 @GodotName("add_to_group") GodotMethod!(void, String, bool) addToGroup; 72 @GodotName("can_process") GodotMethod!(bool) canProcess; 73 @GodotName("duplicate") GodotMethod!(Node, long) duplicate; 74 @GodotName("find_node") GodotMethod!(Node, String, bool, bool) findNode; 75 @GodotName("find_parent") GodotMethod!(Node, String) findParent; 76 @GodotName("get_child") GodotMethod!(Node, long) getChild; 77 @GodotName("get_child_count") GodotMethod!(long) getChildCount; 78 @GodotName("get_children") GodotMethod!(Array) getChildren; 79 @GodotName("get_custom_multiplayer") GodotMethod!(MultiplayerAPI) getCustomMultiplayer; 80 @GodotName("get_filename") GodotMethod!(String) getFilename; 81 @GodotName("get_groups") GodotMethod!(Array) getGroups; 82 @GodotName("get_index") GodotMethod!(long) getIndex; 83 @GodotName("get_multiplayer") GodotMethod!(MultiplayerAPI) getMultiplayer; 84 @GodotName("get_name") GodotMethod!(String) getName; 85 @GodotName("get_network_master") GodotMethod!(long) getNetworkMaster; 86 @GodotName("get_node") GodotMethod!(Node, NodePath) getNode; 87 @GodotName("get_node_and_resource") GodotMethod!(Array, NodePath) getNodeAndResource; 88 @GodotName("get_node_or_null") GodotMethod!(Node, NodePath) getNodeOrNull; 89 @GodotName("get_owner") GodotMethod!(Node) getOwner; 90 @GodotName("get_parent") GodotMethod!(Node) getParent; 91 @GodotName("get_path") GodotMethod!(NodePath) getPath; 92 @GodotName("get_path_to") GodotMethod!(NodePath, Node) getPathTo; 93 @GodotName("get_pause_mode") GodotMethod!(Node.PauseMode) getPauseMode; 94 @GodotName("get_physics_process_delta_time") GodotMethod!(double) getPhysicsProcessDeltaTime; 95 @GodotName("get_position_in_parent") GodotMethod!(long) getPositionInParent; 96 @GodotName("get_process_delta_time") GodotMethod!(double) getProcessDeltaTime; 97 @GodotName("get_process_priority") GodotMethod!(long) getProcessPriority; 98 @GodotName("get_scene_instance_load_placeholder") GodotMethod!(bool) getSceneInstanceLoadPlaceholder; 99 @GodotName("get_tree") GodotMethod!(SceneTree) getTree; 100 @GodotName("get_viewport") GodotMethod!(Viewport) getViewport; 101 @GodotName("has_node") GodotMethod!(bool, NodePath) hasNode; 102 @GodotName("has_node_and_resource") GodotMethod!(bool, NodePath) hasNodeAndResource; 103 @GodotName("is_a_parent_of") GodotMethod!(bool, Node) isAParentOf; 104 @GodotName("is_displayed_folded") GodotMethod!(bool) isDisplayedFolded; 105 @GodotName("is_greater_than") GodotMethod!(bool, Node) isGreaterThan; 106 @GodotName("is_in_group") GodotMethod!(bool, String) isInGroup; 107 @GodotName("is_inside_tree") GodotMethod!(bool) isInsideTree; 108 @GodotName("is_network_master") GodotMethod!(bool) isNetworkMaster; 109 @GodotName("is_physics_processing") GodotMethod!(bool) isPhysicsProcessing; 110 @GodotName("is_physics_processing_internal") GodotMethod!(bool) isPhysicsProcessingInternal; 111 @GodotName("is_processing") GodotMethod!(bool) isProcessing; 112 @GodotName("is_processing_input") GodotMethod!(bool) isProcessingInput; 113 @GodotName("is_processing_internal") GodotMethod!(bool) isProcessingInternal; 114 @GodotName("is_processing_unhandled_input") GodotMethod!(bool) isProcessingUnhandledInput; 115 @GodotName("is_processing_unhandled_key_input") GodotMethod!(bool) isProcessingUnhandledKeyInput; 116 @GodotName("move_child") GodotMethod!(void, Node, long) moveChild; 117 @GodotName("print_stray_nodes") GodotMethod!(void) printStrayNodes; 118 @GodotName("print_tree") GodotMethod!(void) printTree; 119 @GodotName("print_tree_pretty") GodotMethod!(void) printTreePretty; 120 @GodotName("propagate_call") GodotMethod!(void, String, Array, bool) propagateCall; 121 @GodotName("propagate_notification") GodotMethod!(void, long) propagateNotification; 122 @GodotName("queue_free") GodotMethod!(void) queueFree; 123 @GodotName("raise") GodotMethod!(void) raise; 124 @GodotName("remove_and_skip") GodotMethod!(void) removeAndSkip; 125 @GodotName("remove_child") GodotMethod!(void, Node) removeChild; 126 @GodotName("remove_from_group") GodotMethod!(void, String) removeFromGroup; 127 @GodotName("replace_by") GodotMethod!(void, Node, bool) replaceBy; 128 @GodotName("request_ready") GodotMethod!(void) requestReady; 129 @GodotName("rpc") GodotMethod!(Variant, String, GodotVarArgs) rpc; 130 @GodotName("rpc_config") GodotMethod!(void, String, long) rpcConfig; 131 @GodotName("rpc_id") GodotMethod!(Variant, long, String, GodotVarArgs) rpcId; 132 @GodotName("rpc_unreliable") GodotMethod!(Variant, String, GodotVarArgs) rpcUnreliable; 133 @GodotName("rpc_unreliable_id") GodotMethod!(Variant, long, String, GodotVarArgs) rpcUnreliableId; 134 @GodotName("rset") GodotMethod!(void, String, Variant) rset; 135 @GodotName("rset_config") GodotMethod!(void, String, long) rsetConfig; 136 @GodotName("rset_id") GodotMethod!(void, long, String, Variant) rsetId; 137 @GodotName("rset_unreliable") GodotMethod!(void, String, Variant) rsetUnreliable; 138 @GodotName("rset_unreliable_id") GodotMethod!(void, long, String, Variant) rsetUnreliableId; 139 @GodotName("set_custom_multiplayer") GodotMethod!(void, MultiplayerAPI) setCustomMultiplayer; 140 @GodotName("set_display_folded") GodotMethod!(void, bool) setDisplayFolded; 141 @GodotName("set_filename") GodotMethod!(void, String) setFilename; 142 @GodotName("set_name") GodotMethod!(void, String) setName; 143 @GodotName("set_network_master") GodotMethod!(void, long, bool) setNetworkMaster; 144 @GodotName("set_owner") GodotMethod!(void, Node) setOwner; 145 @GodotName("set_pause_mode") GodotMethod!(void, long) setPauseMode; 146 @GodotName("set_physics_process") GodotMethod!(void, bool) setPhysicsProcess; 147 @GodotName("set_physics_process_internal") GodotMethod!(void, bool) setPhysicsProcessInternal; 148 @GodotName("set_process") GodotMethod!(void, bool) setProcess; 149 @GodotName("set_process_input") GodotMethod!(void, bool) setProcessInput; 150 @GodotName("set_process_internal") GodotMethod!(void, bool) setProcessInternal; 151 @GodotName("set_process_priority") GodotMethod!(void, long) setProcessPriority; 152 @GodotName("set_process_unhandled_input") GodotMethod!(void, bool) setProcessUnhandledInput; 153 @GodotName("set_process_unhandled_key_input") GodotMethod!(void, bool) setProcessUnhandledKeyInput; 154 @GodotName("set_scene_instance_load_placeholder") GodotMethod!(void, bool) setSceneInstanceLoadPlaceholder; 155 @GodotName("update_configuration_warning") GodotMethod!(void) updateConfigurationWarning; 156 } 157 /// 158 pragma(inline, true) bool opEquals(in Node other) const 159 { return _godot_object.ptr is other._godot_object.ptr; } 160 /// 161 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 162 { _godot_object.ptr = n; return null; } 163 /// 164 pragma(inline, true) bool opEquals(typeof(null) n) const 165 { return _godot_object.ptr is n; } 166 /// 167 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 168 mixin baseCasts; 169 /// Construct a new instance of Node. 170 /// Note: use `memnew!Node` instead. 171 static Node _new() 172 { 173 static godot_class_constructor constructor; 174 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Node"); 175 if(constructor is null) return typeof(this).init; 176 return cast(Node)(constructor()); 177 } 178 @disable new(size_t s); 179 /// 180 enum PauseMode : int 181 { 182 /** 183 Inherits pause mode from the node's parent. For the root node, it is equivalent to $(D constant PAUSE_MODE_STOP). Default. 184 */ 185 pauseModeInherit = 0, 186 /** 187 Stops processing when the $(D SceneTree) is paused. 188 */ 189 pauseModeStop = 1, 190 /** 191 Continue to process regardless of the $(D SceneTree) pause state. 192 */ 193 pauseModeProcess = 2, 194 } 195 /// 196 enum DuplicateFlags : int 197 { 198 /** 199 Duplicate the node's signals. 200 */ 201 duplicateSignals = 1, 202 /** 203 Duplicate the node's groups. 204 */ 205 duplicateGroups = 2, 206 /** 207 Duplicate the node's scripts. 208 */ 209 duplicateScripts = 4, 210 /** 211 Duplicate using instancing. 212 An instance stays linked to the original so when the original changes, the instance changes too. 213 */ 214 duplicateUseInstancing = 8, 215 } 216 /// 217 enum Constants : int 218 { 219 pauseModeInherit = 0, 220 pauseModeStop = 1, 221 duplicateSignals = 1, 222 duplicateGroups = 2, 223 pauseModeProcess = 2, 224 duplicateScripts = 4, 225 duplicateUseInstancing = 8, 226 /** 227 Notification received when the node enters a $(D SceneTree). 228 */ 229 notificationEnterTree = 10, 230 /** 231 Notification received when the node is about to exit a $(D SceneTree). 232 */ 233 notificationExitTree = 11, 234 /** 235 Notification received when the node is moved in the parent. 236 */ 237 notificationMovedInParent = 12, 238 /** 239 Notification received when the node is ready. See $(D _ready). 240 */ 241 notificationReady = 13, 242 /** 243 Notification received when the node is paused. 244 */ 245 notificationPaused = 14, 246 /** 247 Notification received when the node is unpaused. 248 */ 249 notificationUnpaused = 15, 250 /** 251 Notification received every frame when the physics process flag is set (see $(D setPhysicsProcess)). 252 */ 253 notificationPhysicsProcess = 16, 254 /** 255 Notification received every frame when the process flag is set (see $(D setProcess)). 256 */ 257 notificationProcess = 17, 258 /** 259 Notification received when a node is set as a child of another node. 260 $(B Note:) This doesn't mean that a node entered the $(D SceneTree). 261 */ 262 notificationParented = 18, 263 /** 264 Notification received when a node is unparented (parent removed it from the list of children). 265 */ 266 notificationUnparented = 19, 267 /** 268 Notification received when the node is instanced. 269 */ 270 notificationInstanced = 20, 271 /** 272 Notification received when a drag begins. 273 */ 274 notificationDragBegin = 21, 275 /** 276 Notification received when a drag ends. 277 */ 278 notificationDragEnd = 22, 279 /** 280 Notification received when the node's $(D NodePath) changed. 281 */ 282 notificationPathChanged = 23, 283 /** 284 Notification received every frame when the internal process flag is set (see $(D setProcessInternal)). 285 */ 286 notificationInternalProcess = 25, 287 /** 288 Notification received every frame when the internal physics process flag is set (see $(D setPhysicsProcessInternal)). 289 */ 290 notificationInternalPhysicsProcess = 26, 291 /** 292 Notification received when the node is ready, just before $(D constant NOTIFICATION_READY) is received. Unlike the latter, it's sent every time the node enters tree, instead of only once. 293 */ 294 notificationPostEnterTree = 27, 295 /** 296 Notification received from the OS when the mouse enters the game window. 297 Implemented on desktop and web platforms. 298 */ 299 notificationWmMouseEnter = 1002, 300 /** 301 Notification received from the OS when the mouse leaves the game window. 302 Implemented on desktop and web platforms. 303 */ 304 notificationWmMouseExit = 1003, 305 /** 306 Notification received from the OS when the game window is focused. 307 Implemented on all platforms. 308 */ 309 notificationWmFocusIn = 1004, 310 /** 311 Notification received from the OS when the game window is unfocused. 312 Implemented on all platforms. 313 */ 314 notificationWmFocusOut = 1005, 315 /** 316 Notification received from the OS when a quit request is sent (e.g. closing the window with a "Close" button or Alt+F4). 317 Implemented on desktop platforms. 318 */ 319 notificationWmQuitRequest = 1006, 320 /** 321 Notification received from the OS when a go back request is sent (e.g. pressing the "Back" button on Android). 322 Specific to the Android platform. 323 */ 324 notificationWmGoBackRequest = 1007, 325 /** 326 Notification received from the OS when an unfocus request is sent (e.g. another OS window wants to take the focus). 327 No supported platforms currently send this notification. 328 */ 329 notificationWmUnfocusRequest = 1008, 330 /** 331 Notification received from the OS when the application is exceeding its allocated memory. 332 Specific to the iOS platform. 333 */ 334 notificationOsMemoryWarning = 1009, 335 /** 336 Notification received when translations may have changed. Can be triggered by the user changing the locale. Can be used to respond to language changes, for example to change the UI strings on the fly. Useful when working with the built-in translation support, like $(D GodotObject.tr). 337 */ 338 notificationTranslationChanged = 1010, 339 /** 340 Notification received from the OS when a request for "About" information is sent. 341 Specific to the macOS platform. 342 */ 343 notificationWmAbout = 1011, 344 /** 345 Notification received from Godot's crash handler when the engine is about to crash. 346 Implemented on desktop platforms if the crash handler is enabled. 347 */ 348 notificationCrash = 1012, 349 /** 350 Notification received from the OS when an update of the Input Method Engine occurs (e.g. change of IME cursor position or composition string). 351 Specific to the macOS platform. 352 */ 353 notificationOsImeUpdate = 1013, 354 /** 355 Notification received from the OS when the app is resumed. 356 Specific to the Android platform. 357 */ 358 notificationAppResumed = 1014, 359 /** 360 Notification received from the OS when the app is paused. 361 Specific to the Android platform. 362 */ 363 notificationAppPaused = 1015, 364 } 365 /** 366 Called when the node enters the $(D SceneTree) (e.g. upon instancing, scene changing, or after calling $(D addChild) in a script). If the node has children, its $(D _enterTree) callback will be called first, and then that of the children. 367 Corresponds to the $(D constant NOTIFICATION_ENTER_TREE) notification in $(D GodotObject._notification). 368 */ 369 void _enterTree() 370 { 371 Array _GODOT_args = Array.make(); 372 String _GODOT_method_name = String("_enter_tree"); 373 this.callv(_GODOT_method_name, _GODOT_args); 374 } 375 /** 376 Called when the node is about to leave the $(D SceneTree) (e.g. upon freeing, scene changing, or after calling $(D removeChild) in a script). If the node has children, its $(D _exitTree) callback will be called last, after all its children have left the tree. 377 Corresponds to the $(D constant NOTIFICATION_EXIT_TREE) notification in $(D GodotObject._notification) and signal $(D treeExiting). To get notified when the node has already left the active tree, connect to the $(D treeExited). 378 */ 379 void _exitTree() 380 { 381 Array _GODOT_args = Array.make(); 382 String _GODOT_method_name = String("_exit_tree"); 383 this.callv(_GODOT_method_name, _GODOT_args); 384 } 385 /** 386 The string returned from this method is displayed as a warning in the Scene Dock if the script that overrides it is a `tool` script. 387 Returning an empty string produces no warning. 388 Call $(D updateConfigurationWarning) when the warning needs to be updated for this node. 389 */ 390 String _getConfigurationWarning() 391 { 392 Array _GODOT_args = Array.make(); 393 String _GODOT_method_name = String("_get_configuration_warning"); 394 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String); 395 } 396 /** 397 398 */ 399 String _getEditorDescription() const 400 { 401 Array _GODOT_args = Array.make(); 402 String _GODOT_method_name = String("_get_editor_description"); 403 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String); 404 } 405 /** 406 407 */ 408 NodePath _getImportPath() const 409 { 410 Array _GODOT_args = Array.make(); 411 String _GODOT_method_name = String("_get_import_path"); 412 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!NodePath); 413 } 414 /** 415 Called when there is an input event. The input event propagates up through the node tree until a node consumes it. 416 It is only called if input processing is enabled, which is done automatically if this method is overridden, and can be toggled with $(D setProcessInput). 417 To consume the input event and stop it propagating further to other nodes, $(D SceneTree.setInputAsHandled) can be called. 418 For gameplay input, $(D _unhandledInput) and $(D _unhandledKeyInput) are usually a better fit as they allow the GUI to intercept the events first. 419 $(B Note:) This method is only called if the node is present in the scene tree (i.e. if it's not orphan). 420 */ 421 void _input(InputEvent event) 422 { 423 Array _GODOT_args = Array.make(); 424 _GODOT_args.append(event); 425 String _GODOT_method_name = String("_input"); 426 this.callv(_GODOT_method_name, _GODOT_args); 427 } 428 /** 429 Called during the physics processing step of the main loop. Physics processing means that the frame rate is synced to the physics, i.e. the `delta` variable should be constant. `delta` is in seconds. 430 It is only called if physics processing is enabled, which is done automatically if this method is overridden, and can be toggled with $(D setPhysicsProcess). 431 Corresponds to the $(D constant NOTIFICATION_PHYSICS_PROCESS) notification in $(D GodotObject._notification). 432 $(B Note:) This method is only called if the node is present in the scene tree (i.e. if it's not orphan). 433 */ 434 void _physicsProcess(in double delta) 435 { 436 Array _GODOT_args = Array.make(); 437 _GODOT_args.append(delta); 438 String _GODOT_method_name = String("_physics_process"); 439 this.callv(_GODOT_method_name, _GODOT_args); 440 } 441 /** 442 Called during the processing step of the main loop. Processing happens at every frame and as fast as possible, so the `delta` time since the previous frame is not constant. `delta` is in seconds. 443 It is only called if processing is enabled, which is done automatically if this method is overridden, and can be toggled with $(D setProcess). 444 Corresponds to the $(D constant NOTIFICATION_PROCESS) notification in $(D GodotObject._notification). 445 $(B Note:) This method is only called if the node is present in the scene tree (i.e. if it's not orphan). 446 */ 447 void _process(in double delta) 448 { 449 Array _GODOT_args = Array.make(); 450 _GODOT_args.append(delta); 451 String _GODOT_method_name = String("_process"); 452 this.callv(_GODOT_method_name, _GODOT_args); 453 } 454 /** 455 Called when the node is "ready", i.e. when both the node and its children have entered the scene tree. If the node has children, their $(D _ready) callbacks get triggered first, and the parent node will receive the ready notification afterwards. 456 Corresponds to the $(D constant NOTIFICATION_READY) notification in $(D GodotObject._notification). See also the `onready` keyword for variables. 457 Usually used for initialization. For even earlier initialization, $(D GodotObject._init) may be used. See also $(D _enterTree). 458 $(B Note:) $(D _ready) may be called only once for each node. After removing a node from the scene tree and adding again, `_ready` will not be called for the second time. This can be bypassed with requesting another call with $(D requestReady), which may be called anywhere before adding the node again. 459 */ 460 void _ready() 461 { 462 Array _GODOT_args = Array.make(); 463 String _GODOT_method_name = String("_ready"); 464 this.callv(_GODOT_method_name, _GODOT_args); 465 } 466 /** 467 468 */ 469 void _setEditorDescription(in String editor_description) 470 { 471 Array _GODOT_args = Array.make(); 472 _GODOT_args.append(editor_description); 473 String _GODOT_method_name = String("_set_editor_description"); 474 this.callv(_GODOT_method_name, _GODOT_args); 475 } 476 /** 477 478 */ 479 void _setImportPath(NodePathArg0)(in NodePathArg0 import_path) 480 { 481 Array _GODOT_args = Array.make(); 482 _GODOT_args.append(import_path); 483 String _GODOT_method_name = String("_set_import_path"); 484 this.callv(_GODOT_method_name, _GODOT_args); 485 } 486 /** 487 Called when an $(D InputEvent) hasn't been consumed by $(D _input) or any GUI. The input event propagates up through the node tree until a node consumes it. 488 It is only called if unhandled input processing is enabled, which is done automatically if this method is overridden, and can be toggled with $(D setProcessUnhandledInput). 489 To consume the input event and stop it propagating further to other nodes, $(D SceneTree.setInputAsHandled) can be called. 490 For gameplay input, this and $(D _unhandledKeyInput) are usually a better fit than $(D _input) as they allow the GUI to intercept the events first. 491 $(B Note:) This method is only called if the node is present in the scene tree (i.e. if it's not orphan). 492 */ 493 void _unhandledInput(InputEvent event) 494 { 495 Array _GODOT_args = Array.make(); 496 _GODOT_args.append(event); 497 String _GODOT_method_name = String("_unhandled_input"); 498 this.callv(_GODOT_method_name, _GODOT_args); 499 } 500 /** 501 Called when an $(D InputEventKey) hasn't been consumed by $(D _input) or any GUI. The input event propagates up through the node tree until a node consumes it. 502 It is only called if unhandled key input processing is enabled, which is done automatically if this method is overridden, and can be toggled with $(D setProcessUnhandledKeyInput). 503 To consume the input event and stop it propagating further to other nodes, $(D SceneTree.setInputAsHandled) can be called. 504 For gameplay input, this and $(D _unhandledInput) are usually a better fit than $(D _input) as they allow the GUI to intercept the events first. 505 $(B Note:) This method is only called if the node is present in the scene tree (i.e. if it's not orphan). 506 */ 507 void _unhandledKeyInput(InputEventKey event) 508 { 509 Array _GODOT_args = Array.make(); 510 _GODOT_args.append(event); 511 String _GODOT_method_name = String("_unhandled_key_input"); 512 this.callv(_GODOT_method_name, _GODOT_args); 513 } 514 /** 515 Adds a child node. Nodes can have any number of children, but every child must have a unique name. Child nodes are automatically deleted when the parent node is deleted, so an entire scene can be removed by deleting its topmost node. 516 If `legible_unique_name` is `true`, the child node will have a human-readable name based on the name of the node being instanced instead of its type. 517 $(B Note:) If the child node already has a parent, the function will fail. Use $(D removeChild) first to remove the node from its current parent. For example: 518 519 520 if child_node.get_parent(): 521 child_node.get_parent().remove_child(child_node) 522 add_child(child_node) 523 524 525 $(B Note:) If you want a child to be persisted to a $(D PackedScene), you must set $(D owner) in addition to calling $(D addChild). This is typically relevant for $(D url=https://godot.readthedocs.io/en/3.2/tutorials/misc/running_code_in_the_editor.html)tool scripts$(D /url) and $(D url=https://godot.readthedocs.io/en/latest/tutorials/plugins/editor/index.html)editor plugins$(D /url). If $(D addChild) is called without setting $(D owner), the newly added $(D Node) will not be visible in the scene tree, though it will be visible in the 2D/3D view. 526 */ 527 void addChild(Node node, in bool legible_unique_name = false) 528 { 529 checkClassBinding!(typeof(this))(); 530 ptrcall!(void)(GDNativeClassBinding.addChild, _godot_object, node, legible_unique_name); 531 } 532 /** 533 Adds `child_node` as a child. The child is placed below the given `node` in the list of children. 534 If `legible_unique_name` is `true`, the child node will have a human-readable name based on the name of the node being instanced instead of its type. 535 */ 536 void addChildBelowNode(Node node, Node child_node, in bool legible_unique_name = false) 537 { 538 checkClassBinding!(typeof(this))(); 539 ptrcall!(void)(GDNativeClassBinding.addChildBelowNode, _godot_object, node, child_node, legible_unique_name); 540 } 541 /** 542 Adds the node to a group. Groups are helpers to name and organize a subset of nodes, for example "enemies" or "collectables". A node can be in any number of groups. Nodes can be assigned a group at any time, but will not be added until they are inside the scene tree (see $(D isInsideTree)). See notes in the description, and the group methods in $(D SceneTree). 543 The `persistent` option is used when packing node to $(D PackedScene) and saving to file. Non-persistent groups aren't stored. 544 */ 545 void addToGroup(in String group, in bool persistent = false) 546 { 547 checkClassBinding!(typeof(this))(); 548 ptrcall!(void)(GDNativeClassBinding.addToGroup, _godot_object, group, persistent); 549 } 550 /** 551 Returns `true` if the node can process while the scene tree is paused (see $(D pauseMode)). Always returns `true` if the scene tree is not paused, and `false` if the node is not in the tree. 552 */ 553 bool canProcess() const 554 { 555 checkClassBinding!(typeof(this))(); 556 return ptrcall!(bool)(GDNativeClassBinding.canProcess, _godot_object); 557 } 558 /** 559 Duplicates the node, returning a new node. 560 You can fine-tune the behavior using the `flags` (see $(D duplicateflags)). 561 $(B Note:) It will not work properly if the node contains a script with constructor arguments (i.e. needs to supply arguments to $(D GodotObject._init) method). In that case, the node will be duplicated without a script. 562 */ 563 Node duplicate(in long flags = 15) const 564 { 565 checkClassBinding!(typeof(this))(); 566 return ptrcall!(Node)(GDNativeClassBinding.duplicate, _godot_object, flags); 567 } 568 /** 569 Finds a descendant of this node whose name matches `mask` as in $(D String.match) (i.e. case-sensitive, but `"*"` matches zero or more characters and `"?"` matches any single character except `"."`). 570 $(B Note:) It does not match against the full path, just against individual node names. 571 If `owned` is `true`, this method only finds nodes whose owner is this node. This is especially important for scenes instantiated through a script, because those scenes don't have an owner. 572 $(B Note:) As this method walks through all the descendants of the node, it is the slowest way to get a reference to another node. Whenever possible, consider using $(D getNode) instead. To avoid using $(D findNode) too often, consider caching the node reference into a variable. 573 */ 574 Node findNode(in String mask, in bool recursive = true, in bool owned = true) const 575 { 576 checkClassBinding!(typeof(this))(); 577 return ptrcall!(Node)(GDNativeClassBinding.findNode, _godot_object, mask, recursive, owned); 578 } 579 /** 580 Finds the first parent of the current node whose name matches `mask` as in $(D String.match) (i.e. case-sensitive, but `"*"` matches zero or more characters and `"?"` matches any single character except `"."`). 581 $(B Note:) It does not match against the full path, just against individual node names. 582 $(B Note:) As this method walks upwards in the scene tree, it can be slow in large, deeply nested scene trees. Whenever possible, consider using $(D getNode) instead. To avoid using $(D findParent) too often, consider caching the node reference into a variable. 583 */ 584 Node findParent(in String mask) const 585 { 586 checkClassBinding!(typeof(this))(); 587 return ptrcall!(Node)(GDNativeClassBinding.findParent, _godot_object, mask); 588 } 589 /** 590 Returns a child node by its index (see $(D getChildCount)). This method is often used for iterating all children of a node. 591 To access a child node via its name, use $(D getNode). 592 */ 593 Node getChild(in long idx) const 594 { 595 checkClassBinding!(typeof(this))(); 596 return ptrcall!(Node)(GDNativeClassBinding.getChild, _godot_object, idx); 597 } 598 /** 599 Returns the number of child nodes. 600 */ 601 long getChildCount() const 602 { 603 checkClassBinding!(typeof(this))(); 604 return ptrcall!(long)(GDNativeClassBinding.getChildCount, _godot_object); 605 } 606 /** 607 Returns an array of references to node's children. 608 */ 609 Array getChildren() const 610 { 611 checkClassBinding!(typeof(this))(); 612 return ptrcall!(Array)(GDNativeClassBinding.getChildren, _godot_object); 613 } 614 /** 615 616 */ 617 Ref!MultiplayerAPI getCustomMultiplayer() const 618 { 619 checkClassBinding!(typeof(this))(); 620 return ptrcall!(MultiplayerAPI)(GDNativeClassBinding.getCustomMultiplayer, _godot_object); 621 } 622 /** 623 624 */ 625 String getFilename() const 626 { 627 checkClassBinding!(typeof(this))(); 628 return ptrcall!(String)(GDNativeClassBinding.getFilename, _godot_object); 629 } 630 /** 631 Returns an array listing the groups that the node is a member of. 632 */ 633 Array getGroups() const 634 { 635 checkClassBinding!(typeof(this))(); 636 return ptrcall!(Array)(GDNativeClassBinding.getGroups, _godot_object); 637 } 638 /** 639 Returns the node's index, i.e. its position among the siblings of its parent. 640 */ 641 long getIndex() const 642 { 643 checkClassBinding!(typeof(this))(); 644 return ptrcall!(long)(GDNativeClassBinding.getIndex, _godot_object); 645 } 646 /** 647 648 */ 649 Ref!MultiplayerAPI getMultiplayer() const 650 { 651 checkClassBinding!(typeof(this))(); 652 return ptrcall!(MultiplayerAPI)(GDNativeClassBinding.getMultiplayer, _godot_object); 653 } 654 /** 655 656 */ 657 String getName() const 658 { 659 checkClassBinding!(typeof(this))(); 660 return ptrcall!(String)(GDNativeClassBinding.getName, _godot_object); 661 } 662 /** 663 Returns the peer ID of the network master for this node. See $(D setNetworkMaster). 664 */ 665 long getNetworkMaster() const 666 { 667 checkClassBinding!(typeof(this))(); 668 return ptrcall!(long)(GDNativeClassBinding.getNetworkMaster, _godot_object); 669 } 670 /** 671 Fetches a node. The $(D NodePath) can be either a relative path (from the current node) or an absolute path (in the scene tree) to a node. If the path does not exist, a `null instance` is returned and an error is logged. Attempts to access methods on the return value will result in an "Attempt to call <method> on a null instance." error. 672 $(B Note:) Fetching absolute paths only works when the node is inside the scene tree (see $(D isInsideTree)). 673 $(B Example:) Assume your current node is Character and the following tree: 674 675 676 /root 677 /root/Character 678 /root/Character/Sword 679 /root/Character/Backpack/Dagger 680 /root/MyGame 681 /root/Swamp/Alligator 682 /root/Swamp/Mosquito 683 /root/Swamp/Goblin 684 685 686 Possible paths are: 687 688 689 get_node("Sword") 690 get_node("Backpack/Dagger") 691 get_node("../Swamp/Alligator") 692 get_node("/root/MyGame") 693 694 695 */ 696 Node getNode(NodePathArg0)(in NodePathArg0 path) const 697 { 698 checkClassBinding!(typeof(this))(); 699 return ptrcall!(Node)(GDNativeClassBinding.getNode, _godot_object, path); 700 } 701 /** 702 Fetches a node and one of its resources as specified by the $(D NodePath)'s subname (e.g. `Area2D/CollisionShape2D:shape`). If several nested resources are specified in the $(D NodePath), the last one will be fetched. 703 The return value is an array of size 3: the first index points to the $(D Node) (or `null` if not found), the second index points to the $(D Resource) (or `null` if not found), and the third index is the remaining $(D NodePath), if any. 704 For example, assuming that `Area2D/CollisionShape2D` is a valid node and that its `shape` property has been assigned a $(D RectangleShape2D) resource, one could have this kind of output: 705 706 707 print(get_node_and_resource("Area2D/CollisionShape2D")) # $(D [CollisionShape2D:1161), Null, ] 708 print(get_node_and_resource("Area2D/CollisionShape2D:shape")) # $(D [CollisionShape2D:1161), $(D RectangleShape2D:1156), ] 709 print(get_node_and_resource("Area2D/CollisionShape2D:shape:extents")) # $(D [CollisionShape2D:1161), $(D RectangleShape2D:1156), :extents] 710 711 712 */ 713 Array getNodeAndResource(NodePathArg0)(in NodePathArg0 path) 714 { 715 checkClassBinding!(typeof(this))(); 716 return ptrcall!(Array)(GDNativeClassBinding.getNodeAndResource, _godot_object, path); 717 } 718 /** 719 Similar to $(D getNode), but does not log an error if `path` does not point to a valid $(D Node). 720 */ 721 Node getNodeOrNull(NodePathArg0)(in NodePathArg0 path) const 722 { 723 checkClassBinding!(typeof(this))(); 724 return ptrcall!(Node)(GDNativeClassBinding.getNodeOrNull, _godot_object, path); 725 } 726 /** 727 728 */ 729 Node getOwner() const 730 { 731 checkClassBinding!(typeof(this))(); 732 return ptrcall!(Node)(GDNativeClassBinding.getOwner, _godot_object); 733 } 734 /** 735 Returns the parent node of the current node, or a `null instance` if the node lacks a parent. 736 */ 737 Node getParent() const 738 { 739 checkClassBinding!(typeof(this))(); 740 return ptrcall!(Node)(GDNativeClassBinding.getParent, _godot_object); 741 } 742 /** 743 Returns the absolute path of the current node. This only works if the current node is inside the scene tree (see $(D isInsideTree)). 744 */ 745 NodePath getPath() const 746 { 747 checkClassBinding!(typeof(this))(); 748 return ptrcall!(NodePath)(GDNativeClassBinding.getPath, _godot_object); 749 } 750 /** 751 Returns the relative $(D NodePath) from this node to the specified `node`. Both nodes must be in the same scene or the function will fail. 752 */ 753 NodePath getPathTo(Node node) const 754 { 755 checkClassBinding!(typeof(this))(); 756 return ptrcall!(NodePath)(GDNativeClassBinding.getPathTo, _godot_object, node); 757 } 758 /** 759 760 */ 761 Node.PauseMode getPauseMode() const 762 { 763 checkClassBinding!(typeof(this))(); 764 return ptrcall!(Node.PauseMode)(GDNativeClassBinding.getPauseMode, _godot_object); 765 } 766 /** 767 Returns the time elapsed (in seconds) since the last physics-bound frame (see $(D _physicsProcess)). This is always a constant value in physics processing unless the frames per second is changed via $(D Engine.iterationsPerSecond). 768 */ 769 double getPhysicsProcessDeltaTime() const 770 { 771 checkClassBinding!(typeof(this))(); 772 return ptrcall!(double)(GDNativeClassBinding.getPhysicsProcessDeltaTime, _godot_object); 773 } 774 /** 775 Returns the node's order in the scene tree branch. For example, if called on the first child node the position is `0`. 776 */ 777 long getPositionInParent() const 778 { 779 checkClassBinding!(typeof(this))(); 780 return ptrcall!(long)(GDNativeClassBinding.getPositionInParent, _godot_object); 781 } 782 /** 783 Returns the time elapsed (in seconds) since the last process callback. This value may vary from frame to frame. 784 */ 785 double getProcessDeltaTime() const 786 { 787 checkClassBinding!(typeof(this))(); 788 return ptrcall!(double)(GDNativeClassBinding.getProcessDeltaTime, _godot_object); 789 } 790 /** 791 792 */ 793 long getProcessPriority() const 794 { 795 checkClassBinding!(typeof(this))(); 796 return ptrcall!(long)(GDNativeClassBinding.getProcessPriority, _godot_object); 797 } 798 /** 799 Returns `true` if this is an instance load placeholder. See $(D InstancePlaceholder). 800 */ 801 bool getSceneInstanceLoadPlaceholder() const 802 { 803 checkClassBinding!(typeof(this))(); 804 return ptrcall!(bool)(GDNativeClassBinding.getSceneInstanceLoadPlaceholder, _godot_object); 805 } 806 /** 807 Returns the $(D SceneTree) that contains this node. 808 */ 809 SceneTree getTree() const 810 { 811 checkClassBinding!(typeof(this))(); 812 return ptrcall!(SceneTree)(GDNativeClassBinding.getTree, _godot_object); 813 } 814 /** 815 Returns the node's $(D Viewport). 816 */ 817 Viewport getViewport() const 818 { 819 checkClassBinding!(typeof(this))(); 820 return ptrcall!(Viewport)(GDNativeClassBinding.getViewport, _godot_object); 821 } 822 /** 823 Returns `true` if the node that the $(D NodePath) points to exists. 824 */ 825 bool hasNode(NodePathArg0)(in NodePathArg0 path) const 826 { 827 checkClassBinding!(typeof(this))(); 828 return ptrcall!(bool)(GDNativeClassBinding.hasNode, _godot_object, path); 829 } 830 /** 831 Returns `true` if the $(D NodePath) points to a valid node and its subname points to a valid resource, e.g. `Area2D/CollisionShape2D:shape`. Properties with a non-$(D Resource) type (e.g. nodes or primitive math types) are not considered resources. 832 */ 833 bool hasNodeAndResource(NodePathArg0)(in NodePathArg0 path) const 834 { 835 checkClassBinding!(typeof(this))(); 836 return ptrcall!(bool)(GDNativeClassBinding.hasNodeAndResource, _godot_object, path); 837 } 838 /** 839 Returns `true` if the given node is a direct or indirect child of the current node. 840 */ 841 bool isAParentOf(Node node) const 842 { 843 checkClassBinding!(typeof(this))(); 844 return ptrcall!(bool)(GDNativeClassBinding.isAParentOf, _godot_object, node); 845 } 846 /** 847 Returns `true` if the node is folded (collapsed) in the Scene dock. 848 */ 849 bool isDisplayedFolded() const 850 { 851 checkClassBinding!(typeof(this))(); 852 return ptrcall!(bool)(GDNativeClassBinding.isDisplayedFolded, _godot_object); 853 } 854 /** 855 Returns `true` if the given node occurs later in the scene hierarchy than the current node. 856 */ 857 bool isGreaterThan(Node node) const 858 { 859 checkClassBinding!(typeof(this))(); 860 return ptrcall!(bool)(GDNativeClassBinding.isGreaterThan, _godot_object, node); 861 } 862 /** 863 Returns `true` if this node is in the specified group. See notes in the description, and the group methods in $(D SceneTree). 864 */ 865 bool isInGroup(in String group) const 866 { 867 checkClassBinding!(typeof(this))(); 868 return ptrcall!(bool)(GDNativeClassBinding.isInGroup, _godot_object, group); 869 } 870 /** 871 Returns `true` if this node is currently inside a $(D SceneTree). 872 */ 873 bool isInsideTree() const 874 { 875 checkClassBinding!(typeof(this))(); 876 return ptrcall!(bool)(GDNativeClassBinding.isInsideTree, _godot_object); 877 } 878 /** 879 Returns `true` if the local system is the master of this node. 880 */ 881 bool isNetworkMaster() const 882 { 883 checkClassBinding!(typeof(this))(); 884 return ptrcall!(bool)(GDNativeClassBinding.isNetworkMaster, _godot_object); 885 } 886 /** 887 Returns `true` if physics processing is enabled (see $(D setPhysicsProcess)). 888 */ 889 bool isPhysicsProcessing() const 890 { 891 checkClassBinding!(typeof(this))(); 892 return ptrcall!(bool)(GDNativeClassBinding.isPhysicsProcessing, _godot_object); 893 } 894 /** 895 Returns `true` if internal physics processing is enabled (see $(D setPhysicsProcessInternal)). 896 */ 897 bool isPhysicsProcessingInternal() const 898 { 899 checkClassBinding!(typeof(this))(); 900 return ptrcall!(bool)(GDNativeClassBinding.isPhysicsProcessingInternal, _godot_object); 901 } 902 /** 903 Returns `true` if processing is enabled (see $(D setProcess)). 904 */ 905 bool isProcessing() const 906 { 907 checkClassBinding!(typeof(this))(); 908 return ptrcall!(bool)(GDNativeClassBinding.isProcessing, _godot_object); 909 } 910 /** 911 Returns `true` if the node is processing input (see $(D setProcessInput)). 912 */ 913 bool isProcessingInput() const 914 { 915 checkClassBinding!(typeof(this))(); 916 return ptrcall!(bool)(GDNativeClassBinding.isProcessingInput, _godot_object); 917 } 918 /** 919 Returns `true` if internal processing is enabled (see $(D setProcessInternal)). 920 */ 921 bool isProcessingInternal() const 922 { 923 checkClassBinding!(typeof(this))(); 924 return ptrcall!(bool)(GDNativeClassBinding.isProcessingInternal, _godot_object); 925 } 926 /** 927 Returns `true` if the node is processing unhandled input (see $(D setProcessUnhandledInput)). 928 */ 929 bool isProcessingUnhandledInput() const 930 { 931 checkClassBinding!(typeof(this))(); 932 return ptrcall!(bool)(GDNativeClassBinding.isProcessingUnhandledInput, _godot_object); 933 } 934 /** 935 Returns `true` if the node is processing unhandled key input (see $(D setProcessUnhandledKeyInput)). 936 */ 937 bool isProcessingUnhandledKeyInput() const 938 { 939 checkClassBinding!(typeof(this))(); 940 return ptrcall!(bool)(GDNativeClassBinding.isProcessingUnhandledKeyInput, _godot_object); 941 } 942 /** 943 Moves a child node to a different position (order) among the other children. Since calls, signals, etc are performed by tree order, changing the order of children nodes may be useful. 944 */ 945 void moveChild(Node child_node, in long to_position) 946 { 947 checkClassBinding!(typeof(this))(); 948 ptrcall!(void)(GDNativeClassBinding.moveChild, _godot_object, child_node, to_position); 949 } 950 /** 951 Prints all stray nodes (nodes outside the $(D SceneTree)). Used for debugging. Works only in debug builds. 952 */ 953 void printStrayNodes() 954 { 955 checkClassBinding!(typeof(this))(); 956 ptrcall!(void)(GDNativeClassBinding.printStrayNodes, _godot_object); 957 } 958 /** 959 Prints the tree to stdout. Used mainly for debugging purposes. This version displays the path relative to the current node, and is good for copy/pasting into the $(D getNode) function. 960 $(B Example output:) 961 962 963 TheGame 964 TheGame/Menu 965 TheGame/Menu/Label 966 TheGame/Menu/Camera2D 967 TheGame/SplashScreen 968 TheGame/SplashScreen/Camera2D 969 970 971 */ 972 void printTree() 973 { 974 checkClassBinding!(typeof(this))(); 975 ptrcall!(void)(GDNativeClassBinding.printTree, _godot_object); 976 } 977 /** 978 Similar to $(D printTree), this prints the tree to stdout. This version displays a more graphical representation similar to what is displayed in the scene inspector. It is useful for inspecting larger trees. 979 $(B Example output:) 980 981 982 ┖╴TheGame 983 ┠╴Menu 984 ┃ ┠╴Label 985 ┃ ┖╴Camera2D 986 ┖╴SplashScreen 987 ┖╴Camera2D 988 989 990 */ 991 void printTreePretty() 992 { 993 checkClassBinding!(typeof(this))(); 994 ptrcall!(void)(GDNativeClassBinding.printTreePretty, _godot_object); 995 } 996 /** 997 Calls the given method (if present) with the arguments given in `args` on this node and recursively on all its children. If the `parent_first` argument is `true`, the method will be called on the current node first, then on all its children. If `parent_first` is `false`, the children will be called first. 998 */ 999 void propagateCall(in String method, in Array args = Array.make(), in bool parent_first = false) 1000 { 1001 checkClassBinding!(typeof(this))(); 1002 ptrcall!(void)(GDNativeClassBinding.propagateCall, _godot_object, method, args, parent_first); 1003 } 1004 /** 1005 Notifies the current node and all its children recursively by calling $(D GodotObject.notification) on all of them. 1006 */ 1007 void propagateNotification(in long what) 1008 { 1009 checkClassBinding!(typeof(this))(); 1010 ptrcall!(void)(GDNativeClassBinding.propagateNotification, _godot_object, what); 1011 } 1012 /** 1013 Queues a node for deletion at the end of the current frame. When deleted, all of its child nodes will be deleted as well. This method ensures it's safe to delete the node, contrary to $(D GodotObject.free). Use $(D GodotObject.isQueuedForDeletion) to check whether a node will be deleted at the end of the frame. 1014 $(B Important:) If you have a variable pointing to a node, it will $(I not) be assigned to `null` once the node is freed. Instead, it will point to a $(I previously freed instance) and you should validate it with $(D @GDScript.isInstanceValid) before attempting to call its methods or access its properties. 1015 */ 1016 void queueFree() 1017 { 1018 checkClassBinding!(typeof(this))(); 1019 ptrcall!(void)(GDNativeClassBinding.queueFree, _godot_object); 1020 } 1021 /** 1022 Moves this node to the bottom of parent node's children hierarchy. This is often useful in GUIs ($(D Control) nodes), because their order of drawing depends on their order in the tree. The top Node is drawn first, then any siblings below the top Node in the hierarchy are successively drawn on top of it. After using `raise`, a Control will be drawn on top of its siblings. 1023 */ 1024 void raise() 1025 { 1026 checkClassBinding!(typeof(this))(); 1027 ptrcall!(void)(GDNativeClassBinding.raise, _godot_object); 1028 } 1029 /** 1030 Removes a node and sets all its children as children of the parent node (if it exists). All event subscriptions that pass by the removed node will be unsubscribed. 1031 */ 1032 void removeAndSkip() 1033 { 1034 checkClassBinding!(typeof(this))(); 1035 ptrcall!(void)(GDNativeClassBinding.removeAndSkip, _godot_object); 1036 } 1037 /** 1038 Removes a child node. The node is NOT deleted and must be deleted manually. 1039 */ 1040 void removeChild(Node node) 1041 { 1042 checkClassBinding!(typeof(this))(); 1043 ptrcall!(void)(GDNativeClassBinding.removeChild, _godot_object, node); 1044 } 1045 /** 1046 Removes a node from a group. See notes in the description, and the group methods in $(D SceneTree). 1047 */ 1048 void removeFromGroup(in String group) 1049 { 1050 checkClassBinding!(typeof(this))(); 1051 ptrcall!(void)(GDNativeClassBinding.removeFromGroup, _godot_object, group); 1052 } 1053 /** 1054 Replaces a node in a scene by the given one. Subscriptions that pass through this node will be lost. 1055 */ 1056 void replaceBy(Node node, in bool keep_data = false) 1057 { 1058 checkClassBinding!(typeof(this))(); 1059 ptrcall!(void)(GDNativeClassBinding.replaceBy, _godot_object, node, keep_data); 1060 } 1061 /** 1062 Requests that `_ready` be called again. Note that the method won't be called immediately, but is scheduled for when the node is added to the scene tree again (see $(D _ready)). `_ready` is called only for the node which requested it, which means that you need to request ready for each child if you want them to call `_ready` too (in which case, `_ready` will be called in the same order as it would normally). 1063 */ 1064 void requestReady() 1065 { 1066 checkClassBinding!(typeof(this))(); 1067 ptrcall!(void)(GDNativeClassBinding.requestReady, _godot_object); 1068 } 1069 /** 1070 Sends a remote procedure call request for the given `method` to peers on the network (and locally), optionally sending all additional arguments as arguments to the method called by the RPC. The call request will only be received by nodes with the same $(D NodePath), including the exact same node name. Behaviour depends on the RPC configuration for the given method, see $(D rpcConfig). Methods are not exposed to RPCs by default. See also $(D rset) and $(D rsetConfig) for properties. Returns an empty $(D Variant). 1071 $(B Note:) You can only safely use RPCs on clients after you received the `connected_to_server` signal from the $(D SceneTree). You also need to keep track of the connection state, either by the $(D SceneTree) signals like `server_disconnected` or by checking `SceneTree.network_peer.get_connection_status() == CONNECTION_CONNECTED`. 1072 */ 1073 Variant rpc(VarArgs...)(in String method, VarArgs varArgs) 1074 { 1075 Array _GODOT_args = Array.make(); 1076 _GODOT_args.append(method); 1077 foreach(vai, VA; VarArgs) 1078 { 1079 _GODOT_args.append(varArgs[vai]); 1080 } 1081 String _GODOT_method_name = String("rpc"); 1082 return this.callv(_GODOT_method_name, _GODOT_args); 1083 } 1084 /** 1085 Changes the RPC mode for the given `method` to the given `mode`. See $(D MultiplayerAPI.rpcmode). An alternative is annotating methods and properties with the corresponding keywords (`remote`, `master`, `puppet`, `remotesync`, `mastersync`, `puppetsync`). By default, methods are not exposed to networking (and RPCs). See also $(D rset) and $(D rsetConfig) for properties. 1086 */ 1087 void rpcConfig(in String method, in long mode) 1088 { 1089 checkClassBinding!(typeof(this))(); 1090 ptrcall!(void)(GDNativeClassBinding.rpcConfig, _godot_object, method, mode); 1091 } 1092 /** 1093 Sends a $(D rpc) to a specific peer identified by `peer_id` (see $(D NetworkedMultiplayerPeer.setTargetPeer)). Returns an empty $(D Variant). 1094 */ 1095 Variant rpcId(VarArgs...)(in long peer_id, in String method, VarArgs varArgs) 1096 { 1097 Array _GODOT_args = Array.make(); 1098 _GODOT_args.append(peer_id); 1099 _GODOT_args.append(method); 1100 foreach(vai, VA; VarArgs) 1101 { 1102 _GODOT_args.append(varArgs[vai]); 1103 } 1104 String _GODOT_method_name = String("rpc_id"); 1105 return this.callv(_GODOT_method_name, _GODOT_args); 1106 } 1107 /** 1108 Sends a $(D rpc) using an unreliable protocol. Returns an empty $(D Variant). 1109 */ 1110 Variant rpcUnreliable(VarArgs...)(in String method, VarArgs varArgs) 1111 { 1112 Array _GODOT_args = Array.make(); 1113 _GODOT_args.append(method); 1114 foreach(vai, VA; VarArgs) 1115 { 1116 _GODOT_args.append(varArgs[vai]); 1117 } 1118 String _GODOT_method_name = String("rpc_unreliable"); 1119 return this.callv(_GODOT_method_name, _GODOT_args); 1120 } 1121 /** 1122 Sends a $(D rpc) to a specific peer identified by `peer_id` using an unreliable protocol (see $(D NetworkedMultiplayerPeer.setTargetPeer)). Returns an empty $(D Variant). 1123 */ 1124 Variant rpcUnreliableId(VarArgs...)(in long peer_id, in String method, VarArgs varArgs) 1125 { 1126 Array _GODOT_args = Array.make(); 1127 _GODOT_args.append(peer_id); 1128 _GODOT_args.append(method); 1129 foreach(vai, VA; VarArgs) 1130 { 1131 _GODOT_args.append(varArgs[vai]); 1132 } 1133 String _GODOT_method_name = String("rpc_unreliable_id"); 1134 return this.callv(_GODOT_method_name, _GODOT_args); 1135 } 1136 /** 1137 Remotely changes a property's value on other peers (and locally). Behaviour depends on the RPC configuration for the given property, see $(D rsetConfig). See also $(D rpc) for RPCs for methods, most information applies to this method as well. 1138 */ 1139 void rset(VariantArg1)(in String property, in VariantArg1 value) 1140 { 1141 checkClassBinding!(typeof(this))(); 1142 ptrcall!(void)(GDNativeClassBinding.rset, _godot_object, property, value); 1143 } 1144 /** 1145 Changes the RPC mode for the given `property` to the given `mode`. See $(D MultiplayerAPI.rpcmode). An alternative is annotating methods and properties with the corresponding keywords (`remote`, `master`, `puppet`, `remotesync`, `mastersync`, `puppetsync`). By default, properties are not exposed to networking (and RPCs). See also $(D rpc) and $(D rpcConfig) for methods. 1146 */ 1147 void rsetConfig(in String property, in long mode) 1148 { 1149 checkClassBinding!(typeof(this))(); 1150 ptrcall!(void)(GDNativeClassBinding.rsetConfig, _godot_object, property, mode); 1151 } 1152 /** 1153 Remotely changes the property's value on a specific peer identified by `peer_id` (see $(D NetworkedMultiplayerPeer.setTargetPeer)). 1154 */ 1155 void rsetId(VariantArg2)(in long peer_id, in String property, in VariantArg2 value) 1156 { 1157 checkClassBinding!(typeof(this))(); 1158 ptrcall!(void)(GDNativeClassBinding.rsetId, _godot_object, peer_id, property, value); 1159 } 1160 /** 1161 Remotely changes the property's value on other peers (and locally) using an unreliable protocol. 1162 */ 1163 void rsetUnreliable(VariantArg1)(in String property, in VariantArg1 value) 1164 { 1165 checkClassBinding!(typeof(this))(); 1166 ptrcall!(void)(GDNativeClassBinding.rsetUnreliable, _godot_object, property, value); 1167 } 1168 /** 1169 Remotely changes property's value on a specific peer identified by `peer_id` using an unreliable protocol (see $(D NetworkedMultiplayerPeer.setTargetPeer)). 1170 */ 1171 void rsetUnreliableId(VariantArg2)(in long peer_id, in String property, in VariantArg2 value) 1172 { 1173 checkClassBinding!(typeof(this))(); 1174 ptrcall!(void)(GDNativeClassBinding.rsetUnreliableId, _godot_object, peer_id, property, value); 1175 } 1176 /** 1177 1178 */ 1179 void setCustomMultiplayer(MultiplayerAPI api) 1180 { 1181 checkClassBinding!(typeof(this))(); 1182 ptrcall!(void)(GDNativeClassBinding.setCustomMultiplayer, _godot_object, api); 1183 } 1184 /** 1185 Sets the folded state of the node in the Scene dock. 1186 */ 1187 void setDisplayFolded(in bool fold) 1188 { 1189 checkClassBinding!(typeof(this))(); 1190 ptrcall!(void)(GDNativeClassBinding.setDisplayFolded, _godot_object, fold); 1191 } 1192 /** 1193 1194 */ 1195 void setFilename(in String filename) 1196 { 1197 checkClassBinding!(typeof(this))(); 1198 ptrcall!(void)(GDNativeClassBinding.setFilename, _godot_object, filename); 1199 } 1200 /** 1201 1202 */ 1203 void setName(in String name) 1204 { 1205 checkClassBinding!(typeof(this))(); 1206 ptrcall!(void)(GDNativeClassBinding.setName, _godot_object, name); 1207 } 1208 /** 1209 Sets the node's network master to the peer with the given peer ID. The network master is the peer that has authority over the node on the network. Useful in conjunction with the `master` and `puppet` keywords. Inherited from the parent node by default, which ultimately defaults to peer ID 1 (the server). If `recursive`, the given peer is recursively set as the master for all children of this node. 1210 */ 1211 void setNetworkMaster(in long id, in bool recursive = true) 1212 { 1213 checkClassBinding!(typeof(this))(); 1214 ptrcall!(void)(GDNativeClassBinding.setNetworkMaster, _godot_object, id, recursive); 1215 } 1216 /** 1217 1218 */ 1219 void setOwner(Node owner) 1220 { 1221 checkClassBinding!(typeof(this))(); 1222 ptrcall!(void)(GDNativeClassBinding.setOwner, _godot_object, owner); 1223 } 1224 /** 1225 1226 */ 1227 void setPauseMode(in long mode) 1228 { 1229 checkClassBinding!(typeof(this))(); 1230 ptrcall!(void)(GDNativeClassBinding.setPauseMode, _godot_object, mode); 1231 } 1232 /** 1233 Enables or disables physics (i.e. fixed framerate) processing. When a node is being processed, it will receive a $(D constant NOTIFICATION_PHYSICS_PROCESS) at a fixed (usually 60 FPS, see $(D Engine.iterationsPerSecond) to change) interval (and the $(D _physicsProcess) callback will be called if exists). Enabled automatically if $(D _physicsProcess) is overridden. Any calls to this before $(D _ready) will be ignored. 1234 */ 1235 void setPhysicsProcess(in bool enable) 1236 { 1237 checkClassBinding!(typeof(this))(); 1238 ptrcall!(void)(GDNativeClassBinding.setPhysicsProcess, _godot_object, enable); 1239 } 1240 /** 1241 Enables or disables internal physics for this node. Internal physics processing happens in isolation from the normal $(D _physicsProcess) calls and is used by some nodes internally to guarantee proper functioning even if the node is paused or physics processing is disabled for scripting ($(D setPhysicsProcess)). Only useful for advanced uses to manipulate built-in nodes' behavior. 1242 $(B Warning:) Built-in Nodes rely on the internal processing for their own logic, so changing this value from your code may lead to unexpected behavior. Script access to this internal logic is provided for specific advanced uses, but is unsafe and not supported. 1243 */ 1244 void setPhysicsProcessInternal(in bool enable) 1245 { 1246 checkClassBinding!(typeof(this))(); 1247 ptrcall!(void)(GDNativeClassBinding.setPhysicsProcessInternal, _godot_object, enable); 1248 } 1249 /** 1250 Enables or disables processing. When a node is being processed, it will receive a $(D constant NOTIFICATION_PROCESS) on every drawn frame (and the $(D _process) callback will be called if exists). Enabled automatically if $(D _process) is overridden. Any calls to this before $(D _ready) will be ignored. 1251 */ 1252 void setProcess(in bool enable) 1253 { 1254 checkClassBinding!(typeof(this))(); 1255 ptrcall!(void)(GDNativeClassBinding.setProcess, _godot_object, enable); 1256 } 1257 /** 1258 Enables or disables input processing. This is not required for GUI controls! Enabled automatically if $(D _input) is overridden. Any calls to this before $(D _ready) will be ignored. 1259 */ 1260 void setProcessInput(in bool enable) 1261 { 1262 checkClassBinding!(typeof(this))(); 1263 ptrcall!(void)(GDNativeClassBinding.setProcessInput, _godot_object, enable); 1264 } 1265 /** 1266 Enables or disabled internal processing for this node. Internal processing happens in isolation from the normal $(D _process) calls and is used by some nodes internally to guarantee proper functioning even if the node is paused or processing is disabled for scripting ($(D setProcess)). Only useful for advanced uses to manipulate built-in nodes' behavior. 1267 $(B Warning:) Built-in Nodes rely on the internal processing for their own logic, so changing this value from your code may lead to unexpected behavior. Script access to this internal logic is provided for specific advanced uses, but is unsafe and not supported. 1268 */ 1269 void setProcessInternal(in bool enable) 1270 { 1271 checkClassBinding!(typeof(this))(); 1272 ptrcall!(void)(GDNativeClassBinding.setProcessInternal, _godot_object, enable); 1273 } 1274 /** 1275 1276 */ 1277 void setProcessPriority(in long priority) 1278 { 1279 checkClassBinding!(typeof(this))(); 1280 ptrcall!(void)(GDNativeClassBinding.setProcessPriority, _godot_object, priority); 1281 } 1282 /** 1283 Enables unhandled input processing. This is not required for GUI controls! It enables the node to receive all input that was not previously handled (usually by a $(D Control)). Enabled automatically if $(D _unhandledInput) is overridden. Any calls to this before $(D _ready) will be ignored. 1284 */ 1285 void setProcessUnhandledInput(in bool enable) 1286 { 1287 checkClassBinding!(typeof(this))(); 1288 ptrcall!(void)(GDNativeClassBinding.setProcessUnhandledInput, _godot_object, enable); 1289 } 1290 /** 1291 Enables unhandled key input processing. Enabled automatically if $(D _unhandledKeyInput) is overridden. Any calls to this before $(D _ready) will be ignored. 1292 */ 1293 void setProcessUnhandledKeyInput(in bool enable) 1294 { 1295 checkClassBinding!(typeof(this))(); 1296 ptrcall!(void)(GDNativeClassBinding.setProcessUnhandledKeyInput, _godot_object, enable); 1297 } 1298 /** 1299 Sets whether this is an instance load placeholder. See $(D InstancePlaceholder). 1300 */ 1301 void setSceneInstanceLoadPlaceholder(in bool load_placeholder) 1302 { 1303 checkClassBinding!(typeof(this))(); 1304 ptrcall!(void)(GDNativeClassBinding.setSceneInstanceLoadPlaceholder, _godot_object, load_placeholder); 1305 } 1306 /** 1307 Updates the warning displayed for this node in the Scene Dock. 1308 Use $(D _getConfigurationWarning) to setup the warning message to display. 1309 */ 1310 void updateConfigurationWarning() 1311 { 1312 checkClassBinding!(typeof(this))(); 1313 ptrcall!(void)(GDNativeClassBinding.updateConfigurationWarning, _godot_object); 1314 } 1315 /** 1316 1317 */ 1318 @property NodePath _importPath() 1319 { 1320 return _getImportPath(); 1321 } 1322 /// ditto 1323 @property void _importPath(NodePath v) 1324 { 1325 _setImportPath(v); 1326 } 1327 /** 1328 The override to the default $(D MultiplayerAPI). Set to `null` to use the default $(D SceneTree) one. 1329 */ 1330 @property MultiplayerAPI customMultiplayer() 1331 { 1332 return getCustomMultiplayer(); 1333 } 1334 /// ditto 1335 @property void customMultiplayer(MultiplayerAPI v) 1336 { 1337 setCustomMultiplayer(v); 1338 } 1339 /** 1340 1341 */ 1342 @property String editorDescription() 1343 { 1344 return _getEditorDescription(); 1345 } 1346 /// ditto 1347 @property void editorDescription(String v) 1348 { 1349 _setEditorDescription(v); 1350 } 1351 /** 1352 When a scene is instanced from a file, its topmost node contains the filename from which it was loaded. 1353 */ 1354 @property String filename() 1355 { 1356 return getFilename(); 1357 } 1358 /// ditto 1359 @property void filename(String v) 1360 { 1361 setFilename(v); 1362 } 1363 /** 1364 The $(D MultiplayerAPI) instance associated with this node. Either the $(D customMultiplayer), or the default SceneTree one (if inside tree). 1365 */ 1366 @property MultiplayerAPI multiplayer() 1367 { 1368 return getMultiplayer(); 1369 } 1370 /** 1371 The name of the node. This name is unique among the siblings (other child nodes from the same parent). When set to an existing name, the node will be automatically renamed. 1372 $(B Note:) Auto-generated names might include the `@` character, which is reserved for unique names when using $(D addChild). When setting the name manually, any `@` will be removed. 1373 */ 1374 @property String name() 1375 { 1376 return getName(); 1377 } 1378 /// ditto 1379 @property void name(String v) 1380 { 1381 setName(v); 1382 } 1383 /** 1384 The node owner. A node can have any other node as owner (as long as it is a valid parent, grandparent, etc. ascending in the tree). When saving a node (using $(D PackedScene)), all the nodes it owns will be saved with it. This allows for the creation of complex $(D SceneTree)s, with instancing and subinstancing. 1385 */ 1386 @property Node owner() 1387 { 1388 return getOwner(); 1389 } 1390 /// ditto 1391 @property void owner(Node v) 1392 { 1393 setOwner(v); 1394 } 1395 /** 1396 Pause mode. How the node will behave if the $(D SceneTree) is paused. 1397 */ 1398 @property Node.PauseMode pauseMode() 1399 { 1400 return getPauseMode(); 1401 } 1402 /// ditto 1403 @property void pauseMode(long v) 1404 { 1405 setPauseMode(v); 1406 } 1407 /** 1408 The node's priority in the execution order of the enabled processing callbacks (i.e. $(D constant NOTIFICATION_PROCESS), $(D constant NOTIFICATION_PHYSICS_PROCESS) and their internal counterparts). Nodes whose process priority value is $(I lower) will have their processing callbacks executed first. 1409 */ 1410 @property long processPriority() 1411 { 1412 return getProcessPriority(); 1413 } 1414 /// ditto 1415 @property void processPriority(long v) 1416 { 1417 setProcessPriority(v); 1418 } 1419 }