This commit is contained in:
2025-06-19 22:55:46 +01:00
parent 4f0fa95e13
commit fe1ac8f5a4
2 changed files with 101 additions and 118 deletions
+13 -20
View File
@@ -1,8 +1,7 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Creature.State.WalkCycle (
-- updateWalkCycle,
footstepSideEffect,
updateWalkCycle,
) where
import Control.Lens
@@ -10,10 +9,18 @@ import Dodge.Data.World
import Dodge.SoundLogic
import Sound.Data
updateWalkCycle :: Stance -> Stance
updateWalkCycle s = case s ^. carriage of
Walking x ff | x > s ^. strideLength -> s & carriage .~ Walking 0 (normalGait ff)
_ -> s
updateWalkCycle :: Creature -> World -> World
updateWalkCycle 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
resetStride :: Carriage -> Carriage
resetStride (Walking _ ff) = Walking 0 (normalGait ff)
@@ -26,20 +33,6 @@ normalGait = \case
RightForward -> LeftForward
WasRightForward -> LeftForward
footstepSideEffect :: Creature -> World -> World
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
chooseFootSound _ = foot2S