Allow creatures to path around chasms

This commit is contained in:
2025-10-16 23:52:25 +01:00
parent 0481f6e6f2
commit 5ba642c20a
4 changed files with 30 additions and 44 deletions
+7 -3
View File
@@ -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 #-}