package coffee.liz.ecs.input import coffee.liz.ecs.TickedSystem import coffee.liz.ecs.World import kotlin.time.Duration data class InputState( val activeInputs: Set, ) interface InputProvider { val inputState: InputState } class InputSystem( pollRate: Duration, ) : TickedSystem(pollRate) { private val activeInputs = mutableMapOf() override fun update( world: World, state: Outside, ticks: Int, ) { state.inputState.activeInputs.forEach { activeInputs[it] = (activeInputs[it] ?: 0) + ticks } activeInputs.keys.retainAll(state.inputState.activeInputs) world.query(Controlled::class).forEach { it.get(Controlled::class).handleInput(activeInputs.toMap()) } } }