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
+1 -2
View File
@@ -251,8 +251,7 @@ sizeSelf x cr w
) )
| otherwise = Nothing | otherwise = Nothing
where where
cr1 = colCrWall' w (cr {_crRad = 10* x}) cr1 = colCrWall w (cr {_crRad = 10* x})
--cr2 = colCrWall w cr1
distR = 120 distR = 120
distortionBulge distortionBulge
| _crRad cr < 10*x = raddist 1.9 | _crRad cr < 10*x = raddist 1.9
+3 -10
View File
@@ -57,9 +57,7 @@ stateUpdate f = foldCr
, invSideEff , invSideEff
, movementSideEff , movementSideEff
, f , f
, internalUpdate -- note that updateMovement needs to be evaluated at the correct moment , internalUpdate
-- wrt any changes in position made by the creature: the
-- oldPos needs to be correctly set
, checkDeath , checkDeath
] ]
@@ -92,11 +90,6 @@ dropByState cr w = foldr (copyInvItemToFloor cr) w $ case cr ^. crState . crDrop
DropSpecific xs -> xs DropSpecific xs -> xs
DropAmount n -> take n $ evalState (shuffle $ IM.keys $ _crInv cr) (_randGen w) 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 :: Creature -> World -> World
doDamage cr w = w doDamage cr w = w
& creatures . ix (_crID cr) . crState . crDamage .~ [] & 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 :: Creature -> Creature
updateMovement cr updateMovement cr
| isFrictionless cr = over crPos (+.+ momentum) $ setOldPos cr | isFrictionless cr = over crPos (+.+ momentum) cr
| otherwise = updateWalkCycle $ setOldPos cr | otherwise = updateWalkCycle cr
where where
momentum' = 0.98 *.* (_crPos cr -.- _crOldPos cr) momentum' = 0.98 *.* (_crPos cr -.- _crOldPos cr)
momentum'' | magV momentum' > 1 = 1 *.* normalizeV momentum' momentum'' | magV momentum' > 1 = 1 *.* normalizeV momentum'
+6
View File
@@ -72,6 +72,7 @@ functionalUpdate cfig w = checkEndGame
. updateIMl _machines _mcUpdate . updateIMl _machines _mcUpdate
. updateIMl _creatures _crUpdate . updateIMl _creatures _crUpdate
-- creatures should be updated early so that crOldPos is set before any position change -- creatures should be updated early so that crOldPos is set before any position change
. over creatures (fmap setOldPos)
. updateCreatureGroups . updateCreatureGroups
. updateBlocks . updateBlocks
. updateSeenWalls . updateSeenWalls
@@ -85,6 +86,11 @@ functionalUpdate cfig w = checkEndGame
where where
(x,y) = cloudZoneOfPoint $ stripZ $ _clPos cl (x,y) = cloudZoneOfPoint $ stripZ $ _clPos cl
setOldPos :: Creature -> Creature
setOldPos cr = cr
& crOldPos .~ _crPos cr
& crOldDir .~ _crDir cr
-- hack -- hack
--updateRandGen :: World -> World --updateRandGen :: World -> World
--updateRandGen = randGen %~ (snd . (uniform :: StdGen -> (Int,StdGen))) --updateRandGen = randGen %~ (snd . (uniform :: StdGen -> (Int,StdGen)))
+6 -7
View File
@@ -2,7 +2,6 @@
module Dodge.WallCreatureCollisions module Dodge.WallCreatureCollisions
( colCrsWalls ( colCrsWalls
, colCrWall , colCrWall
, colCrWall'
, pushCreatureOutFromWalls , pushCreatureOutFromWalls
, crOnWall , crOnWall
) where ) where
@@ -20,16 +19,16 @@ import Control.Lens
import qualified Data.IntMap.Strict as IM import qualified Data.IntMap.Strict as IM
colCrsWalls :: Configuration -> World -> World colCrsWalls :: Configuration -> World -> World
colCrsWalls cfig w = w & creatures %~ fmap (colCrWall cfig w) colCrsWalls cfig w = w & creatures %~ fmap (noclipCheck cfig w)
colCrWall :: Configuration -> World -> Creature -> Creature noclipCheck :: Configuration -> World -> Creature -> Creature
colCrWall cfig w c noclipCheck cfig w c
| _debug_noclip cfig && _crID c == 0 = c -- for noclip | _debug_noclip cfig && _crID c == 0 = c -- for noclip
| otherwise = colCrWall' w c | otherwise = colCrWall w c
-- no noclip check, so no need for a configuration file -- no noclip check, so no need for a configuration file
colCrWall' :: World -> Creature -> Creature colCrWall :: World -> Creature -> Creature
colCrWall' w c colCrWall w c
| p1 == p2 = pushOrCrush ls c | p1 == p2 = pushOrCrush ls c
-- | _crPos c' == _crPos c'' = c' -- | _crPos c' == _crPos c'' = c'
-- | otherwise = c & crPos .~ _crOldPos c -- | otherwise = c & crPos .~ _crOldPos c