class DataModel(dataModel_: Long)
val dataModel = EntityContext.getDataModel()
// setup button event listener
button.entity.registerEventListener<EventArgs>("button") { _, _ ->
// handle event
}
dataModel?.sendEvent(entity, "button", EventArgs("click", dataModel))
| Name | Summary |
|---|---|
DataModel | constructor(dataModel_: Long) |
| Name | Summary |
|---|---|
Companion | object Companion |
inner class KeyIterator(dm_: DataModel, it_: Long) |
| Name | Summary |
|---|---|
createEntity | fun createEntity(): Entity Creates a new entity in the data model. fun createEntity(vararg components: ComponentBase): Entity fun createEntity(components: List<ComponentBase>): Entity Creates a new entity in the data model with components. |
deleteEntity | fun deleteEntity(eid: Long) Deletes an entity from the data model. The entity will be included in deleted queries next tick. We recommend using Entity.destroy() instead of this function. |
getEventListenerForEvent | fun getEventListenerForEvent(eventType: String): Set<<Error class: unknown class><Entity, EventListener<EventArgs>>> Gets all listeners registered for a specific event type. |
getKeyValueMap | inline fun <T, V> getKeyValueMap(id: Long, attribute: Int): HashMap<T, V> |
getLastUpdateVersion | fun getLastUpdateVersion(): <Error class: unknown class> Experimental API. This gets a long that represents the last updated version of the data model. |
hasKey | fun hasKey(id: Long, attribute: Int): Boolean Checks if an entity has a specific attribute. |
nativeGetKeyValueMap | external fun nativeGetKeyValueMap(dataModel: Long, id: Long, attribute: Int): Array<Any> |
registerAttributeListener | fun registerAttributeListener(attribute: Int, listener: AttributeListener) Registers a listener for changes to a specific attribute. |
registerComponentListener | fun registerComponentListener(componentID: Int, componentClass: KClass<*>, listener: ComponentListener) Registers a listener for changes to a specific component. |
registerEventListener | fun registerEventListener(entity: Entity, eventType: String, listener: EventListener<EventArgs>) Registers a listener for events on a specific entity. |
registerLinkedEntityAttribute | fun registerLinkedEntityAttribute(attributeID: Int) This method is experimental and is subject to change in the future. |
removeComponentListener | fun removeComponentListener(componentID: Int) Removes a previously registered component listener. |
object Companion
| Name | Summary |
|---|---|
getLocalDataModelTime | fun getLocalDataModelTime(): Long Gets the local time based on the data model. |