Further simplify walk cycle

This commit is contained in:
2025-06-19 14:01:59 +01:00
parent c035f82b0e
commit 4f0fa95e13
+8 -2
View File
@@ -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,7 +27,7 @@ normalGait = \case
WasRightForward -> LeftForward
footstepSideEffect :: Creature -> World -> World
footstepSideEffect cr = over (cWorld . lWorld . creatures . ix (cr ^. crID) . crStance) updateWalkCycle .
footstepSideEffect cr =
case cr ^. crStance . carriage of
Walking x ff
| x > cr ^. crStance . strideLength ->
@@ -32,6 +36,8 @@ footstepSideEffect cr = over (cWorld . lWorld . creatures . ix (cr ^. crID) . cr
(cr ^. crPos)
(chooseFootSound ff)
Nothing
.
over (cWorld . lWorld . creatures . ix (cr ^. crID) . crStance . carriage) resetStride
_ -> id
chooseFootSound :: FootForward -> SoundID