Package-level declarations

Types

Link copied to clipboard

Marks KTX Ashley type-safe builders.

Link copied to clipboard
class ComponentDelegate<T : Component>(mapper: ComponentMapper<T>)

Property delegate for an Entity wrapping around a ComponentMapper. Allows accessing components assigned to entities with the property syntax. Designed for non-nullable components that are available for all entities without the risk of a NullPointerException.

Link copied to clipboard
class CreateComponentException(type: KClass<*>, cause: Throwable? = null) : RuntimeException

Thrown when unable to create a component of given type.

Link copied to clipboard
class EngineEntity(val engine: Engine, val entity: Entity)

An Entity created by the provided Engine.

Link copied to clipboard
interface EntityAdditionListener : EntityListener

An EntityListener only requiring an implementation of the entityAdded method.

Link copied to clipboard
interface EntityRemovalListener : EntityListener

An EntityListener only requiring an implementation of the entityRemoved method.

Link copied to clipboard
abstract class Mapper<T : Component>

A utility abstract class for companion objects of Components. Defines a static mapper available of a chosen Component type.

Link copied to clipboard
class MissingEntitySystemException(type: KClass<out EntitySystem>) : GdxRuntimeException

Thrown when accessing an EntitySystem via getSystem that does not exist in the Engine.

Link copied to clipboard
class OptionalComponentDelegate<T : Component>(mapper: ComponentMapper<T>, componentClass: Class<T>)

Property delegate for an Entity wrapping around a ComponentMapper. Designed for components that might not be defined for each entity and can be null. Attempting to assign a null value to the property will remove the component from the entity.

Link copied to clipboard
class ProviderTagDelegate<T : Component>(mapper: ComponentMapper<T>, componentClass: Class<T>, defaultValueProvider: () -> T) : TagDelegate<T>

Property delegate for an Entity wrapping around a ComponentMapper. Allows checking the presence of a Component of an Entity. Automatically creates instances of the T if its value is set to true.

Link copied to clipboard
class SingletonTagDelegate<T : Component>(mapper: ComponentMapper<T>, componentClass: Class<T>, defaultValue: T) : TagDelegate<T>

Property delegate for an Entity wrapping around a ComponentMapper. Allows checking the presence of a Component of an Entity. Automatically assigns a singleton instance of the T if its value is set to true. This property delegate should be used only for stateless components without any mutable properties.

Link copied to clipboard
interface TagDelegate<T : Component>

Common interface for property delegates wrapping around flag components. These properties should generally wrap Components that do not have any fields, and instead their presence alone is used for filtering or associated logic. An example of such component could be a Visible class that marks entities that should be rendered.

Functions

Link copied to clipboard
inline fun Engine.add(configure: Engine.() -> Unit)

Builder function for Engine.

Link copied to clipboard
inline fun <T : Component> Entity.addComponent(engine: Engine, configure: T.() -> Unit = {}): T

Adds a Component to this Entity. If a Component of the same type already exists, it will be replaced.

Link copied to clipboard
fun allOf(vararg components: KClass<out Component>): Family.Builder
Link copied to clipboard
fun Family.Builder.allOf(vararg components: KClass<out Component>): Family.Builder
Link copied to clipboard
inline fun Engine.configureEntity(entity: Entity, configure: EngineEntity.() -> Unit)

Allows to configure an existing Entity with this Engine.

Link copied to clipboard
operator fun <T : Component> Entity.contains(mapper: ComponentMapper<T>): Boolean

Checks whether the Entity has the specified Component.

Link copied to clipboard
inline fun <T : Component> Engine.create(configure: T.() -> Unit = {}): T

Get or create a Component by calling Engine.createComponent.

Link copied to clipboard
inline fun Engine.entity(configure: EngineEntity.() -> Unit = {}): Entity

Create and add an Entity to the Engine.

Link copied to clipboard
fun exclude(vararg components: KClass<out Component>): Family.Builder
Link copied to clipboard
fun Family.Builder.exclude(vararg components: KClass<out Component>): Family.Builder
Link copied to clipboard
inline fun <T : Component> Entity.get(): T?

Gets the specified Component from the Entity.

operator fun <T : EntitySystem> Engine.get(type: KClass<T>): T?

operator fun <T : Component> Entity.get(mapper: ComponentMapper<T>): T?

Gets the specified Component from the Entity with a ComponentMapper.

Link copied to clipboard
inline fun <T : EntitySystem> Engine.getSystem(): T
Link copied to clipboard
fun <T : Component> Entity.has(mapper: ComponentMapper<T>): Boolean

