Start to make wall flags/pathing interaction more sensible

This commit is contained in:
2025-10-23 11:35:24 +01:00
parent 9e6534b8f4
commit fc7c4d6468
18 changed files with 167 additions and 145 deletions
+5 -4
View File
@@ -15,6 +15,7 @@ module Dodge.Path (
getEdgesCrossing,
) where
import qualified Data.Set as S
import qualified Algorithm.Search as AS
import Control.Lens
--import Data.Bifunctor
@@ -82,7 +83,7 @@ makePathBetween :: Point2 -> Point2 -> World -> Maybe [Int]
makePathBetween = makePathUsing $ not . pathEdgeObstructed
pathEdgeObstructed :: Set.Set EdgeObstacle -> Bool
pathEdgeObstructed pe = any (`Set.member` pe) [DoorObstacle, BlockObstacle, ChasmObstacle]
pathEdgeObstructed pe = any (`Set.member` pe) [WallObstacle WallNotAutoOpen, ChasmObstacle]
walkableNodeNear :: World -> Point2 -> Maybe Int
{-# INLINE walkableNodeNear #-}
@@ -129,17 +130,17 @@ pairsToIncGraph pairs =
ps = Set.toList $ Set.map fst pairs <> Set.map snd pairs
obstructPathsCrossing ::
EdgeObstacle ->
S.Set EdgeObstacle ->
Point2 ->
Point2 ->
World ->
(World, [(Int,Int)])
obstructPathsCrossing obstacletype s e w =
obstructPathsCrossing obs s e w =
( w & cWorld . incGraph %~ updateincedges
, inces
)
where
updateincedge = flip $ updateEdge (at obstacletype ?~ ())
updateincedge = flip $ updateEdge (S.union obs)
updateincedges gr = foldl' updateincedge gr inces
inces = filter inedgecrosses $ nearSeg peZoneSize _incEdgeZoning s e w
inedgecrosses (i, j) = isJust $ intersectSegSeg s e (f i) (f j)