From 0270d423fde09c89f8b3166db1c5a13a6f0db029 Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 24 Jun 2022 14:30:16 +0100 Subject: [PATCH] Refactor more instances to use streaming --- src/Dodge/Base/Collide.hs | 21 ++++++++++----------- src/Dodge/Floor.hs | 13 +++++++------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Dodge/Base/Collide.hs b/src/Dodge/Base/Collide.hs index 501353ab3..e0503dab2 100644 --- a/src/Dodge/Base/Collide.hs +++ b/src/Dodge/Base/Collide.hs @@ -53,13 +53,15 @@ import qualified Streaming.Prelude as S hasLOS :: Point2 -> Point2 -> World -> Bool {-# INLINE hasLOS #-} -hasLOS p1 p2 = not . pointHitsWalls p1 p2 . wallsAlongLine p1 p2 +hasLOS p1 p2 = not + . collidePointTestFilter (const True) p1 p2 + . wallsAlongLineStream p1 p2 hasButtonLOS :: Point2 -> Point2 -> World -> Bool {-# INLINE hasButtonLOS #-} -hasButtonLOS p1 p2 = not . pointHitsWalls p1 p2 - . IM.filter (not . _wlTouchThrough) - . wallsAlongLine p1 p2 +hasButtonLOS p1 p2 = not + . collidePointTestFilter (not . _wlTouchThrough) p1 p2 + . wallsAlongLineStream p1 p2 --hitPointLines -- :: Point2 @@ -225,9 +227,9 @@ collidePointIndirect' p1 p2 -- the reason for using the dashed version is the hope that this will short -- circuit hasLOSIndirect :: Point2 -> Point2 -> World -> Bool -hasLOSIndirect p1 p2 w = case collidePointIndirect' p1 p2 $ wallsAlongLine p1 p2 w of - Just _ -> False - Nothing -> True +hasLOSIndirect p1 p2 = not + . collidePointTestFilter wlIsOpaque p1 p2 + . wallsAlongLineStream p1 p2 isWalkable :: Point2 -> Point2 -> World -> Bool isWalkable p1 p2 = not @@ -283,10 +285,7 @@ canSee i j w = hasLOS p1 p2 w -- jpos = _crPos (_creatures w IM.! j) canSeeIndirect :: Int -> Int -> World -> Bool -canSeeIndirect i j w = not - $ any (isJust . uncurry (intersectSegSeg ipos jpos) . _wlLine) - $ IM.filter wlIsOpaque - $ wallsAlongLine ipos jpos w +canSeeIndirect i j w = hasLOSIndirect ipos jpos w where ipos = _crPos (_creatures w IM.! i) jpos = _crPos (_creatures w IM.! j) diff --git a/src/Dodge/Floor.hs b/src/Dodge/Floor.hs index 3177431e9..db364a356 100644 --- a/src/Dodge/Floor.hs +++ b/src/Dodge/Floor.hs @@ -44,12 +44,13 @@ initialAnoTree = OnwardList , AnRoom slowDoorRoom , AnTree firstBreather , AnTree $ telRoomLev 1 >>= rToOnward "telRoomLev" . pure . cleatOnward - ] - -extraAnoList :: [Annotation] -extraAnoList = --- , (SpecificRoom . return . tToBTree $ treePost [corridor,corridor,cleatOnward corridor]) - [ AnRoom $ roomCCrits 10 +-- ] +-- +--extraAnoList :: [Annotation] +--extraAnoList = +---- , (SpecificRoom . return . tToBTree $ treePost [corridor,corridor,cleatOnward corridor]) +-- [ AnRoom $ roomCCrits 10 + , AnRoom $ roomCCrits 10 , AnTree $ tToBTree "spawners" <$> spawnerRoom , AnRoom pistolerRoom , AnRoom doubleCorridorBarrels