Only update stride amount when actually moving

This commit is contained in:
2025-12-24 22:02:43 +00:00
parent 8e484e37a9
commit 27cb05b8f7
6 changed files with 198 additions and 164 deletions
+11
View File
@@ -3,6 +3,7 @@
module Dodge.Update (updateUniverse) where
import Dodge.Creature.MoveType
import Dodge.Render.List
import Data.Foldable
import qualified Data.Set as S
@@ -251,6 +252,7 @@ functionalUpdate =
. over uvWorld (cWorld . lWorld . lClock +~ 1)
. over uvWorld updateDistortions
. over uvWorld updateCreatureSoundPositions
. over uvWorld updateCreatureStrides
. colCrsWalls
. over uvWorld simpleCrSprings
. over uvWorld updateDoors
@@ -307,6 +309,15 @@ functionalUpdate =
. updateAimPos
. over uvWorld updatePastWorlds -- it might be possible to do this without storing stuff such as the temporary lights/flares etc
updateCreatureStrides :: World -> World
updateCreatureStrides w = foldl' updateCreatureStride w $ w ^. cWorld . lWorld . creatures
updateCreatureStride :: World -> Creature -> World
updateCreatureStride w cr = w & cWorld . lWorld . creatures . ix (cr ^. crID) . crStance . carriage . strideAmount +~ d
where
s = fromMaybe 0 $ crMvType cr ^? mvSpeed
d = min s . norm $ cr ^. crPos - cr ^. crOldPos
updateAimPos :: Universe -> Universe
updateAimPos u =
u & uvWorld . cWorld . lWorld . lAimPos