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

ComponentManager Class

Modifiers: final
Manages component registration, creation, and lifecycle in the Spatial SDK.
The ComponentManager is responsible for:
  • Registering components with the system
  • Creating component instances
  • Managing component pools
  • Tracking attribute information for components
  • Handling entity component lifecycle
How to register a component in your Spatial SDK Activity/Service:
override fun onCreate() {
  super.onCreate()
  componentManager.registerComponent<MyComponent>(MyComponent.Companion)
}

Signature

class ComponentManager

Constructors

ComponentManager ()
Signature
constructor()

Functions

assertComponent ( clazz )
Asserts that a component class is registered.
Signature
fun assertComponent(clazz: KClass<*>)
Parameters
clazz: KClass
The Kotlin class to check
Throws
IllegalArgumentException
If the component class is not registered
checkComponent ( clazz )
Checks if a component class is registered.
Signature
fun checkComponent(clazz: KClass<*>): Boolean
Parameters
clazz: KClass
The Kotlin class to check
Returns
Boolean
True if the component is registered, false otherwise
createInstance ( clazz , entID )
Creates an instance of a component for a specific entity.
Signature
fun <T> createInstance(clazz: KClass<*>, entID: Long): Pair<T, Boolean><T, Boolean>
Parameters
clazz: KClass
The Kotlin class of the component to create
entID: Long
The entity ID to associate with the component
Returns
Pair<T, Boolean>
A pair containing the component instance and a boolean indicating if it was cached
Throws
IllegalArgumentException
If the component class is not registered
createInstance ( clazz )
Creates an instance of a component without associating it with an entity.
Signature
fun <T> createInstance(clazz: KClass<*>): Pair<T, Boolean><T, Boolean>
Parameters
clazz: KClass
The Kotlin class of the component to create
Returns
Pair<T, Boolean>
A pair containing the component instance and a boolean indicating if it was cached
Throws
IllegalArgumentException
If the component class is not registered
registerComponent ( clazz , name , sendRate , companionObjectInstance )
This method registers a component class with the ComponentManager, making it available for use with entities. It also registers the component's attributes with the DataModel and configures metadata settings.
Signature
fun registerComponent(clazz: KClass<*>, name: String, sendRate: SendRate, companionObjectInstance: ComponentCompanion)
Parameters
clazz: KClass
The Kotlin class of the component
name: String
The name of the component
sendRate: SendRate
companionObjectInstance: ComponentCompanion
The companion object instance of the component class
registerComponent ( companionObjectInstance , sendRate )
Registers a component with the ComponentManager using reified type parameters.
Signature
inline fun <T : ComponentBase> registerComponent(companionObjectInstance: ComponentCompanion, sendRate: SendRate = SendRate.DEFAULT)
Parameters
companionObjectInstance: ComponentCompanion
The companion object instance of the component class
sendRate: SendRate
The network synchronization rate for this component (defaults to DEFAULT)
Did you find this page helpful?