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

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

There is a newer version: 0.10.0-4.3.0
Show newest version
package godot.core

@JvmInline
value class ObjectID(val id: Long) {
    val isReference: Boolean
        get() = (id and OBJECTDB_REFERENCE_BIT) != 0L

    val index: Int
        get() = (id and OBJECTDB_SLOT_MAX_COUNT_MASK).toInt()

    val validator: Int
        get() = ((id shr OBJECTDB_SLOT_MAX_COUNT_BITS) and OBJECTDB_VALIDATOR_MASK).toInt()

    companion object {
        //Copied from object.h, change that part if Godot does.
        private const val OBJECTDB_VALIDATOR_BITS = 39
        const val OBJECTDB_VALIDATOR_MASK = ((1L shl OBJECTDB_VALIDATOR_BITS) - 1L)
        const val OBJECTDB_SLOT_MAX_COUNT_BITS = 24
        const val OBJECTDB_SLOT_MAX_COUNT_MASK = ((1L shl OBJECTDB_SLOT_MAX_COUNT_BITS) - 1L)
        const val OBJECTDB_REFERENCE_BIT = (1L shl (OBJECTDB_SLOT_MAX_COUNT_BITS + OBJECTDB_VALIDATOR_BITS))
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy