mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-21 11:26:53 +01:00
404 lines
20 KiB
XML
404 lines
20 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<class name="Object" version="3.12">
|
|
<brief_description>
|
|
Base class for all non-built-in types.
|
|
</brief_description>
|
|
<description>
|
|
Every class which is not a built-in type inherits from this class.
|
|
You can construct Objects from scripting languages, using [code]Object.new()[/code] in GDScript, [code]new Object[/code] in C#, or the "Construct Object" node in VisualScript.
|
|
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 [method free] method from your script or delete the instance from C++.
|
|
Some classes that extend Object add memory management. This is the case of [Reference], which counts references and deletes itself automatically when no longer referenced. [Node], another fundamental type, deletes all its children when freed from memory.
|
|
Objects export properties, which are mainly useful for storage and editing, but not really so much in programming. Properties are exported in [method _get_property_list] and handled in [method _get] and [method _set]. However, scripting languages and C++ have simpler means to export them.
|
|
Property membership can be tested directly in GDScript using [code]in[/code]:
|
|
[codeblock]
|
|
var n = Node2D.new()
|
|
print("position" in n) # Prints "True".
|
|
print("other_property" in n) # Prints "False".
|
|
[/codeblock]
|
|
The [code]in[/code] operator will evaluate to [code]true[/code] as long as the key exists, even if the value is [code]null[/code].
|
|
Objects also receive notifications. Notifications are a simple way to notify the object about different events, so they can all be handled together. See [method _notification].
|
|
[b]Note:[/b] Unlike references to a [Reference], references to an Object stored in a variable can become invalid without warning. Therefore, it's recommended to use [Reference] for data classes instead of [Object].
|
|
[b]Note:[/b] Due to a bug, you can't create a "plain" Object using [code]Object.new()[/code]. Instead, use [code]ClassDB.instance("Object")[/code]. This bug only applies to Object itself, not any of its descendents like [Reference].
|
|
</description>
|
|
<tutorials>
|
|
<link title="When and how to avoid using nodes for everything">$DOCS_URL/tutorials/best_practices/node_alternatives.html</link>
|
|
<link title="Advanced exports using _get_property_list()">$DOCS_URL/tutorials/scripting/gdscript/gdscript_exports.html#advanced-exports</link>
|
|
</tutorials>
|
|
<methods>
|
|
<method name="_get" qualifiers="virtual">
|
|
<return type="Variant" />
|
|
<argument index="0" name="property" type="StringName" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="_get_property_list" qualifiers="virtual">
|
|
<return type="Array" />
|
|
<description>
|
|
Virtual method which can be overridden to customize the return value of [method get_property_list].
|
|
Returns the object's property list as an [Array] of dictionaries.
|
|
Each property's [Dictionary] must contain at least [code]name: String[/code] and [code]type: int[/code] (see [enum Variant.Type]) entries. Optionally, it can also include [code]hint: int[/code] (see [enum PropertyHint]), [code]hint_string: String[/code], and [code]usage: int[/code] (see [enum PropertyUsageFlags]).
|
|
</description>
|
|
</method>
|
|
<method name="_init" qualifiers="virtual">
|
|
<return type="void" />
|
|
<description>
|
|
Called when the object is initialized in memory. Can be defined to take in parameters, that are passed in when constructing.
|
|
[b]Note:[/b] If [method _init] is defined with required parameters, then explicit construction is the only valid means of creating an Object of the class. If any other means (such as [method PackedScene.instance]) is used, then initialization will fail.
|
|
</description>
|
|
</method>
|
|
<method name="_notification" qualifiers="virtual">
|
|
<return type="void" />
|
|
<argument index="0" name="what" type="int" />
|
|
<description>
|
|
Called whenever the object receives a notification, which is identified in [code]what[/code] by a constant. The base [Object] has two constants [constant NOTIFICATION_POSTINITIALIZE] and [constant NOTIFICATION_PREDELETE], but subclasses such as [Node] define a lot more notifications which are also received by this method.
|
|
</description>
|
|
</method>
|
|
<method name="_set" qualifiers="virtual">
|
|
<return type="bool" />
|
|
<argument index="0" name="property" type="StringName" />
|
|
<argument index="1" name="value" type="Variant" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="_to_string" qualifiers="virtual">
|
|
<return type="String" />
|
|
<description>
|
|
Virtual method which can be overridden to customize the return value of [method to_string], and thus the object's representation where it is converted to a string, e.g. with [code]print(obj)[/code].
|
|
Returns a [String] representing the object. If not overridden, defaults to [code]"[ClassName:RID]"[/code].
|
|
</description>
|
|
</method>
|
|
<method name="add_user_signal">
|
|
<return type="void" />
|
|
<argument index="0" name="signal" type="String" />
|
|
<argument index="1" name="arguments" type="Array" default="[ ]" />
|
|
<description>
|
|
Adds a user-defined [code]signal[/code]. Arguments are optional, but can be added as an [Array] of dictionaries, each containing [code]name: String[/code] and [code]type: int[/code] (see [enum Variant.Type]) entries.
|
|
</description>
|
|
</method>
|
|
<method name="call" qualifiers="vararg">
|
|
<return type="Variant" />
|
|
<argument index="0" name="method" type="StringName" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="call_deferred" qualifiers="vararg">
|
|
<return type="void" />
|
|
<argument index="0" name="method" type="StringName" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="callv">
|
|
<return type="Variant" />
|
|
<argument index="0" name="method" type="StringName" />
|
|
<argument index="1" name="arg_array" type="Array" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="can_translate_messages" qualifiers="const">
|
|
<return type="bool" />
|
|
<description>
|
|
Returns [code]true[/code] if the object can translate strings. See [method set_message_translation] and [method tr].
|
|
</description>
|
|
</method>
|
|
<method name="cancel_free">
|
|
<return type="void" />
|
|
<description>
|
|
If this method is called during [constant NOTIFICATION_PREDELETE], this object will reject being freed and will remain allocated. This is mostly an internal function used for error handling to avoid the user from freeing objects when they are not intended to.
|
|
</description>
|
|
</method>
|
|
<method name="connect">
|
|
<return type="int" enum="Error" />
|
|
<argument index="0" name="signal" type="StringName" />
|
|
<argument index="1" name="target" type="Object" />
|
|
<argument index="2" name="method" type="StringName" />
|
|
<argument index="3" name="binds" type="Array" default="[ ]" />
|
|
<argument index="4" name="flags" type="int" default="0" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="disconnect">
|
|
<return type="void" />
|
|
<argument index="0" name="signal" type="StringName" />
|
|
<argument index="1" name="target" type="Object" />
|
|
<argument index="2" name="method" type="StringName" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="emit_signal" qualifiers="vararg">
|
|
<return type="void" />
|
|
<argument index="0" name="signal" type="StringName" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="free">
|
|
<return type="void" />
|
|
<description>
|
|
Deletes the object from memory immediately. For [Node]s, you may want to use [method Node.queue_free] to queue the node for safe deletion at the end of the current frame.
|
|
[b]Important:[/b] If you have a variable pointing to an object, it will [i]not[/i] be assigned to [code]null[/code] once the object is freed. Instead, it will point to a [i]previously freed instance[/i] and you should validate it with [method @GDScript.is_instance_valid] before attempting to call its methods or access its properties.
|
|
</description>
|
|
</method>
|
|
<method name="get" qualifiers="const">
|
|
<return type="Variant" />
|
|
<argument index="0" name="property" type="String" />
|
|
<description>
|
|
Returns the [Variant] value of the given [code]property[/code]. If the [code]property[/code] doesn't exist, this will return [code]null[/code].
|
|
[b]Note:[/b] 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).
|
|
</description>
|
|
</method>
|
|
<method name="get_class" qualifiers="const">
|
|
<return type="String" />
|
|
<description>
|
|
Returns the object's class as a [String]. See also [method is_class].
|
|
[b]Note:[/b] [method get_class] does not take [code]class_name[/code] declarations into account. If the object has a [code]class_name[/code] defined, the base class name will be returned instead.
|
|
</description>
|
|
</method>
|
|
<method name="get_incoming_connections" qualifiers="const">
|
|
<return type="Array" />
|
|
<description>
|
|
Returns an [Array] of dictionaries with information about signals that are connected to the object.
|
|
Each [Dictionary] contains three String entries:
|
|
- [code]source[/code] is a reference to the signal emitter.
|
|
- [code]signal_name[/code] is the name of the connected signal.
|
|
- [code]method_name[/code] is the name of the method to which the signal is connected.
|
|
</description>
|
|
</method>
|
|
<method name="get_indexed" qualifiers="const">
|
|
<return type="Variant" />
|
|
<argument index="0" name="property_path" type="NodePath" />
|
|
<description>
|
|
Gets the object's property indexed by the given [code]property_path[/code]. The path should be a [NodePath] relative to the current object and can use the colon character ([code]:[/code]) to access nested properties. Examples: [code]"position:x"[/code] or [code]"material:next_pass:blend_mode"[/code].
|
|
[b]Note:[/b] Even though the method takes [NodePath] argument, it doesn't support actual paths to [Node]s in the scene tree, only colon-separated sub-property paths. For the purpose of nodes, use [method Node.get_node_and_resource] instead.
|
|
</description>
|
|
</method>
|
|
<method name="get_instance_id" qualifiers="const">
|
|
<return type="int" />
|
|
<description>
|
|
Returns the object's unique instance ID.
|
|
This ID can be saved in [EncodedObjectAsID], and can be used to retrieve the object instance with [method @GDScript.instance_from_id].
|
|
</description>
|
|
</method>
|
|
<method name="get_meta" qualifiers="const">
|
|
<return type="Variant" />
|
|
<argument index="0" name="name" type="String" />
|
|
<argument index="1" name="default" type="Variant" default="null" />
|
|
<description>
|
|
Returns the object's metadata entry for the given [code]name[/code].
|
|
Throws error if the entry does not exist, unless [code]default[/code] is not [code]null[/code] (in which case the default value will be returned).
|
|
</description>
|
|
</method>
|
|
<method name="get_meta_list" qualifiers="const">
|
|
<return type="PoolStringArray" />
|
|
<description>
|
|
Returns the object's metadata as a [PoolStringArray].
|
|
</description>
|
|
</method>
|
|
<method name="get_method_list" qualifiers="const">
|
|
<return type="Array" />
|
|
<description>
|
|
Returns the object's methods and their signatures as an [Array].
|
|
</description>
|
|
</method>
|
|
<method name="get_property_list" qualifiers="const">
|
|
<return type="Array" />
|
|
<description>
|
|
Returns the object's property list as an [Array] of dictionaries.
|
|
Each property's [Dictionary] contain at least [code]name: String[/code] and [code]type: int[/code] (see [enum Variant.Type]) entries. Optionally, it can also include [code]hint: int[/code] (see [enum PropertyHint]), [code]hint_string: String[/code], and [code]usage: int[/code] (see [enum PropertyUsageFlags]).
|
|
</description>
|
|
</method>
|
|
<method name="get_script" qualifiers="const">
|
|
<return type="Reference" />
|
|
<description>
|
|
Returns the object's [Script] instance, or [code]null[/code] if none is assigned.
|
|
</description>
|
|
</method>
|
|
<method name="get_signal_connection_list" qualifiers="const">
|
|
<return type="Array" />
|
|
<argument index="0" name="signal" type="String" />
|
|
<description>
|
|
Returns an [Array] of connections for the given [code]signal[/code].
|
|
</description>
|
|
</method>
|
|
<method name="get_signal_list" qualifiers="const">
|
|
<return type="Array" />
|
|
<description>
|
|
Returns the list of signals as an [Array] of dictionaries.
|
|
</description>
|
|
</method>
|
|
<method name="has_meta" qualifiers="const">
|
|
<return type="bool" />
|
|
<argument index="0" name="name" type="String" />
|
|
<description>
|
|
Returns [code]true[/code] if a metadata entry is found with the given [code]name[/code].
|
|
</description>
|
|
</method>
|
|
<method name="has_method" qualifiers="const">
|
|
<return type="bool" />
|
|
<argument index="0" name="method" type="StringName" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="has_signal" qualifiers="const">
|
|
<return type="bool" />
|
|
<argument index="0" name="signal" type="StringName" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="has_user_signal" qualifiers="const">
|
|
<return type="bool" />
|
|
<argument index="0" name="signal" type="StringName" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="is_blocking_signals" qualifiers="const">
|
|
<return type="bool" />
|
|
<description>
|
|
Returns [code]true[/code] if signal emission blocking is enabled.
|
|
</description>
|
|
</method>
|
|
<method name="is_class" qualifiers="const">
|
|
<return type="bool" />
|
|
<argument index="0" name="class" type="String" />
|
|
<description>
|
|
Returns [code]true[/code] if the object inherits from the given [code]class[/code]. See also [method get_class].
|
|
[b]Note:[/b] [method is_class] does not take [code]class_name[/code] declarations into account. If the object has a [code]class_name[/code] defined, [method is_class] will return [code]false[/code] for that name.
|
|
</description>
|
|
</method>
|
|
<method name="is_connected" qualifiers="const">
|
|
<return type="bool" />
|
|
<argument index="0" name="signal" type="StringName" />
|
|
<argument index="1" name="target" type="Object" />
|
|
<argument index="2" name="method" type="StringName" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="is_queued_for_deletion" qualifiers="const">
|
|
<return type="bool" />
|
|
<description>
|
|
Returns [code]true[/code] if the [method Node.queue_free] method was called for the object.
|
|
</description>
|
|
</method>
|
|
<method name="notification">
|
|
<return type="void" />
|
|
<argument index="0" name="what" type="int" />
|
|
<argument index="1" name="reversed" type="bool" default="false" />
|
|
<description>
|
|
Send a given notification to the object, which will also trigger a call to the [method _notification] method of all classes that the object inherits from.
|
|
If [code]reversed[/code] is [code]true[/code], [method _notification] is called first on the object's own class, and then up to its successive parent classes. If [code]reversed[/code] is [code]false[/code], [method _notification] is called first on the highest ancestor ([Object] itself), and then down to its successive inheriting classes.
|
|
</description>
|
|
</method>
|
|
<method name="property_list_changed_notify">
|
|
<return type="void" />
|
|
<description>
|
|
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.
|
|
</description>
|
|
</method>
|
|
<method name="remove_meta">
|
|
<return type="void" />
|
|
<argument index="0" name="name" type="String" />
|
|
<description>
|
|
Removes a given entry from the object's metadata. See also [method set_meta].
|
|
</description>
|
|
</method>
|
|
<method name="set">
|
|
<return type="void" />
|
|
<argument index="0" name="property" type="String" />
|
|
<argument index="1" name="value" type="Variant" />
|
|
<description>
|
|
Assigns a new value to the given property. If the [code]property[/code] does not exist or the given value's type doesn't match, nothing will happen.
|
|
[b]Note:[/b] 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).
|
|
</description>
|
|
</method>
|
|
<method name="set_block_signals">
|
|
<return type="void" />
|
|
<argument index="0" name="enable" type="bool" />
|
|
<description>
|
|
If set to [code]true[/code], signal emission is blocked.
|
|
</description>
|
|
</method>
|
|
<method name="set_deferred">
|
|
<return type="void" />
|
|
<argument index="0" name="property" type="StringName" />
|
|
<argument index="1" name="value" type="Variant" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
<method name="set_indexed">
|
|
<return type="void" />
|
|
<argument index="0" name="property_path" type="NodePath" />
|
|
<argument index="1" name="value" type="Variant" />
|
|
<description>
|
|
Assigns a new value to the property identified by the [code]property_path[/code]. The path should be a [NodePath] relative to the current object and can use the colon character ([code]:[/code]) to access nested properties. Example:
|
|
[codeblock]
|
|
set_indexed("position", Vector2(42, 0))
|
|
set_indexed("position:y", -10)
|
|
print(position) # (42, -10)
|
|
[/codeblock]
|
|
</description>
|
|
</method>
|
|
<method name="set_message_translation">
|
|
<return type="void" />
|
|
<argument index="0" name="enable" type="bool" />
|
|
<description>
|
|
Defines whether the object can translate strings (with calls to [method tr]). Enabled by default.
|
|
</description>
|
|
</method>
|
|
<method name="set_meta">
|
|
<return type="void" />
|
|
<argument index="0" name="name" type="String" />
|
|
<argument index="1" name="value" type="Variant" />
|
|
<description>
|
|
Adds, changes or removes a given entry in the object's metadata. Metadata are serialized and can take any [Variant] value.
|
|
To remove a given entry from the object's metadata, use [method remove_meta]. Metadata is also removed if its value is set to [code]null[/code]. This means you can also use [code]set_meta("name", null)[/code] to remove metadata for [code]"name"[/code].
|
|
</description>
|
|
</method>
|
|
<method name="set_script">
|
|
<return type="void" />
|
|
<argument index="0" name="script" type="Reference" />
|
|
<description>
|
|
Assigns a script to the object. Each object can have a single script assigned to it, which are used to extend its functionality.
|
|
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 [method _init] method will be called.
|
|
</description>
|
|
</method>
|
|
<method name="to_string">
|
|
<return type="String" />
|
|
<description>
|
|
Returns a [String] representing the object. If not overridden, defaults to [code]"[ClassName:RID]"[/code].
|
|
Override the method [method _to_string] to customize the [String] representation.
|
|
</description>
|
|
</method>
|
|
<method name="tr" qualifiers="const">
|
|
<return type="StringName" />
|
|
<argument index="0" name="message" type="StringName" />
|
|
<description>
|
|
</description>
|
|
</method>
|
|
</methods>
|
|
<signals>
|
|
<signal name="script_changed">
|
|
<description>
|
|
Emitted whenever the object's script is changed.
|
|
</description>
|
|
</signal>
|
|
</signals>
|
|
<constants>
|
|
<constant name="NOTIFICATION_POSTINITIALIZE" value="0">
|
|
Called right when the object is initialized. Not available in script.
|
|
</constant>
|
|
<constant name="NOTIFICATION_PREDELETE" value="1">
|
|
Called before the object is about to be deleted.
|
|
</constant>
|
|
<constant name="CONNECT_DEFERRED" value="1" enum="ConnectFlags">
|
|
Connects a signal in deferred mode. This way, signal emissions are stored in a queue, then set on idle time.
|
|
</constant>
|
|
<constant name="CONNECT_PERSIST" value="2" enum="ConnectFlags">
|
|
Persisting connections are saved when the object is serialized to file.
|
|
</constant>
|
|
<constant name="CONNECT_ONESHOT" value="4" enum="ConnectFlags">
|
|
One-shot connections disconnect themselves after emission.
|
|
</constant>
|
|
<constant name="CONNECT_REFERENCE_COUNTED" value="8" enum="ConnectFlags">
|
|
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.
|
|
</constant>
|
|
</constants>
|
|
</class>
|