From 395aa7d1c312e495517701be11c21425d9a5838e Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 26 Oct 2025 17:25:13 -0700 Subject: Checkpoint --- .../kotlin/coffee/liz/ecs/input/InputSystem.kt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 composeApp/src/commonMain/kotlin/coffee/liz/ecs/input/InputSystem.kt (limited to 'composeApp/src/commonMain/kotlin/coffee/liz/ecs/input/InputSystem.kt') diff --git a/composeApp/src/commonMain/kotlin/coffee/liz/ecs/input/InputSystem.kt b/composeApp/src/commonMain/kotlin/coffee/liz/ecs/input/InputSystem.kt new file mode 100644 index 0000000..6dc8256 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/coffee/liz/ecs/input/InputSystem.kt @@ -0,0 +1,23 @@ +package coffee.liz.ecs.input + +import coffee.liz.ecs.System +import coffee.liz.ecs.TickedSystem +import coffee.liz.ecs.World +import kotlin.time.Duration + +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()) + } + } +} \ No newline at end of file -- cgit v1.2.3-70-g09d2