Continue to refactor zoning to be more stream-based

This commit is contained in:
2022-06-28 03:21:55 +01:00
parent f6d96ec92c
commit e06527091e
34 changed files with 214 additions and 252 deletions
+1 -1
View File
@@ -108,7 +108,7 @@ drawInspectWalls w = foldMap (drawInspectWall w)
drawInspectWall :: World -> Wall -> Picture
drawInspectWall _ wl = setLayer DebugLayer $
color rose (thickLine 3 [a,b])
<> foldMap (drawZone zoneSize)
<> foldMap (drawZone wallZoneSize)
(runIdentity $ S.toList_ $ zoneOfWall wl)
where
(a,b) = _wlLine wl
+6 -2
View File
@@ -10,6 +10,7 @@ import ShapePicture
import Control.Lens
--import Data.Maybe
import qualified Control.Foldl as L
import qualified Streaming.Prelude as S
--import Data.List
--import qualified Data.IntMap.Strict as IM
wallsToDrawStreams
@@ -20,11 +21,14 @@ wallsToDrawStreams cfig w
= ( wls, wins,spic)
where
f wl = (_wlLine wl, _wlColor wl)
(wls, wins, spic) = L.fold ((,,)
(wls, wins, spic) = runIdentity $ L.purely S.fold_
((,,)
<$> L.prefilter wlOpaqueDraw (L.premap f L.list)
<*> L.prefilter wlSeeThroughDraw (L.premap f L.list)
<*> L.premap getWallSPic L.mconcat
) (wallsDoubleScreen cfig w)
) (S.concat $ S.mapMaybe g $ zoneOfSight wallZoneSize w)
g (V2 i j) = w ^? wallsZone . znObjects . ix i . ix j
wlOpaqueDraw :: Wall -> Bool
wlOpaqueDraw wl = wlIsOpaque wl && _wlDraw wl
wlSeeThroughDraw :: Wall -> Bool