1 /** 2 Base class for all non-built-in types. 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.object; 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.classdb; 23 import godot.reference; 24 /** 25 Base class for all non-built-in types. 26 27 Every class which is not a built-in type inherits from this class. 28 You can construct Objects from scripting languages, using `Object.new()` in GDScript, `new Object` in C#, or the "Construct Object" node in VisualScript. 29 Objects do not manage memory. If a class inherits from Object, you will have to delete instances of it manually. To do so, call the $(D free) method from your script or delete the instance from C++. 30 Some classes that extend Object add memory management. This is the case of $(D Reference), which counts references and deletes itself automatically when no longer referenced. $(D Node), another fundamental type, deletes all its children when freed from memory. 31 Objects export properties, which are mainly useful for storage and editing, but not really so much in programming. Properties are exported in $(D _getPropertyList) and handled in $(D _get) and $(D _set). However, scripting languages and C++ have simpler means to export them. 32 Property membership can be tested directly in GDScript using `in`: 33 34 35 var n = Node2D.new() 36 print("position" in n) # Prints "True". 37 print("other_property" in n) # Prints "False". 38 39 40 The `in` operator will evaluate to `true` as long as the key exists, even if the value is `null`. 41 Objects also receive notifications. Notifications are a simple way to notify the object about different events, so they can all be handled together. See $(D _notification). 42 $(B Note:) Unlike references to a $(D Reference), references to an Object stored in a variable can become invalid without warning. Therefore, it's recommended to use $(D Reference) for data classes instead of $(D GodotObject). 43 $(B Note:) Due to a bug, you can't create a "plain" Object using `Object.new()`. Instead, use `ClassDB.instance("Object")`. This bug only applies to Object itself, not any of its descendents like $(D Reference). 44 */ 45 @GodotBaseClass struct GodotObject 46 { 47 package(godot) enum string _GODOT_internal_name = "Object"; 48 public: 49 @nogc nothrow: 50 godot_object _godot_object; 51 alias BaseClasses = AliasSeq!(); 52 package(godot) __gshared bool _classBindingInitialized = false; 53 package(godot) static struct GDNativeClassBinding 54 { 55 __gshared: 56 @GodotName("_get") GodotMethod!(Variant, String) _get; 57 @GodotName("_get_property_list") GodotMethod!(Array) _getPropertyList; 58 @GodotName("_init") GodotMethod!(void) _init; 59 @GodotName("_notification") GodotMethod!(void, long) _notification; 60 @GodotName("_set") GodotMethod!(bool, String, Variant) _set; 61 @GodotName("_to_string") GodotMethod!(String) _toString; 62 @GodotName("add_user_signal") GodotMethod!(void, String, Array) addUserSignal; 63 @GodotName("call") GodotMethod!(Variant, String, GodotVarArgs) call; 64 @GodotName("call_deferred") GodotMethod!(void, String, GodotVarArgs) callDeferred; 65 @GodotName("callv") GodotMethod!(Variant, String, Array) callv; 66 @GodotName("can_translate_messages") GodotMethod!(bool) canTranslateMessages; 67 @GodotName("connect") GodotMethod!(GodotError, String, GodotObject, String, Array, long) connect; 68 @GodotName("disconnect") GodotMethod!(void, String, GodotObject, String) disconnect; 69 @GodotName("emit_signal") GodotMethod!(void, String, GodotVarArgs) emitSignal; 70 @GodotName("free") GodotMethod!(void) free; 71 @GodotName("get") GodotMethod!(Variant, String) get; 72 @GodotName("get_class") GodotMethod!(String) getClass; 73 @GodotName("get_incoming_connections") GodotMethod!(Array) getIncomingConnections; 74 @GodotName("get_indexed") GodotMethod!(Variant, NodePath) getIndexed; 75 @GodotName("get_instance_id") GodotMethod!(long) getInstanceId; 76 @GodotName("get_meta") GodotMethod!(Variant, String) getMeta; 77 @GodotName("get_meta_list") GodotMethod!(PoolStringArray) getMetaList; 78 @GodotName("get_method_list") GodotMethod!(Array) getMethodList; 79 @GodotName("get_property_list") GodotMethod!(Array) getPropertyList; 80 @GodotName("get_script") GodotMethod!(Reference) getScript; 81 @GodotName("get_signal_connection_list") GodotMethod!(Array, String) getSignalConnectionList; 82 @GodotName("get_signal_list") GodotMethod!(Array) getSignalList; 83 @GodotName("has_meta") GodotMethod!(bool, String) hasMeta; 84 @GodotName("has_method") GodotMethod!(bool, String) hasMethod; 85 @GodotName("has_signal") GodotMethod!(bool, String) hasSignal; 86 @GodotName("has_user_signal") GodotMethod!(bool, String) hasUserSignal; 87 @GodotName("is_blocking_signals") GodotMethod!(bool) isBlockingSignals; 88 @GodotName("is_class") GodotMethod!(bool, String) isClass; 89 @GodotName("is_connected") GodotMethod!(bool, String, GodotObject, String) isConnected; 90 @GodotName("is_queued_for_deletion") GodotMethod!(bool) isQueuedForDeletion; 91 @GodotName("notification") GodotMethod!(void, long, bool) notification; 92 @GodotName("property_list_changed_notify") GodotMethod!(void) propertyListChangedNotify; 93 @GodotName("remove_meta") GodotMethod!(void, String) removeMeta; 94 @GodotName("set") GodotMethod!(void, String, Variant) set; 95 @GodotName("set_block_signals") GodotMethod!(void, bool) setBlockSignals; 96 @GodotName("set_deferred") GodotMethod!(void, String, Variant) setDeferred; 97 @GodotName("set_indexed") GodotMethod!(void, NodePath, Variant) setIndexed; 98 @GodotName("set_message_translation") GodotMethod!(void, bool) setMessageTranslation; 99 @GodotName("set_meta") GodotMethod!(void, String, Variant) setMeta; 100 @GodotName("set_script") GodotMethod!(void, Reference) setScript; 101 @GodotName("to_string") GodotMethod!(String) toString; 102 @GodotName("tr") GodotMethod!(String, String) tr; 103 } 104 /// 105 pragma(inline, true) bool opEquals(in GodotObject other) const 106 { return _godot_object.ptr is other._godot_object.ptr; } 107 /// 108 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 109 { _godot_object.ptr = n; return null; } 110 /// 111 pragma(inline, true) bool opEquals(typeof(null) n) const 112 { return _godot_object.ptr is n; } 113 /// 114 pragma(inline, true) int opCmp(in GodotObject other) const 115 { const void* a = _godot_object.ptr, b = other._godot_object.ptr; return a is b ? 0 : a < b ? -1 : 1; } 116 /// 117 pragma(inline, true) int opCmp(T)(in T other) const if(extendsGodotBaseClass!T) 118 { const void* a = _godot_object.ptr, b = other.owner._godot_object.ptr; return a is b ? 0 : a < b ? -1 : 1; } 119 /// 120 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 121 mixin baseCasts; 122 /// Construct a new instance of GodotObject. 123 /// Note: use `memnew!GodotObject` instead. 124 static GodotObject _new() 125 { 126 static godot_class_constructor constructor; 127 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Object"); 128 if(constructor is null) return typeof(this).init; 129 return cast(GodotObject)(constructor()); 130 } 131 @disable new(size_t s); 132 /// 133 enum ConnectFlags : int 134 { 135 /** 136 Connects a signal in deferred mode. This way, signal emissions are stored in a queue, then set on idle time. 137 */ 138 connectDeferred = 1, 139 /** 140 Persisting connections are saved when the object is serialized to file. 141 */ 142 connectPersist = 2, 143 /** 144 One-shot connections disconnect themselves after emission. 145 */ 146 connectOneshot = 4, 147 /** 148 Connect a signal as reference-counted. This means that a given signal can be connected several times to the same target, and will only be fully disconnected once no references are left. 149 */ 150 connectReferenceCounted = 8, 151 } 152 /// 153 enum Constants : int 154 { 155 /** 156 Called right when the object is initialized. Not available in script. 157 */ 158 notificationPostinitialize = 0, 159 /** 160 Called before the object is about to be deleted. 161 */ 162 notificationPredelete = 1, 163 connectDeferred = 1, 164 connectPersist = 2, 165 connectOneshot = 4, 166 connectReferenceCounted = 8, 167 } 168 /** 169 Virtual method which can be overridden to customize the return value of $(D get). 170 Returns the given property. Returns `null` if the `property` does not exist. 171 */ 172 Variant _get(in String property) 173 { 174 Array _GODOT_args = Array.make(); 175 _GODOT_args.append(property); 176 String _GODOT_method_name = String("_get"); 177 return this.callv(_GODOT_method_name, _GODOT_args); 178 } 179 /** 180 Virtual method which can be overridden to customize the return value of $(D getPropertyList). 181 Returns the object's property list as an $(D Array) of dictionaries. 182 Each property's $(D Dictionary) must contain at least `name: String` and `type: int` (see $(D Variant.type)) entries. Optionally, it can also include `hint: int` (see $(D propertyhint)), `hint_string: String`, and `usage: int` (see $(D propertyusageflags)). 183 */ 184 Array _getPropertyList() 185 { 186 Array _GODOT_args = Array.make(); 187 String _GODOT_method_name = String("_get_property_list"); 188 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Array); 189 } 190 /** 191 Called when the object is initialized. 192 */ 193 void _init() 194 { 195 Array _GODOT_args = Array.make(); 196 String _GODOT_method_name = String("_init"); 197 this.callv(_GODOT_method_name, _GODOT_args); 198 } 199 /** 200 Called whenever the object receives a notification, which is identified in `what` by a constant. The base $(D GodotObject) has two constants $(D constant NOTIFICATION_POSTINITIALIZE) and $(D constant NOTIFICATION_PREDELETE), but subclasses such as $(D Node) define a lot more notifications which are also received by this method. 201 */ 202 void _notification(in long what) 203 { 204 Array _GODOT_args = Array.make(); 205 _GODOT_args.append(what); 206 String _GODOT_method_name = String("_notification"); 207 this.callv(_GODOT_method_name, _GODOT_args); 208 } 209 /** 210 Virtual method which can be overridden to customize the return value of $(D set). 211 Sets a property. Returns `true` if the `property` exists. 212 */ 213 bool _set(VariantArg1)(in String property, in VariantArg1 value) 214 { 215 Array _GODOT_args = Array.make(); 216 _GODOT_args.append(property); 217 _GODOT_args.append(value); 218 String _GODOT_method_name = String("_set"); 219 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool); 220 } 221 /** 222 Virtual method which can be overridden to customize the return value of $(D toString), and thus the object's representation where it is converted to a string, e.g. with `print(obj)`. 223 Returns a $(D String) representing the object. If not overridden, defaults to `"$(D ClassName:RID)"`. 224 */ 225 String _toString() 226 { 227 Array _GODOT_args = Array.make(); 228 String _GODOT_method_name = String("_to_string"); 229 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String); 230 } 231 /** 232 Adds a user-defined `signal`. Arguments are optional, but can be added as an $(D Array) of dictionaries, each containing `name: String` and `type: int` (see $(D Variant.type)) entries. 233 */ 234 void addUserSignal(in String signal, in Array arguments = Array.make()) 235 { 236 checkClassBinding!(typeof(this))(); 237 ptrcall!(void)(GDNativeClassBinding.addUserSignal, _godot_object, signal, arguments); 238 } 239 /** 240 Calls the `method` on the object and returns the result. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example: 241 242 243 call("set", "position", Vector2(42.0, 0.0)) 244 245 246 $(B Note:) In C#, the method name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined methods where you should use the same convention as in the C# source (typically PascalCase). 247 */ 248 Variant call(VarArgs...)(in String method, VarArgs varArgs) 249 { 250 Array _GODOT_args = Array.make(); 251 _GODOT_args.append(method); 252 foreach(vai, VA; VarArgs) 253 { 254 _GODOT_args.append(varArgs[vai]); 255 } 256 String _GODOT_method_name = String("call"); 257 return this.callv(_GODOT_method_name, _GODOT_args); 258 } 259 /** 260 Calls the `method` on the object during idle time. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example: 261 262 263 call_deferred("set", "position", Vector2(42.0, 0.0)) 264 265 266 $(B Note:) In C#, the method name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined methods where you should use the same convention as in the C# source (typically PascalCase). 267 */ 268 void callDeferred(VarArgs...)(in String method, VarArgs varArgs) 269 { 270 Array _GODOT_args = Array.make(); 271 _GODOT_args.append(method); 272 foreach(vai, VA; VarArgs) 273 { 274 _GODOT_args.append(varArgs[vai]); 275 } 276 String _GODOT_method_name = String("call_deferred"); 277 this.callv(_GODOT_method_name, _GODOT_args); 278 } 279 /** 280 Calls the `method` on the object and returns the result. Contrarily to $(D call), this method does not support a variable number of arguments but expects all parameters to be via a single $(D Array). 281 282 283 callv("set", $(D "position", Vector2(42.0, 0.0) )) 284 285 286 */ 287 Variant callv(in String method, in Array arg_array) const 288 { 289 checkClassBinding!(typeof(this))(); 290 return ptrcall!(Variant)(GDNativeClassBinding.callv, _godot_object, method, arg_array); 291 } 292 /** 293 Returns `true` if the object can translate strings. See $(D setMessageTranslation) and $(D tr). 294 */ 295 bool canTranslateMessages() const 296 { 297 checkClassBinding!(typeof(this))(); 298 return ptrcall!(bool)(GDNativeClassBinding.canTranslateMessages, _godot_object); 299 } 300 /** 301 Connects a `signal` to a `method` on a `target` object. Pass optional `binds` to the call as an $(D Array) of parameters. These parameters will be passed to the method after any parameter used in the call to $(D emitSignal). Use `flags` to set deferred or one-shot connections. See $(D connectflags) constants. 302 A `signal` can only be connected once to a `method`. It will throw an error if already connected, unless the signal was connected with $(D constant CONNECT_REFERENCE_COUNTED). To avoid this, first, use $(D isConnected) to check for existing connections. 303 If the `target` is destroyed in the game's lifecycle, the connection will be lost. 304 Examples: 305 306 307 connect("pressed", self, "_on_Button_pressed") # BaseButton signal 308 connect("text_entered", self, "_on_LineEdit_text_entered") # LineEdit signal 309 connect("hit", self, "_on_Player_hit", $(D weapon_type, damage )) # User-defined signal 310 311 312 An example of the relationship between `binds` passed to $(D connect) and parameters used when calling $(D emitSignal): 313 314 315 connect("hit", self, "_on_Player_hit", $(D weapon_type, damage )) # weapon_type and damage are passed last 316 emit_signal("hit", "Dark lord", 5) # "Dark lord" and 5 are passed first 317 func _on_Player_hit(hit_by, level, weapon_type, damage): 318 print("Hit by %s (lvl %d) with weapon %s for %d damage" % $(D hit_by, level, weapon_type, damage)) 319 320 321 */ 322 GodotError connect(in String signal, GodotObject target, in String method, in Array binds = Array.make(), in long flags = 0) 323 { 324 checkClassBinding!(typeof(this))(); 325 return ptrcall!(GodotError)(GDNativeClassBinding.connect, _godot_object, signal, target, method, binds, flags); 326 } 327 /** 328 Disconnects a `signal` from a `method` on the given `target`. 329 If you try to disconnect a connection that does not exist, the method will throw an error. Use $(D isConnected) to ensure that the connection exists. 330 */ 331 void disconnect(in String signal, GodotObject target, in String method) 332 { 333 checkClassBinding!(typeof(this))(); 334 ptrcall!(void)(GDNativeClassBinding.disconnect, _godot_object, signal, target, method); 335 } 336 /** 337 Emits the given `signal`. The signal must exist, so it should be a built-in signal of this class or one of its parent classes, or a user-defined signal. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example: 338 339 340 emit_signal("hit", weapon_type, damage) 341 emit_signal("game_over") 342 343 344 */ 345 void emitSignal(VarArgs...)(in String signal, VarArgs varArgs) 346 { 347 Array _GODOT_args = Array.make(); 348 _GODOT_args.append(signal); 349 foreach(vai, VA; VarArgs) 350 { 351 _GODOT_args.append(varArgs[vai]); 352 } 353 String _GODOT_method_name = String("emit_signal"); 354 this.callv(_GODOT_method_name, _GODOT_args); 355 } 356 /** 357 Deletes the object from memory immediately. For $(D Node)s, you may want to use $(D Node.queueFree) to queue the node for safe deletion at the end of the current frame. 358 $(B Important:) If you have a variable pointing to an object, it will $(I not) be assigned to `null` once the object 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. 359 */ 360 void free() 361 { 362 checkClassBinding!(typeof(this))(); 363 ptrcall!(void)(GDNativeClassBinding.free, _godot_object); 364 } 365 /** 366 Returns the $(D Variant) value of the given `property`. If the `property` doesn't exist, this will return `null`. 367 $(B Note:) In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase). 368 */ 369 Variant get(in String property) const 370 { 371 checkClassBinding!(typeof(this))(); 372 return ptrcall!(Variant)(GDNativeClassBinding.get, _godot_object, property); 373 } 374 /** 375 Returns the object's class as a $(D String). 376 */ 377 String getClass() const 378 { 379 checkClassBinding!(typeof(this))(); 380 return ptrcall!(String)(GDNativeClassBinding.getClass, _godot_object); 381 } 382 /** 383 Returns an $(D Array) of dictionaries with information about signals that are connected to the object. 384 Each $(D Dictionary) contains three String entries: 385 - `source` is a reference to the signal emitter. 386 - `signal_name` is the name of the connected signal. 387 - `method_name` is the name of the method to which the signal is connected. 388 */ 389 Array getIncomingConnections() const 390 { 391 checkClassBinding!(typeof(this))(); 392 return ptrcall!(Array)(GDNativeClassBinding.getIncomingConnections, _godot_object); 393 } 394 /** 395 Gets the object's property indexed by the given $(D NodePath). The node path should be relative to the current object and can use the colon character (`:`) to access nested properties. Examples: `"position:x"` or `"material:next_pass:blend_mode"`. 396 */ 397 Variant getIndexed(NodePathArg0)(in NodePathArg0 property) const 398 { 399 checkClassBinding!(typeof(this))(); 400 return ptrcall!(Variant)(GDNativeClassBinding.getIndexed, _godot_object, property); 401 } 402 /** 403 Returns the object's unique instance ID. 404 This ID can be saved in $(D EncodedObjectAsID), and can be used to retrieve the object instance with $(D @GDScript.instanceFromId). 405 */ 406 long getInstanceId() const 407 { 408 checkClassBinding!(typeof(this))(); 409 return ptrcall!(long)(GDNativeClassBinding.getInstanceId, _godot_object); 410 } 411 /** 412 Returns the object's metadata entry for the given `name`. 413 */ 414 Variant getMeta(in String name) const 415 { 416 checkClassBinding!(typeof(this))(); 417 return ptrcall!(Variant)(GDNativeClassBinding.getMeta, _godot_object, name); 418 } 419 /** 420 Returns the object's metadata as a $(D PoolStringArray). 421 */ 422 PoolStringArray getMetaList() const 423 { 424 checkClassBinding!(typeof(this))(); 425 return ptrcall!(PoolStringArray)(GDNativeClassBinding.getMetaList, _godot_object); 426 } 427 /** 428 Returns the object's methods and their signatures as an $(D Array). 429 */ 430 Array getMethodList() const 431 { 432 checkClassBinding!(typeof(this))(); 433 return ptrcall!(Array)(GDNativeClassBinding.getMethodList, _godot_object); 434 } 435 /** 436 Returns the object's property list as an $(D Array) of dictionaries. 437 Each property's $(D Dictionary) contain at least `name: String` and `type: int` (see $(D Variant.type)) entries. Optionally, it can also include `hint: int` (see $(D propertyhint)), `hint_string: String`, and `usage: int` (see $(D propertyusageflags)). 438 */ 439 Array getPropertyList() const 440 { 441 checkClassBinding!(typeof(this))(); 442 return ptrcall!(Array)(GDNativeClassBinding.getPropertyList, _godot_object); 443 } 444 /** 445 Returns the object's $(D Script) instance, or `null` if none is assigned. 446 */ 447 Ref!Reference getScript() const 448 { 449 checkClassBinding!(typeof(this))(); 450 return ptrcall!(Reference)(GDNativeClassBinding.getScript, _godot_object); 451 } 452 /** 453 Returns an $(D Array) of connections for the given `signal`. 454 */ 455 Array getSignalConnectionList(in String signal) const 456 { 457 checkClassBinding!(typeof(this))(); 458 return ptrcall!(Array)(GDNativeClassBinding.getSignalConnectionList, _godot_object, signal); 459 } 460 /** 461 Returns the list of signals as an $(D Array) of dictionaries. 462 */ 463 Array getSignalList() const 464 { 465 checkClassBinding!(typeof(this))(); 466 return ptrcall!(Array)(GDNativeClassBinding.getSignalList, _godot_object); 467 } 468 /** 469 Returns `true` if a metadata entry is found with the given `name`. 470 */ 471 bool hasMeta(in String name) const 472 { 473 checkClassBinding!(typeof(this))(); 474 return ptrcall!(bool)(GDNativeClassBinding.hasMeta, _godot_object, name); 475 } 476 /** 477 Returns `true` if the object contains the given `method`. 478 */ 479 bool hasMethod(in String method) const 480 { 481 checkClassBinding!(typeof(this))(); 482 return ptrcall!(bool)(GDNativeClassBinding.hasMethod, _godot_object, method); 483 } 484 /** 485 Returns `true` if the given `signal` exists. 486 */ 487 bool hasSignal(in String signal) const 488 { 489 checkClassBinding!(typeof(this))(); 490 return ptrcall!(bool)(GDNativeClassBinding.hasSignal, _godot_object, signal); 491 } 492 /** 493 Returns `true` if the given user-defined `signal` exists. Only signals added using $(D addUserSignal) are taken into account. 494 */ 495 bool hasUserSignal(in String signal) const 496 { 497 checkClassBinding!(typeof(this))(); 498 return ptrcall!(bool)(GDNativeClassBinding.hasUserSignal, _godot_object, signal); 499 } 500 /** 501 Returns `true` if signal emission blocking is enabled. 502 */ 503 bool isBlockingSignals() const 504 { 505 checkClassBinding!(typeof(this))(); 506 return ptrcall!(bool)(GDNativeClassBinding.isBlockingSignals, _godot_object); 507 } 508 /** 509 Returns `true` if the object inherits from the given `class`. 510 */ 511 bool isClass(in String _class) const 512 { 513 checkClassBinding!(typeof(this))(); 514 return ptrcall!(bool)(GDNativeClassBinding.isClass, _godot_object, _class); 515 } 516 /** 517 Returns `true` if a connection exists for a given `signal`, `target`, and `method`. 518 */ 519 bool isConnected(in String signal, GodotObject target, in String method) const 520 { 521 checkClassBinding!(typeof(this))(); 522 return ptrcall!(bool)(GDNativeClassBinding.isConnected, _godot_object, signal, target, method); 523 } 524 /** 525 Returns `true` if the $(D Node.queueFree) method was called for the object. 526 */ 527 bool isQueuedForDeletion() const 528 { 529 checkClassBinding!(typeof(this))(); 530 return ptrcall!(bool)(GDNativeClassBinding.isQueuedForDeletion, _godot_object); 531 } 532 /** 533 Send a given notification to the object, which will also trigger a call to the $(D _notification) method of all classes that the object inherits from. 534 If `reversed` is `true`, $(D _notification) is called first on the object's own class, and then up to its successive parent classes. If `reversed` is `false`, $(D _notification) is called first on the highest ancestor ($(D GodotObject) itself), and then down to its successive inheriting classes. 535 */ 536 void notification(in long what, in bool reversed = false) 537 { 538 checkClassBinding!(typeof(this))(); 539 ptrcall!(void)(GDNativeClassBinding.notification, _godot_object, what, reversed); 540 } 541 /** 542 Notify the editor that the property list has changed, so that editor plugins can take the new values into account. Does nothing on export builds. 543 */ 544 void propertyListChangedNotify() 545 { 546 checkClassBinding!(typeof(this))(); 547 ptrcall!(void)(GDNativeClassBinding.propertyListChangedNotify, _godot_object); 548 } 549 /** 550 Removes a given entry from the object's metadata. See also $(D setMeta). 551 */ 552 void removeMeta(in String name) 553 { 554 checkClassBinding!(typeof(this))(); 555 ptrcall!(void)(GDNativeClassBinding.removeMeta, _godot_object, name); 556 } 557 /** 558 Assigns a new value to the given property. If the `property` does not exist, nothing will happen. 559 $(B Note:) In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase). 560 */ 561 void set(VariantArg1)(in String property, in VariantArg1 value) 562 { 563 checkClassBinding!(typeof(this))(); 564 ptrcall!(void)(GDNativeClassBinding.set, _godot_object, property, value); 565 } 566 /** 567 If set to `true`, signal emission is blocked. 568 */ 569 void setBlockSignals(in bool enable) 570 { 571 checkClassBinding!(typeof(this))(); 572 ptrcall!(void)(GDNativeClassBinding.setBlockSignals, _godot_object, enable); 573 } 574 /** 575 Assigns a new value to the given property, after the current frame's physics step. This is equivalent to calling $(D set) via $(D callDeferred), i.e. `call_deferred("set", property, value)`. 576 $(B Note:) In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase). 577 */ 578 void setDeferred(VariantArg1)(in String property, in VariantArg1 value) 579 { 580 checkClassBinding!(typeof(this))(); 581 ptrcall!(void)(GDNativeClassBinding.setDeferred, _godot_object, property, value); 582 } 583 /** 584 Assigns a new value to the property identified by the $(D NodePath). The node path should be relative to the current object and can use the colon character (`:`) to access nested properties. Example: 585 586 587 set_indexed("position", Vector2(42, 0)) 588 set_indexed("position:y", -10) 589 print(position) # (42, -10) 590 591 592 */ 593 void setIndexed(NodePathArg0, VariantArg1)(in NodePathArg0 property, in VariantArg1 value) 594 { 595 checkClassBinding!(typeof(this))(); 596 ptrcall!(void)(GDNativeClassBinding.setIndexed, _godot_object, property, value); 597 } 598 /** 599 Defines whether the object can translate strings (with calls to $(D tr)). Enabled by default. 600 */ 601 void setMessageTranslation(in bool enable) 602 { 603 checkClassBinding!(typeof(this))(); 604 ptrcall!(void)(GDNativeClassBinding.setMessageTranslation, _godot_object, enable); 605 } 606 /** 607 Adds, changes or removes a given entry in the object's metadata. Metadata are serialized and can take any $(D Variant) value. 608 To remove a given entry from the object's metadata, use $(D removeMeta). Metadata is also removed if its value is set to `null`. This means you can also use `set_meta("name", null)` to remove metadata for `"name"`. 609 */ 610 void setMeta(VariantArg1)(in String name, in VariantArg1 value) 611 { 612 checkClassBinding!(typeof(this))(); 613 ptrcall!(void)(GDNativeClassBinding.setMeta, _godot_object, name, value); 614 } 615 /** 616 Assigns a script to the object. Each object can have a single script assigned to it, which are used to extend its functionality. 617 If the object already had a script, the previous script instance will be freed and its variables and state will be lost. The new script's $(D _init) method will be called. 618 */ 619 void setScript(Reference script) 620 { 621 checkClassBinding!(typeof(this))(); 622 ptrcall!(void)(GDNativeClassBinding.setScript, _godot_object, script); 623 } 624 /** 625 Returns a $(D String) representing the object. If not overridden, defaults to `"$(D ClassName:RID)"`. 626 Override the method $(D _toString) to customize the $(D String) representation. 627 */ 628 String toString() 629 { 630 checkClassBinding!(typeof(this))(); 631 return ptrcall!(String)(GDNativeClassBinding.toString, _godot_object); 632 } 633 /** 634 Translates a message using translation catalogs configured in the Project Settings. 635 Only works if message translation is enabled (which it is by default), otherwise it returns the `message` unchanged. See $(D setMessageTranslation). 636 */ 637 String tr(in String message) const 638 { 639 checkClassBinding!(typeof(this))(); 640 return ptrcall!(String)(GDNativeClassBinding.tr, _godot_object, message); 641 } 642 }