summaryrefslogtreecommitdiff
path: root/composeApp/src/commonMain/kotlin/coffee/liz/ecs/animation/AnimationSystem.kt
diff options
context:
space:
mode:
Diffstat (limited to 'composeApp/src/commonMain/kotlin/coffee/liz/ecs/animation/AnimationSystem.kt')
-rw-r--r--composeApp/src/commonMain/kotlin/coffee/liz/ecs/animation/AnimationSystem.kt14
1 files changed, 11 insertions, 3 deletions
diff --git a/composeApp/src/commonMain/kotlin/coffee/liz/ecs/animation/AnimationSystem.kt b/composeApp/src/commonMain/kotlin/coffee/liz/ecs/animation/AnimationSystem.kt
index 7968250..db64ac6 100644
--- a/composeApp/src/commonMain/kotlin/coffee/liz/ecs/animation/AnimationSystem.kt
+++ b/composeApp/src/commonMain/kotlin/coffee/liz/ecs/animation/AnimationSystem.kt
@@ -7,8 +7,13 @@ import kotlin.time.Duration
/**
* Updates animation playback state for all [Animator] components in [World].
*/
-class AnimationSystem(animationTickRate: Duration) : TickedSystem(animationTickRate) {
- override fun update(world: World, ticks: Int) {
+class AnimationSystem(
+ animationTickRate: Duration,
+) : TickedSystem(animationTickRate) {
+ override fun update(
+ world: World,
+ ticks: Int,
+ ) {
world.query(Animator::class).forEach { entity ->
val animator = entity.get(Animator::class)
if (!animator.playing) return@forEach
@@ -30,7 +35,10 @@ class AnimationSystem(animationTickRate: Duration) : TickedSystem(animationTickR
/**
* Advances the animation to the next frame based on loop mode.
*/
- private fun advanceFrame(animator: Animator, clip: AnimationClip) {
+ private fun advanceFrame(
+ animator: Animator,
+ clip: AnimationClip,
+ ) {
animator.frameIndex += animator.direction.step
when (clip.loopMode) {