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
where
cr1 = colCrWall' w (cr {_crRad = 10* x})
--cr2 = colCrWall w cr1
cr1 = colCrWall w (cr {_crRad = 10* x})
distR = 120
distortionBulge
| _crRad cr < 10*x = raddist 1.9
+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'
+6
View File
@@ -72,6 +72,7 @@ functionalUpdate cfig w = checkEndGame
. updateIMl _machines _mcUpdate
. updateIMl _creatures _crUpdate
-- creatures should be updated early so that crOldPos is set before any position change
. over creatures (fmap setOldPos)
. updateCreatureGroups
. updateBlocks
. updateSeenWalls
@@ -85,6 +86,11 @@ functionalUpdate cfig w = checkEndGame
where
(x,y) = cloudZoneOfPoint $ stripZ $ _clPos cl
setOldPos :: Creature -> Creature
setOldPos cr = cr
& crOldPos .~ _crPos cr
& crOldDir .~ _crDir cr
-- hack
--updateRandGen :: World -> World
--updateRandGen = randGen %~ (snd . (uniform :: StdGen -> (Int,StdGen)))
+6 -7
View File
@@ -2,7 +2,6 @@
module Dodge.WallCreatureCollisions
( colCrsWalls
, colCrWall
, colCrWall'
, pushCreatureOutFromWalls
, crOnWall
) where
@@ -20,16 +19,16 @@ import Control.Lens
import qualified Data.IntMap.Strict as IM
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
colCrWall cfig w c
noclipCheck :: Configuration -> World -> Creature -> Creature
noclipCheck cfig w c
| _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
colCrWall' :: World -> Creature -> Creature
colCrWall' w c
colCrWall :: World -> Creature -> Creature
colCrWall w c
| p1 == p2 = pushOrCrush ls c
-- | _crPos c' == _crPos c'' = c'
-- | otherwise = c & crPos .~ _crOldPos c