From a8e5e723b7e1891c9b352261a3ee4c3d3563e8cf Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 26 Oct 2025 21:38:22 -0700 Subject: Checkpoint two --- .../kotlin/coffee/liz/ecs/input/InputSystem.kt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (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 index 6dc8256..f80c1ad 100644 --- a/composeApp/src/commonMain/kotlin/coffee/liz/ecs/input/InputSystem.kt +++ b/composeApp/src/commonMain/kotlin/coffee/liz/ecs/input/InputSystem.kt @@ -1,16 +1,27 @@ package coffee.liz.ecs.input -import coffee.liz.ecs.System 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 + pollRate: Duration, ) : TickedSystem(pollRate) { private val activeInputs = mutableMapOf() - override fun update(world: World, state: Outside, ticks: Int) { + override fun update( + world: World, + state: Outside, + ticks: Int, + ) { state.inputState.activeInputs.forEach { activeInputs[it] = (activeInputs[it] ?: 0) + ticks } @@ -20,4 +31,4 @@ class InputSystem( it.get(Controlled::class).handleInput(activeInputs.toMap()) } } -} \ No newline at end of file +} -- cgit v1.2.3-70-g09d2