All Downloads are FREE. Search and download functionalities are using the official Maven repository.

godot.core.KtClass.kt Maven / Gradle / Ivy

The newest version!
package godot.core

import godot.core.memory.TransferContext

@Suppress("unused")
data class KtClass(
    val registeredName: String,
    val relativeSourcePath: String,
    val compilationTimeRelativeRegistrationFilePath: String,
    private val _registeredSupertypes: List,
    private val _constructors: List?>,
    private val _properties: Map>,
    private val _functions: Map>,
    private val _notificationFunctions: List Unit>,
    private val _signalInfos: Map,
    val baseGodotClass: String
) {
    val registeredSupertypes: Array
        get() = _registeredSupertypes.toTypedArray()
    val constructors: Array?>
        get() = _constructors.toTypedArray()
    val functions: Array>
        get() = _functions.values.toTypedArray()
    val properties: Array>
        get() = _properties.values.toTypedArray()
    val signalInfos: Array
        get() = _signalInfos.values.toTypedArray()
    val hasNotification: Boolean
        get() = _notificationFunctions.isNotEmpty()

    fun doNotification(instance: T) {
        val parameters = arrayOfNulls(2)
        TransferContext.readArguments(
            arrayOf(VariantParser.LONG, VariantParser.BOOL),
            parameters
        )

        val notification = parameters[0]
        val reversed = parameters[1]

        require(notification is Long)
        require(reversed is Boolean)

        if (reversed) {
            for (notificationFunction in _notificationFunctions) {
                notificationFunction(instance, notification.toInt())
            }
            return
        }

        for (i in _notificationFunctions.size - 1 downTo 0) {
            _notificationFunctions[i](instance, notification.toInt())
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy