Implement (partially) updating pathing grid when opening doors

This commit is contained in:
2022-07-02 21:39:33 +01:00
parent 8a612be5fe
commit 46bc135e69
11 changed files with 48 additions and 35 deletions
+3 -3
View File
@@ -118,8 +118,8 @@ addEdges nodemap gr = runIdentity . S.fold_ f (mempty,gr) id
theedge = (g a,g b,PathEdge a b (dist a b) mempty)
g a = nodemap M.! a
obstructPathsCrossing :: Point2 -> Point2 -> World -> ( World, [(Int,Int,PathEdge)])
obstructPathsCrossing sp' ep w =
obstructPathsCrossing :: EdgeObstacle -> Point2 -> Point2 -> World -> ( World, [(Int,Int,PathEdge)])
obstructPathsCrossing obstacletype sp' ep w =
( w & pathGraph %~ updateedges
, runIdentity $ S.toList_ es
)
@@ -128,4 +128,4 @@ obstructPathsCrossing sp' ep w =
edgecrosses (_,_,pe) = isJust $ intersectSegSeg sp' ep (_peStart pe) (_peEnd pe)
updateedges gr = runIdentity $ S.fold_ updateedge gr id es
updateedge gr (x,y,pe)
= insEdge (x,y,pe & peObstacles . at BlockObstacle ?~ ()) $ delEdge (x,y) gr
= insEdge (x,y,pe & peObstacles . at obstacletype ?~ ()) $ delEdge (x,y) gr