optionalPropertyFor

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.

Passing a mapper is optional; if no value is given, it will create a new ComponentMapper for the chosen Component class.

See also