Finish replacement of sortOn with safeMinimumBy, regress door space leak

This commit is contained in:
2021-07-20 05:40:57 +02:00
parent 8bc5b49a3c
commit 40ee81aff9
4 changed files with 10 additions and 16 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ import Dodge.Data
import Dodge.Base
import Geometry
import Data.Maybe
--import Data.Maybe
import Data.List
import qualified Data.IntMap.Strict as IM
--import System.Random
@@ -52,7 +52,7 @@ rmSelectedInvItem
rmSelectedInvItem cid w = rmInvItem cid (_crInvSel (_creatures w IM.! cid)) w
-- for now, left are floor items, right are buttons
closestActiveObject :: World -> Maybe (Either FloorItem Button)
closestActiveObject w = listToMaybe $ sortOn (dist ypos . pos) actObjs
closestActiveObject w = safeMinimumOn (dist ypos . pos) actObjs
where
ypos = _crPos $ you w
actObjs = filter (\obj -> dist ypos (pos obj) < 40 && hasLOS ypos (pos obj) w)