This commit is contained in:
2022-06-25 21:45:17 +01:00
parent c56e53d33f
commit 4eaa31bf32
9 changed files with 24 additions and 23 deletions
+6 -6
View File
@@ -59,13 +59,13 @@ hasLOS :: Point2 -> Point2 -> World -> Bool
{-# INLINE hasLOS #-}
hasLOS p1 p2 = not
. collidePointTestFilter (const True) p1 p2
. wallsAlongLineStream p1 p2
. wallsAlongLine p1 p2
hasButtonLOS :: Point2 -> Point2 -> World -> Bool
{-# INLINE hasButtonLOS #-}
hasButtonLOS p1 p2 = not
. collidePointTestFilter (not . _wlTouchThrough) p1 p2
. wallsAlongLineStream p1 p2
. wallsAlongLine p1 p2
--hitPointLines
-- :: Point2
@@ -137,7 +137,7 @@ collidePointWallsFilterStream :: (Wall -> Bool) -> Point2 -> Point2 -> World ->
collidePointWallsFilterStream t sp ep = runIdentity
. S.fold_ findPoint (ep, Nothing) id
. S.filter t
. wallsAlongLineStream sp ep
. wallsAlongLine sp ep
where
findPoint (p,mwl) wl = maybe (p,mwl) (,Just wl) . uncurry (intersectSegSeg sp p) . _wlLine $ wl
@@ -155,7 +155,7 @@ visibleWalls sp ep = S.take 1 <=< -- hlint, was using join and fmap
( S.span (not . wlIsOpaque . snd)
. orderStreamOn (dist sp . fst)
. S.mapMaybe f
. wallsAlongLineStream sp ep )
. wallsAlongLine sp ep )
where
f wl = uncurry (intersectSegSeg sp ep) (_wlLine wl) <&> (,wl)
@@ -206,12 +206,12 @@ ssfold p f a0 xs = foldr (\x g a -> if p a then a else g (f a x)) id xs a0
hasLOSIndirect :: Point2 -> Point2 -> World -> Bool
hasLOSIndirect p1 p2 = not
. collidePointTestFilter wlIsOpaque p1 p2
. wallsAlongLineStream p1 p2
. wallsAlongLine p1 p2
isWalkable :: Point2 -> Point2 -> World -> Bool
isWalkable p1 p2 = not
. collidePointTestFilter (not . (^?! wlPathable)) p1 p2
. wallsAlongLineStream p1 p2
. wallsAlongLine p1 p2
canSee :: Int -> Int -> World -> Bool
canSee i j w = hasLOS p1 p2 w