Entity.create() static method to create new entities instead of the Entity constructors
class Entity
Entity
(
dataModel
, id
, components
)
|
Constructor for creating an entity with a specified data model, ID, and variable number of components.
Signature
constructor(dataModel: DataModel, id: Long, vararg components: ComponentBase) Parameters
dataModel:
DataModel
id:
Long
components:
ComponentBase Returns |
addName
(
name
)
| |
addToMap
(
attribute
, value
)
|
Signature
fun addToMap(attribute: Int, value: HashMap<*, *><out <Error class: unknown class>, out <Error class: unknown class>>) Parameters
attribute:
Int
value:
HashMap<*, *>
|
childrenOfAttrId
(
typeID
)
|
childrenOfTypeId returns a sequence of entities that are children of this entity's attribute.
Signature
fun childrenOfAttrId(typeID: Int): Sequence<Entity><Entity> Parameters
typeID:
Int
Returns
Sequence<Entity>
|
destroy
()
|
Destroys this entity.
This method will remove the entity from the data model and free up any resources associated with it.
Signature
fun destroy() |
destroyWithChildren
()
|
Signature
fun Entity.destroyWithChildren() |
equals
(
o
)
|
Checks if this entity is equal to another object. The object is equal to this entity iff the object is an Entity and has the same ID as this entity.
Signature
open operator override fun equals(o: Any?): Boolean Parameters
o:
Any?
Returns
Boolean
|
getComponent
(
recycler
)
|
gets the specified component with the most up to date attribute values for this entity. If the component does not exist for this entity, a RuntimeException will be thrown.
Example:
val transform = entity.getComponent<Transform>()
Signature
inline fun <T : ComponentBase> getComponent(recycler: ComponentRecyler? = null): T Parameters
recycler:
ComponentRecyler?
Throws
RuntimeException
|
hasComponent
()
|
Signature
inline fun <T : ComponentBase> hasComponent(): Boolean Returns
Boolean
|
isLocal
()
|
Returns whether the entity is local or not.
Signature
fun isLocal(): Boolean Returns
Boolean
|
markComponentChanged
()
|
Marks a component as "changed" without setting new component data.
This is useful in rare cases where you want the component to be considered "changed" for change detection purposes, even when the actual component data hasn't been modified. This will trigger component change listeners and queries that look for changed components.
Example:
// Force the Panel component to be marked as changed entity.markComponentChanged<Panel>()
Signature
inline fun <T : ComponentBase> markComponentChanged(): Entity Throws
RuntimeException
|
readIntoComponent
(
cls
)
|
Signature
fun <T : ComponentBase> readIntoComponent(cls: Pair<T, Boolean><T, Boolean>): T Parameters
cls:
Pair<T, Boolean>
Returns |
registerEventListener
(
eventName
, listener
)
|
Registers an event listener for a specific event.
Signature
fun <T : EventArgs> registerEventListener(eventName: String, listener: (entity: Entity, eventArgs: T) -> Unit): Entity Parameters
eventName:
String
listener:
Function2
|
setComponent
(
c
)
|
Sets a single component for this entity.
Signature
fun setComponent(c: ComponentBase): Entity Parameters
The component to set.
|
setComponents
(
components
)
|
Sets the components for this entity.
Signature
fun setComponents(components: List<ComponentBase>): Entity Parameters
components:
List
|
setComponents
(
components
)
|
Sets the components for this entity.
Signature
fun setComponents(vararg components: ComponentBase): Entity Parameters
components:
ComponentBase |
setMap
(
attribute
, value
)
|
Signature
fun setMap(attribute: Int, value: HashMap<*, *><out <Error class: unknown class>, out <Error class: unknown class>>) Parameters
attribute:
Int
value:
HashMap<*, *>
|
tryGetComponent
(
recycler
)
|
A safe way to get a component with the most up to date attribute values for this entity. If the component does not exist for this entity, null will be returned.
Example:
val transform = entity.tryGetComponent<Transform>()
Signature
inline fun <T : ComponentBase> tryGetComponent(recycler: ComponentRecyler? = null): T? Parameters
recycler:
ComponentRecyler?
Returns
The component instance of type T or null if the component does not exist for this entity
|
tryReadIntoComponent
(
cls
, componentTypeID
)
|
Signature
fun <T : ComponentBase> tryReadIntoComponent(cls: Pair<T, Boolean><T, Boolean>, componentTypeID: Int): T? Parameters
cls:
Pair<T, Boolean>
componentTypeID:
Int
Returns |
create
()
|
Creates a new entity with the default data model.
Signature
fun create(): Entity |
create
(
dm
)
| |
create
(
component
)
|
Creates a new entity with the specified component.
Signature
fun create(component: ComponentBase): Entity Parameters
component:
ComponentBase |
create
(
components
)
|
Creates a new entity with the specified list of components.
Signature
fun create(components: List<ComponentBase>): Entity Parameters
components:
List
|
create
(
components
)
|
Creates a new entity with the specified variable number of components.
Signature
fun create(vararg components: ComponentBase): Entity Parameters
components:
ComponentBase |
createPanelEntity
(
panelId
, transform
, components
)
|
Signature
fun Entity.Companion.createPanelEntity(panelId: Int, transform: Transform, vararg components: ComponentBase): Entity Parameters Returns |
createPanelEntity
(
entityId
, panelId
, transform
, components
)
|
Signature
fun Entity.Companion.createPanelEntity(entityId: Int, panelId: Int, transform: Transform, vararg components: ComponentBase): Entity Parameters Returns |
fromBox
(
length
, transform
, material
, components
)
|
Signature
fun Entity.Companion.fromBox(length: Float, transform: Transform, material: Material? = null, vararg components: ComponentBase): Entity Parameters Returns |
fromGLB
(
mesh
, transform
, components
)
|
Signature
fun Entity.Companion.fromGLB(mesh: Mesh, transform: Transform, vararg components: ComponentBase): Entity Parameters Returns |
fromMeshAndMaterial
(
mesh
, material
, transform
, components
)
|
Signature
fun Entity.Companion.fromMeshAndMaterial(mesh: Mesh, material: Material, transform: Transform, vararg components: ComponentBase): Entity Parameters Returns |
fromPanelRegistry
(
registry
, transform
, components
)
|
Signature
fun Entity.Companion.fromPanelRegistry(registry: PanelRegistration, transform: Transform, vararg components: ComponentBase): Entity Parameters Returns |
fromSphere
(
length
, transform
, material
, components
)
|
Signature
fun Entity.Companion.fromSphere(length: Float, transform: Transform, material: Material? = null, vararg components: ComponentBase): Entity Parameters Returns |
nullEntity
()
|
Creates a null entity. You cannot use this entity to set or get components. The nullEntity is generally used as a placeholder for Entity attributes.
Here is an example using TransformParent:
val transformParent = myEntity.getComponent<TransformParent>() transformParent.parent = Entity.nullEntity() // This makes it as if no TransformParent is set. myEntity.setComponent(transformParent)
Signature
fun nullEntity(): Entity |