RegisteredClass
See the code atresources/registered_class.gdDescription
Inherits Resource
The RegisteredClass class represents a registered class in the ModClassDB. It defines a script associated with a unique class name and provides information about the class, including its name, the script it is associated with, and its parent class.
Properties
name
var name: StringName
The unique name of the registered class. It can be either the Script resource path or an explicitly provided name.
| Type | StringName |
|---|---|
| Default |
cls
var cls: Script
The Script class associated with the registered class.
| Type | Script |
|---|---|
| Default | null |
parent
var parent: RegisteredClass
The parent class of this registered class.
Note: The parent must also be registered.
| Type | RegisteredClass |
|---|---|
| Default | null |
Methods
_init
func _init(
name_value: StringName,
cls_value: Script,
parent_value: RegisteredClass = null
) -> void
Initializes a new RegisteredClass object with the given name, cls, and parent.
Parameters
| Name | Type | Description |
|---|---|---|
name_value | StringName | The unique name of the registered class. |
cls_value | Script | The script class associated with the registered class. |
parent_value | RegisteredClass (optional) | The parent class of the registered class. |
Returns
void
from_script
from_script(script: GDScript) -> RegisteredClass
Creates a new RegisteredClass object by parsing the class name from the GDScript script's class_name declaration or the resource_path if the class name is empty. It also parses the parent class from the extends declaration.
Parameters
| Name | Type | Description |
|---|---|---|
script | GDScript | The script class to register. |
Returns
| Type | RegisteredClass |
|---|---|
| Description | The new RegisteredClass. |
has_ancestor
func has_ancestor(ancestor: RegisteredClass) -> bool
Checks whether the RegisteredClass or any of its parent classes is the specified ancestor class.
Parameters
| Name | Type | Description |
|---|---|---|
ancestor | RegisteredClass | The ancestor class to check. |
Returns
| Type | bool |
|---|---|
| Description | true if this RegisteredClass has the given ancestory. |