Further simplify walk cycle

This commit is contained in:
2025-06-19 14:01:59 +01:00
parent c035f82b0e
commit 4f0fa95e13
+17 -11
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,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