Move configuration from world to universe

This commit is contained in:
2021-11-28 22:30:47 +00:00
parent 45ba120796
commit 8c5777a1af
29 changed files with 343 additions and 300 deletions
+25 -5
View File
@@ -2,6 +2,7 @@
module Dodge.WallCreatureCollisions
( colCrsWalls
, colCrWall
, colCrWall'
, pushCreatureOutFromWalls
, crOnWall
) where
@@ -18,11 +19,11 @@ import Data.Function
import Control.Lens
import qualified Data.IntMap.Strict as IM
colCrsWalls :: World -> World
colCrsWalls w = w & creatures %~ fmap (colCrWall w)
colCrsWalls :: Configuration -> World -> World
colCrsWalls cfig w = w & creatures %~ fmap (colCrWall cfig w)
colCrWall :: World -> Creature -> Creature
colCrWall w c
colCrWall :: Configuration -> World -> Creature -> Creature
colCrWall cfig w c
| noclipIsOn && _crID c == 0 = c -- for noclip
| p1 == p2 = pushOrCrush ls c
-- | _crPos c' == _crPos c'' = c'
@@ -40,7 +41,26 @@ colCrWall w c
ls = IM.elems $ _wlLine <$> wls
wls = IM.filter (not . _wlWalkable) $ wallsNearPoint p2 w
--wallPoints = map fst ls
noclipIsOn = _debug_noclip $ _config w
noclipIsOn = _debug_noclip cfig
colCrWall' :: World -> Creature -> Creature
colCrWall' w c
| p1 == p2 = pushOrCrush ls c
-- | _crPos c' == _crPos c'' = c'
-- | otherwise = c & crPos .~ _crOldPos c
| otherwise = c'
where
-- c'' = c' & crPos %~ pushOutFromWalls rad ls
--c' = c & crPos %~ pushOutFromWalls' rad (reverse ls)
c' = c & crPos %~ pushOutFromCorners rad ls
. pushOutFromWalls rad ls
. flip (collidePointWalls p1) wls -- check push throughs
rad = _crRad c + wallBuffer
p1 = _crOldPos c
p2 = _crPos c
ls = IM.elems $ _wlLine <$> wls
wls = IM.filter (not . _wlWalkable) $ wallsNearPoint p2 w
--wallPoints = map fst ls
-- the amount to push creatures out from walls, extra to their radius
wallBuffer :: Float