addComponent

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.

Return

a Component instance of the chosen type.

Parameters

T

type of component to add. Must have a no-argument constructor.

See also

Entity.add

Throws

if the engine was unable to create the component.