From 4f0fa95e13aa8e269e88b4f78e38d41dd43780e7 Mon Sep 17 00:00:00 2001 From: justin Date: Thu, 19 Jun 2025 14:01:59 +0100 Subject: [PATCH] Further simplify walk cycle --- src/Dodge/Creature/State/WalkCycle.hs | 28 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/Dodge/Creature/State/WalkCycle.hs b/src/Dodge/Creature/State/WalkCycle.hs index 380c6fe42..395902b03 100644 --- a/src/Dodge/Creature/State/WalkCycle.hs +++ b/src/Dodge/Creature/State/WalkCycle.hs @@ -1,7 +1,7 @@ {-# LANGUAGE LambdaCase #-} module Dodge.Creature.State.WalkCycle ( - updateWalkCycle, + -- updateWalkCycle, footstepSideEffect, ) where @@ -15,6 +15,10 @@ updateWalkCycle s = case s ^. carriage of Walking x ff | x > s ^. strideLength -> s & carriage .~ Walking 0 (normalGait ff) _ -> s +resetStride :: Carriage -> Carriage +resetStride (Walking _ ff) = Walking 0 (normalGait ff) +resetStride x = x + normalGait :: FootForward -> FootForward normalGait = \case LeftForward -> RightForward @@ -23,16 +27,18 @@ normalGait = \case WasRightForward -> LeftForward footstepSideEffect :: Creature -> World -> World -footstepSideEffect cr = over (cWorld . lWorld . creatures . ix (cr ^. crID) . crStance) updateWalkCycle . - case cr ^. crStance . carriage of - Walking x ff - | x > cr ^. crStance . strideLength -> - soundMultiFrom - [FootstepSound i | i <- [0 .. 10]] - (cr ^. crPos) - (chooseFootSound ff) - Nothing - _ -> id +footstepSideEffect cr = + case cr ^. crStance . carriage of + Walking x ff + | x > cr ^. crStance . strideLength -> + soundMultiFrom + [FootstepSound i | i <- [0 .. 10]] + (cr ^. crPos) + (chooseFootSound ff) + Nothing + . + over (cWorld . lWorld . creatures . ix (cr ^. crID) . crStance . carriage) resetStride + _ -> id chooseFootSound :: FootForward -> SoundID chooseFootSound LeftForward = foot1S