Checks whether the Entity has the specified Component.

Link copied to clipboard
fun <T : Component> Entity.hasNot(mapper: ComponentMapper<T>): Boolean

Checks whether the Entity does not have the specified Component.

Link copied to clipboard
inline fun <T : Component> mapperFor(): ComponentMapper<T>

Creates a ComponentMapper for the specified Component type.

Link copied to clipboard
inline fun IntervalIteratingSystem.onEntityAdded(priority: Int = 0, crossinline onAdded: (entity: Entity) -> Unit): EntityAdditionListener

A wrapper for Engine.onEntityAdded that uses this IntervalIteratingSystem's Family as a filter for the EntityAdditionListener.

inline fun IteratingSystem.onEntityAdded(priority: Int = 0, crossinline onAdded: (entity: Entity) -> Unit): EntityAdditionListener

A wrapper for Engine.onEntityAdded that uses this IteratingSystem's Family as a filter for the EntityAdditionListener.

inline fun SortedIteratingSystem.onEntityAdded(priority: Int = 0, crossinline onAdded: (entity: Entity) -> Unit): EntityAdditionListener

A wrapper for Engine.onEntityAdded that uses this SortedIteratingSystem's Family as a filter for the EntityAdditionListener.

inline fun Engine.onEntityAdded(family: Family = anyFamily, priority: Int = 0, crossinline onAdded: (entity: Entity) -> Unit): EntityAdditionListener

Adds an EntityAdditionListener to this Engine and returns a reference to the new listener instance. The listener calls onAdded lambda every time an entity addition event is triggered.

Link copied to clipboard
inline fun IntervalIteratingSystem.onEntityRemoved(priority: Int = 0, crossinline onRemoved: (entity: Entity) -> Unit): EntityRemovalListener

A wrapper for Engine.onEntityRemoved that uses this IntervalIteratingSystem's Family as a filter for the EntityRemovalListener.

inline fun IteratingSystem.onEntityRemoved(priority: Int = 0, crossinline onRemoved: (entity: Entity) -> Unit): EntityRemovalListener

A wrapper for Engine.onEntityRemoved that uses this IteratingSystem's Family as a filter for the EntityRemovalListener.

inline fun SortedIteratingSystem.onEntityRemoved(priority: Int = 0, crossinline onRemoved: (entity: Entity) -> Unit): EntityRemovalListener

A wrapper for Engine.onEntityRemoved that uses this SortedIteratingSystem's Family as a filter for the EntityRemovalListener.

inline fun Engine.onEntityRemoved(family: Family = anyFamily, priority: Int = 0, crossinline onRemoved: (entity: Entity) -> Unit): EntityRemovalListener

Adds an EntityRemovalListener to this Engine and returns a reference to the new listener instance. The listener calls onRemoved lambda every time an entity addition event is triggered.

Link copied to clipboard
fun oneOf(vararg components: KClass<out Component>): Family.Builder
Link copied to clipboard
fun Family.Builder.oneOf(vararg components: KClass<out Component>): Family.Builder
Link copied to clipboard
inline fun <T : Component> optionalPropertyFor(mapper: ComponentMapper<T> = mapperFor()): OptionalComponentDelegate<T>

Returns a delegated property for the Entity class to access the given Component. Allows accessing and setting optional components assigned to entities with the property syntax. Attempting to assign a null value to the property will remove the component it from the entity.

Link copied to clipboard
operator fun Entity.plusAssign(component: Component)

Adds a constructed Component to this Entity. If a Component of the same type exists, it will be replaced.

Link copied to clipboard
inline fun <T : Component> propertyFor(mapper: ComponentMapper<T> = mapperFor()): ComponentDelegate<T>

Returns a delegated property for the Entity class to access the given Component. Allows accessing and setting mandatory components assigned to entities with the property syntax.

Link copied to clipboard
inline fun <T : Component> Entity.remove(): Component?

Removes the specified Component from the Entity.

Link copied to clipboard
inline fun <T : Component> tagFor(component: T): TagDelegate<T>
inline fun <T : Component> tagFor(singleton: Boolean = true): TagDelegate<T>
inline fun <T : Component> tagFor(singleton: Boolean = true, noinline provider: () -> T): TagDelegate<T>

Returns a delegated property for the Entity class that check if the given Component is present within the entity. Changing the boolean value of the property will either add or remove the component from the entity, depending on whether the value is true or false respectively.

Link copied to clipboard
inline fun <T : Component> EngineEntity.with(configure: T.() -> Unit = {}): T

Get or creates an instance of the component T and adds it to this entity.