ktx.artemis.mapper.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ktx-artemis Show documentation
Show all versions of ktx-artemis Show documentation
Artemis-odb entity component system utilities for Kotlin libGDX applications.
The newest version!
package ktx.artemis
import com.artemis.Component
import com.artemis.ComponentMapper
import com.artemis.World
/**
* Checks if the entity has this type of [Component].
*
* @receiver the [ComponentMapper] for checking if the entity has the component.
* @param entityId the ID of entity to check.
* @return `true` if the entity has this component type, `false`` if it does not or is scheduled for removal.
* @throws ArrayIndexOutOfBoundsException if the component was removed or never existed.
*/
operator fun ComponentMapper.contains(entityId: Int): Boolean = has(entityId)
/**
* Retrieves a ComponentMapper instance for a [Component].
*
* @receiver the [World].
* @param T type of the [ComponentMapper] to retrieve.
* @return the [ComponentMapper] of the given type.
*/
inline fun World.mapperFor(): ComponentMapper = getMapper(T::class.java)