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
+16 -16
View File
@@ -4,7 +4,7 @@ Find which objects lie upon a line.
-}
module Dodge.WorldEvent.ThingsHit
( thingsHit
, wallsHit
-- , wallsHit
, thingHit
, thingsHitExceptCr
)
@@ -57,18 +57,18 @@ thingsHitExceptCr (Just cid) sp ep = S.filter crNotCid . thingsHit sp ep
crNotCid (_,Left cr) = _crID cr /= cid
crNotCid _ = True
wallsHit
:: Point2 -- ^ Line start point
-> Point2 -- ^ Line end point
-> World
-> [(Point2, Wall)]
wallsHit sp ep w
| sp == ep = []
| otherwise = sortOn (dist sp . fst) wls
where
wls = IM.elems $ wallsOnLineHit sp ep
$ IM.unions [f b $ f a $ _znObjects $ _wallsZone w
| a<-[x-1,x,x+1] , b<-[y-1,y,y+1]]
-- $ _walls w
(x,y) = zoneOfPoint (0.5 *.* (sp +.+ ep))
f i = fromMaybe IM.empty . IM.lookup i
--wallsHit
-- :: Point2 -- ^ Line start point
-- -> Point2 -- ^ Line end point
-- -> World
-- -> [(Point2, Wall)]
--wallsHit sp ep w
-- | sp == ep = []
-- | otherwise = sortOn (dist sp . fst) wls
-- where
-- wls = IM.elems $ wallsOnLineHit sp ep
-- $ IM.unions [f b $ f a $ _znObjects $ _wallsZone w
-- | a<-[x-1,x,x+1] , b<-[y-1,y,y+1]]
-- -- $ _walls w
-- V2 x y = wallZoneOfPoint (0.5 *.* (sp +.+ ep))
-- f i = fromMaybe IM.empty . IM.lookup i