summaryrefslogtreecommitdiff
path: root/composeApp/src/commonMain/kotlin/coffee/liz/ecs/input/InputSystem.kt
diff options
context:
space:
mode:
authorElizabeth Hunt <me@liz.coffee>2025-10-26 21:38:22 -0700
committerElizabeth Hunt <me@liz.coffee>2025-10-26 21:39:58 -0700
commita8e5e723b7e1891c9b352261a3ee4c3d3563e8cf (patch)
tree853df79c877d37d7e5d25f52b301aedcc3d5db55 /composeApp/src/commonMain/kotlin/coffee/liz/ecs/input/InputSystem.kt
parent395aa7d1c312e495517701be11c21425d9a5838e (diff)
downloadabstraction-engine-kt-main.tar.gz
abstraction-engine-kt-main.zip
Checkpoint twoHEADmain
Diffstat (limited to 'composeApp/src/commonMain/kotlin/coffee/liz/ecs/input/InputSystem.kt')
-rw-r--r--composeApp/src/commonMain/kotlin/coffee/liz/ecs/input/InputSystem.kt19
1 files changed, 15 insertions, 4 deletions
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<String>,
+)
+
+interface InputProvider {
+ val inputState: InputState
+}
+
class InputSystem<Outside : InputProvider>(
- pollRate: Duration
+ pollRate: Duration,
) : TickedSystem<Outside>(pollRate) {
private val activeInputs = mutableMapOf<String, Int>()
- override fun update(world: World<Outside>, state: Outside, ticks: Int) {
+ override fun update(
+ world: World<Outside>,
+ state: Outside,
+ ticks: Int,
+ ) {
state.inputState.activeInputs.forEach {
activeInputs[it] = (activeInputs[it] ?: 0) + ticks
}
@@ -20,4 +31,4 @@ class InputSystem<Outside : InputProvider>(
it.get(Controlled::class).handleInput(activeInputs.toMap())
}
}
-} \ No newline at end of file
+}