Introduce safeMinimumOn

This commit is contained in:
jgk
2021-07-20 04:34:28 +02:00
parent 6905c6f154
commit 58b2c8a842
5 changed files with 59 additions and 28 deletions
+4 -2
View File
@@ -95,6 +95,9 @@ wallsOnCirc p r = IM.filter f
where
f wl = uncurry circOnSeg (_wlLine wl) p r
wallsOnScreen :: World -> IM.IntMap Wall
wallsOnScreen w = wallsNearZones (zoneOfScreen w) w
allWalls :: World -> IM.IntMap Wall
allWalls w = IM.unions $ concatMap IM.elems $ IM.elems $ _wallsZone w
@@ -202,8 +205,7 @@ reflectPointCreature p1 p2 cr = case collidePointCirc p1 p2 (_crRad cr) (_crPos
{- | TODO: determine precisely what this does. -}
reflectPointCreatures :: Point2 -> Point2 -> IM.IntMap Creature -> Maybe (Point2,Point2,Int)
reflectPointCreatures p1 p2 cs
= listToMaybe
. sortOn f
= safeMinimumOn f
. IM.elems
$ IM.mapMaybe (reflectPointCreature p1 p2) cs
where