Improve pathing debugging, work on door pathing

This commit is contained in:
2022-07-03 00:24:25 +01:00
parent 3efd89fa34
commit 67b612fe60
9 changed files with 59 additions and 43 deletions
+10 -16
View File
@@ -160,17 +160,18 @@ drawInspectWall w wl = setLayer DebugLayer $
drawDoorPaths :: World -> Int -> Picture
drawDoorPaths w drid = fromMaybe mempty $ do
paths <- w ^? doors . ix drid . drObstructs
-- path <- listToMaybe paths
-- undefined
return $ foldMap (drawPathEdge . (^. _3)) paths
-- return $ (drawPathEdge . (^. _3)) path
drawPathEdge :: PathEdge -> Picture
drawPathEdge pe = setLayer DebugLayer $ color col $ arrow (_peStart pe) (_peEnd pe)
where
col = case _peObstacles pe of
pos | WallObstacle `Set.member` pos -> blue
| True -> red
drawPathEdge pe = setLayer DebugLayer
$ multiArrow (_peStart pe) (_peEnd pe) green (Set.map obstacleColor (_peObstacles pe))
obstacleColor :: EdgeObstacle -> Color
obstacleColor eo = case eo of
WallObstacle -> cyan
DoorObstacle -> red
AutoDoorObstacle -> yellow
BlockObstacle -> blue
drawWorldSelect :: World -> Picture
drawWorldSelect w = setLayer DebugLayer
@@ -293,15 +294,8 @@ drawWlIDs cfig w = setLayer FixedCoordLayer $ foldMap f (_walls w)
edgeToPic :: [Point2] -> PathEdge -> Picture
edgeToPic poly pe
| not (pointInPolygon sp poly) && not (pointInPolygon ep poly) = mempty
| null $ _peObstacles pe
= anarrow green
| hasobstacle BlockObstacle
= anarrow red
| hasobstacle AutoDoorObstacle = anarrow yellow
| otherwise = anarrow cyan
| otherwise = drawPathEdge pe
where
hasobstacle = (`Set.member` _peObstacles pe)
anarrow col = color col $ arrow sp ep
sp = _peStart pe
ep = _peEnd pe