Skip to main content

RegisteredClass

See the code at resources/registered_class.gd

Description

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.

TypeStringName
Default

cls

var cls: Script

The Script class associated with the registered class.

TypeScript
Defaultnull

parent

var parent: RegisteredClass

The parent class of this registered class.

Note: The parent must also be registered.

TypeRegisteredClass
Defaultnull

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

NameTypeDescription
name_valueStringNameThe unique name of the registered class.
cls_valueScriptThe script class associated with the registered class.
parent_valueRegisteredClass (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

NameTypeDescription
scriptGDScriptThe script class to register.

Returns

TypeRegisteredClass
DescriptionThe 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

NameTypeDescription
ancestorRegisteredClassThe ancestor class to check.

Returns

Typebool
Descriptiontrue if this RegisteredClass has the given ancestory.