Finish replacement of sortOn with safeMinimumBy, regress door space leak
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
module Dodge.Creature.Action.Flee
|
||||
where
|
||||
import Dodge.Data
|
||||
import Dodge.Base.Collide
|
||||
import Geometry
|
||||
|
||||
import Data.List
|
||||
import Data.Maybe
|
||||
|
||||
retreatPointForFrom
|
||||
:: Float -> World -> Creature -> Point2 -> Maybe Point2
|
||||
retreatPointForFrom d _ cr p
|
||||
= listToMaybe
|
||||
. sortOn (dist cpos)
|
||||
= safeMinimumOn (dist cpos)
|
||||
$ divideCircle 10 p d
|
||||
where
|
||||
cpos = _crPos cr
|
||||
|
||||
@@ -17,7 +17,6 @@ import Picture
|
||||
import Geometry
|
||||
|
||||
import Data.Maybe
|
||||
import Data.List
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
import Control.Monad.Reader
|
||||
@@ -59,7 +58,7 @@ mFlockACC cr w = do
|
||||
&& dist (_crPos cr') tpos > dist cpos tpos
|
||||
-- && circOnSeg (_crPos cr') tpos cpos (_crRad cr + _crRad cr')
|
||||
nearACCs = IM.filter isFarACC $ creaturesNearPointI 3 cpos w
|
||||
acr <- listToMaybe $ sortOn (dist cpos . _crPos) $ IM.elems nearACCs
|
||||
acr <- safeMinimumOn (dist cpos . _crPos) nearACCs
|
||||
let r = _crRad acr + _crRad cr + 10
|
||||
horDir = normalizeV (vNormal (cpos -.- tpos))
|
||||
horShift = if isLHS tpos cpos (_crPos acr)
|
||||
|
||||
Reference in New Issue
Block a user