Tweak creature update
This commit is contained in:
@@ -1,37 +1,35 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
module Dodge.Creature.State.WalkCycle (
|
||||
updateWalkCycle,
|
||||
) where
|
||||
module Dodge.Creature.State.WalkCycle (updateWalkCycle) where
|
||||
|
||||
import Control.Lens
|
||||
import Dodge.Data.World
|
||||
import Dodge.SoundLogic
|
||||
import Sound.Data
|
||||
|
||||
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
|
||||
updateWalkCycle :: Int -> World -> World
|
||||
updateWalkCycle cid w
|
||||
| Just cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
, Walking x ff <- cr ^. crStance . carriage
|
||||
, x > cr ^. crStance . strideLength =
|
||||
w
|
||||
& soundMultiFrom
|
||||
[FootstepSound i | i <- [0 .. 10]]
|
||||
(cr ^. crPos)
|
||||
(chooseFootSound ff)
|
||||
Nothing
|
||||
& over (cWorld . lWorld . creatures . ix cid . crStance . carriage) resetStride
|
||||
| otherwise = w
|
||||
|
||||
resetStride :: Carriage -> Carriage
|
||||
resetStride (Walking _ ff) = Walking 0 (normalGait ff)
|
||||
resetStride x = x
|
||||
resetStride = \case
|
||||
Walking _ ff -> Walking 0 (normalGait ff)
|
||||
x -> x
|
||||
|
||||
normalGait :: FootForward -> FootForward
|
||||
normalGait = \case
|
||||
LeftForward -> RightForward
|
||||
WasLeftForward -> RightForward
|
||||
RightForward -> LeftForward
|
||||
WasRightForward -> LeftForward
|
||||
|
||||
chooseFootSound :: FootForward -> SoundID
|
||||
chooseFootSound LeftForward = foot1S
|
||||
|
||||
Reference in New Issue
Block a user