From df3fde5d3ea28b0fda3053aa5a1e146ba91471b4 Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 20 Jun 2025 23:11:40 +0100 Subject: [PATCH] Cleanup --- src/Dodge/WorldEvent/ThingsHit.hs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/Dodge/WorldEvent/ThingsHit.hs b/src/Dodge/WorldEvent/ThingsHit.hs index f57ecac32..9c4c94a2f 100644 --- a/src/Dodge/WorldEvent/ThingsHit.hs +++ b/src/Dodge/WorldEvent/ThingsHit.hs @@ -28,13 +28,7 @@ import Geometry import qualified ListHelp as List {- List those objects that appear on a line. -} -thingsHit :: - -- | Line start point - Point2 -> - -- | Line end point - Point2 -> - World -> - [(Point2, Either Creature Wall)] +thingsHit :: Point2 -> Point2 -> World -> [(Point2, Either Creature Wall)] thingsHit sp ep w = List.mergeOn (dist sp . fst) @@ -68,7 +62,8 @@ thingHit :: Point2 -> Point2 -> World -> Maybe (Point2, Either Creature Wall) thingHit sp ep = listToMaybe . thingsHit sp ep crHit :: Point2 -> Point2 -> World -> Maybe (Point2,Creature) -crHit sp ep = listToMaybe . sortOn (dist sp . fst) . crsHit sp ep +--crHit sp ep = listToMaybe . sortOn (dist sp . fst) . crsHit sp ep +crHit sp ep = listToMaybe . crsHit sp ep {- List objects that appear on a line. Can filter out a creature. -} @@ -82,10 +77,9 @@ thingsHitExceptCr :: World -> [(Point2, Either Creature Wall)] thingsHitExceptCr Nothing sp ep = thingsHit sp ep -thingsHitExceptCr (Just cid) sp ep = filter crNotCid . thingsHit sp ep +thingsHitExceptCr (Just cid) sp ep = filter t . thingsHit sp ep where - crNotCid (_, Left cr) = _crID cr /= cid - crNotCid _ = True + t = (Just cid /=) . (^? _2 . _Left . crID) wlsHit :: Point2 -> Point2 -> World -> [(Point2, Wall)] wlsHit sp ep