Clarify when crOldPos is set

This commit is contained in:
2022-05-18 11:26:47 +01:00
parent 8ad33d2f8b
commit 914cae8212
4 changed files with 16 additions and 19 deletions
+3 -10
View File
@@ -57,9 +57,7 @@ stateUpdate f = foldCr
, invSideEff
, movementSideEff
, f
, internalUpdate -- note that updateMovement needs to be evaluated at the correct moment
-- wrt any changes in position made by the creature: the
-- oldPos needs to be correctly set
, internalUpdate
, checkDeath
]
@@ -92,11 +90,6 @@ dropByState cr w = foldr (copyInvItemToFloor cr) w $ case cr ^. crState . crDrop
DropSpecific xs -> xs
DropAmount n -> take n $ evalState (shuffle $ IM.keys $ _crInv cr) (_randGen w)
setOldPos :: Creature -> Creature
setOldPos cr = cr
& crOldPos .~ _crPos cr
& crOldDir .~ _crDir cr
doDamage :: Creature -> World -> World
doDamage cr w = w
& creatures . ix (_crID cr) . crState . crDamage .~ []
@@ -185,8 +178,8 @@ weaponReloadSounds cr w = case cr ^? crInv . ix (_crInvSel cr) . itConsumption o
updateMovement :: Creature -> Creature
updateMovement cr
| isFrictionless cr = over crPos (+.+ momentum) $ setOldPos cr
| otherwise = updateWalkCycle $ setOldPos cr
| isFrictionless cr = over crPos (+.+ momentum) cr
| otherwise = updateWalkCycle cr
where
momentum' = 0.98 *.* (_crPos cr -.- _crOldPos cr)
momentum'' | magV momentum' > 1 = 1 *.* normalizeV momentum'