ktx.artemis.archetype.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.Archetype
import com.artemis.ArchetypeBuilder
import com.artemis.Component
import kotlin.reflect.KClass
/**
* Adds a [Component] to an [ArchetypeBuilder].
*
* @receiver the [ArchetypeBuilder] for creating an [Archetype].
* @param T the component to add to the [ArchetypeBuilder].
* @return the [ArchetypeBuilder].
*/
inline fun ArchetypeBuilder.add(): ArchetypeBuilder = add(T::class.java)
/**
* Removes a [Component] from an [ArchetypeBuilder].
*
* @receiver the [ArchetypeBuilder] for creating an [Archetype].
* @param T the component to remove from the [ArchetypeBuilder].
* @return the [ArchetypeBuilder].
*/
inline fun ArchetypeBuilder.remove(): ArchetypeBuilder = remove(T::class.java)
/**
* Adds multiple components to an [ArchetypeBuilder].
*
* @receiver the [ArchetypeBuilder] for creating an [Archetype].
* @param components the components to add to the [ArchetypeBuilder].
* @return the [ArchetypeBuilder].
*/
fun ArchetypeBuilder.add(vararg components: KClass): ArchetypeBuilder =
add(*components.asJavaClasses())
/**
* Removes multiple components from an [ArchetypeBuilder].
*
* @receiver the [ArchetypeBuilder] for creating an [Archetype].
* @param components - the components to remove from the [ArchetypeBuilder]
* @return the [ArchetypeBuilder].
*/
fun ArchetypeBuilder.remove(vararg components: KClass): ArchetypeBuilder =
remove(*components.asJavaClasses())