This commit is contained in:
2025-06-20 23:11:40 +01:00
parent b45d6817f5
commit df3fde5d3e
+5 -11
View File
@@ -28,13 +28,7 @@ import Geometry
import qualified ListHelp as List import qualified ListHelp as List
{- List those objects that appear on a line. -} {- List those objects that appear on a line. -}
thingsHit :: thingsHit :: Point2 -> Point2 -> World -> [(Point2, Either Creature Wall)]
-- | Line start point
Point2 ->
-- | Line end point
Point2 ->
World ->
[(Point2, Either Creature Wall)]
thingsHit sp ep w = thingsHit sp ep w =
List.mergeOn List.mergeOn
(dist sp . fst) (dist sp . fst)
@@ -68,7 +62,8 @@ thingHit :: Point2 -> Point2 -> World -> Maybe (Point2, Either Creature Wall)
thingHit sp ep = listToMaybe . thingsHit sp ep thingHit sp ep = listToMaybe . thingsHit sp ep
crHit :: Point2 -> Point2 -> World -> Maybe (Point2,Creature) 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. {- List objects that appear on a line.
Can filter out a creature. -} Can filter out a creature. -}
@@ -82,10 +77,9 @@ thingsHitExceptCr ::
World -> World ->
[(Point2, Either Creature Wall)] [(Point2, Either Creature Wall)]
thingsHitExceptCr Nothing sp ep = thingsHit sp ep 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 where
crNotCid (_, Left cr) = _crID cr /= cid t = (Just cid /=) . (^? _2 . _Left . crID)
crNotCid _ = True
wlsHit :: Point2 -> Point2 -> World -> [(Point2, Wall)] wlsHit :: Point2 -> Point2 -> World -> [(Point2, Wall)]
wlsHit sp ep wlsHit sp ep