API reference
API reference
Select your platform
No SDKs available
No versions available

ComponentBase

ComponentBase

abstract class ComponentBase
Base class for all components in the Spatial SDK entity-component system (ECS). See more: https://developers.meta.com/horizon/documentation/spatial-sdk/spatial-sdk-component
ComponentBase provides the core functionality for components, including attribute storage, serialization, and lifecycle management.

Constructors

NameSummary
ComponentBase
constructor()

Properties

NameSummary
cachable
open val cachable: Boolean
entID
var entID: Long
isDirty
var isDirty: Boolean
recycled
var recycled: Boolean
timeStamp
var timeStamp: Long

Functions

NameSummary
companion
open fun companion(): ComponentCompanion

Gets the companion object for this component.
getComponentDataAttributeType
fun getComponentDataAttributeType(key: Int): AttributePrimitive?

Gets the attribute type for the specified key.



fun getComponentDataAttributeType(keyString: String): AttributePrimitive?

Gets the attribute type for the specified string key.
getComponentDataKey
fun getComponentDataKey(key: String): Int?

Gets the integer key associated with the specified string key.
getComponentDataValue
fun getComponentDataValue(key: Int): Any?

Gets the value for the specified key.



fun getComponentDataValue(keyString: String): Any?

Gets the value for the specified string key.
getEnumClass
fun getEnumClass(key: String): Class<out Enum<*>>?

Gets the enum class associated with the specified string key.
hasComponentData
fun hasComponentData(key: Int): Boolean

Checks if this component has data for the specified key.



fun hasComponentData(keyString: String): Boolean

Checks if this component has data for the specified string key.
read
fun read(e: Entity, cachable: Boolean)

Reads component data from the specified entity.
recycle
fun recycle()

Recycles this component by returning it to its pool.
reset
open fun reset()

Resets the component to its default state.
setComponentDataValue
fun setComponentDataValue(key: Int, value: Any): Boolean

Sets the value for the specified key.



fun setComponentDataValue(keyString: String, value: Any): Boolean

Sets the value for the specified string key.
setPool
fun setPool(pool: ComponentPool<*>, entID: Long)

Sets the component pool and entity ID for this component.
toString
open override fun toString(): String
typeID
abstract fun typeID(): Int

Returns the unique type ID of this component.
write
fun write(e: Entity)

Writes this component’s data to the specified entity.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon