Allow creatures to path around chasms
This commit is contained in:
@@ -37,6 +37,7 @@ module Dodge.Base.Collide (
|
||||
collide3,
|
||||
) where
|
||||
|
||||
import Data.Monoid
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import qualified Data.IntSet as IS
|
||||
@@ -326,10 +327,13 @@ hasLOSIndirect p1 p2 =
|
||||
|
||||
isWalkable :: Point2 -> Point2 -> World -> Bool
|
||||
{-# INLINE isWalkable #-}
|
||||
isWalkable p1 p2 =
|
||||
not
|
||||
isWalkable p1 p2 w =
|
||||
(not
|
||||
. collidePointTestFilter (not . (^?! wlPathable)) p1 p2
|
||||
. wlsNearSeg p1 p2
|
||||
. wlsNearSeg p1 p2 $ w)
|
||||
&& not (getAny $ foldMap f (w ^. cWorld . chasms))
|
||||
where
|
||||
f = foldMap (Any . isJust . uncurry (intersectSegSeg p1 p2)) . loopPairs
|
||||
|
||||
canSee :: Int -> Int -> World -> Bool
|
||||
{-# INLINE canSee #-}
|
||||
|
||||
Reference in New Issue
Block a user