Further simplify walk cycle
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{-# LANGUAGE LambdaCase #-}
|
{-# LANGUAGE LambdaCase #-}
|
||||||
|
|
||||||
module Dodge.Creature.State.WalkCycle (
|
module Dodge.Creature.State.WalkCycle (
|
||||||
updateWalkCycle,
|
-- updateWalkCycle,
|
||||||
footstepSideEffect,
|
footstepSideEffect,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@@ -15,6 +15,10 @@ updateWalkCycle s = case s ^. carriage of
|
|||||||
Walking x ff | x > s ^. strideLength -> s & carriage .~ Walking 0 (normalGait ff)
|
Walking x ff | x > s ^. strideLength -> s & carriage .~ Walking 0 (normalGait ff)
|
||||||
_ -> s
|
_ -> s
|
||||||
|
|
||||||
|
resetStride :: Carriage -> Carriage
|
||||||
|
resetStride (Walking _ ff) = Walking 0 (normalGait ff)
|
||||||
|
resetStride x = x
|
||||||
|
|
||||||
normalGait :: FootForward -> FootForward
|
normalGait :: FootForward -> FootForward
|
||||||
normalGait = \case
|
normalGait = \case
|
||||||
LeftForward -> RightForward
|
LeftForward -> RightForward
|
||||||
@@ -23,16 +27,18 @@ normalGait = \case
|
|||||||
WasRightForward -> LeftForward
|
WasRightForward -> LeftForward
|
||||||
|
|
||||||
footstepSideEffect :: Creature -> World -> World
|
footstepSideEffect :: Creature -> World -> World
|
||||||
footstepSideEffect cr = over (cWorld . lWorld . creatures . ix (cr ^. crID) . crStance) updateWalkCycle .
|
footstepSideEffect cr =
|
||||||
case cr ^. crStance . carriage of
|
case cr ^. crStance . carriage of
|
||||||
Walking x ff
|
Walking x ff
|
||||||
| x > cr ^. crStance . strideLength ->
|
| x > cr ^. crStance . strideLength ->
|
||||||
soundMultiFrom
|
soundMultiFrom
|
||||||
[FootstepSound i | i <- [0 .. 10]]
|
[FootstepSound i | i <- [0 .. 10]]
|
||||||
(cr ^. crPos)
|
(cr ^. crPos)
|
||||||
(chooseFootSound ff)
|
(chooseFootSound ff)
|
||||||
Nothing
|
Nothing
|
||||||
_ -> id
|
.
|
||||||
|
over (cWorld . lWorld . creatures . ix (cr ^. crID) . crStance . carriage) resetStride
|
||||||
|
_ -> id
|
||||||
|
|
||||||
chooseFootSound :: FootForward -> SoundID
|
chooseFootSound :: FootForward -> SoundID
|
||||||
chooseFootSound LeftForward = foot1S
|
chooseFootSound LeftForward = foot1S
|
||||||
|
|||||||
Reference in New Issue
Block a user