More streaming refactoring

This commit is contained in:
2022-06-25 22:31:49 +01:00
parent 4eaa31bf32
commit 3c7ea4d73b
12 changed files with 88 additions and 28 deletions
+7 -5
View File
@@ -18,6 +18,8 @@ import Data.Function
import Control.Lens
import qualified Data.IntMap.Strict as IM
import qualified Streaming.Prelude as S
colCrsWalls :: Configuration -> World -> World
colCrsWalls cfig w = w & creatures %~ fmap (noclipCheck cfig w)
@@ -42,9 +44,9 @@ colCrWall w c
rad = _crRad c + wallBuffer
p1 = _crOldPos c
p2 = _crPos c
ls = IM.elems $ _wlLine <$> wls
ls = _wlLine <$> wls
ls' = filter (uncurry $ isLHS p1) ls
wls = IM.filter (not . _wlWalkable) $ wallsNearPoint p2 w
wls = runIdentity . S.toList_ . S.filter (not . _wlWalkable) $ wallsNearPoint p2 w
--wallPoints = map fst ls
-- the amount to push creatures out from walls, extra to their radius
@@ -81,9 +83,9 @@ pushOrCrush wls cr = case mapMaybe (pushOutFromWall (_crRad cr) cpos) wls of
-- note the inclusion of endpoints in circOnSeg
crOnWall :: Creature -> World -> Bool
crOnWall cr = any (\(a,b) -> circOnSeg a b p r)
. fmap _wlLine
. IM.filter (not . _wlWalkable)
crOnWall cr = runIdentity
. S.any_ (uncurry (circOnSeg' p r) . _wlLine)
. S.filter (not . _wlWalkable)
. wallsNearPoint p
where
p = _crPos cr