ktx icon indicating copy to clipboard operation
ktx copied to clipboard

Property delegate for component boolean flags in Ashley

Open czyzby opened this issue 3 years ago • 0 comments

The goal of this task is to add property delegates to ktx-ashley module to support checking for existence of specific components via entity properties. For example:

class Visible: Component
var Entity.isVisible: Boolean by tagFor<Visible>()

// Usage examples:
val engine = Engine()
val entity = Entity()
engine.addEntity(entity)

println(entity.isVisible) // false

// Adds a Visible component to entity:
entity.isVisible = true
println(entity.isVisible) // true

// Removes the Visible component from entity:
entity.isVisible = false
println(entity.isVisible) // false

Originally posted by @pylvain July 30, 2022, see #421

czyzby avatar Jul 30 '22 10:07 czyzby