Continue to work on pathfinding

This commit is contained in:
2025-10-21 15:35:37 +01:00
parent 0b997579ad
commit 6742241e5d
22 changed files with 296 additions and 298 deletions
+2 -4
View File
@@ -4,8 +4,6 @@ module Dodge.Placement.PlaceSpot.Block (
plLineBlock,
) where
import Data.Set (Set)
import qualified Data.Set as Set
import Control.Lens
import qualified Data.IntSet as IS
import Data.List
@@ -115,11 +113,11 @@ plLineBlock basePane blwidth a b gw =
-- | Must be done after inserting the block
insertWalls :: Int -> [Wall] -> World -> World
insertWalls blid wls w = w' & cWorld . lWorld . blocks . ix blid . blObstructs .~ Set.unions paths
insertWalls blid wls w = w' & cWorld . lWorld . blocks . ix blid . blObstructs .~ concat paths
where
(w', paths) = mapAccumR (flip insertWall) w wls
insertWall :: Wall -> World -> (World, Set PathEdgeNodes)
insertWall :: Wall -> World -> (World, [(Int,Int)])
insertWall wl =
uncurry (obstructPathsCrossing BlockObstacle) (_wlLine wl)
. (cWorld . lWorld . walls . at (_wlID wl) ?~ wl)
+12 -15
View File
@@ -1,19 +1,15 @@
module Dodge.Placement.PlaceSpot.TriggerDoor (
plDoor,
plSlideDoor,
maybeClearDoorPaths,
updateDoorEdges,
) where
import Dodge.Data.GenWorld
import Data.Set (Set)
import qualified Data.Graph.Inductive as FGL
import qualified Data.IntSet as IS
import Data.List
import Dodge.Base
import Dodge.Default.Door
import Dodge.LevelGen.DoorPane
import Dodge.Path
import Dodge.Zoning.Wall
import Geometry
import qualified IntMapHelp as IM
import LensHelp
@@ -61,19 +57,20 @@ addDoorWall eo drid wl w (wlid, wlps) =
, _wlID = wlid
, _wlStructure = DoorPart drid
}
& cWorld . lWorld . doors . ix drid . drObstructs <>~ es
-- & cWorld . lWorld . doors . ix drid . drObstructs <>~ es
where
(w', es) = uncurry (obstructPathsCrossing eo) wlps w
(w', _) = uncurry (obstructPathsCrossing eo) wlps w
maybeClearDoorPaths :: EdgeObstacle -> Set PathEdgeNodes -> World -> World
maybeClearDoorPaths eo es w = foldl' (maybeClearDoorPath eo) w es
updateDoorEdges :: EdgeObstacle -> [(Int,Int)] -> World -> World
updateDoorEdges eo es w = foldl' (updateDoorEdge eo) w es
maybeClearDoorPath :: EdgeObstacle -> World -> PathEdgeNodes -> World
maybeClearDoorPath eo w (PathEdgeNodes x y pe)
| not . null $ overlapSegWalls (_peStart pe) (_peEnd pe) $ wlsNearSeg (_peStart pe) (_peEnd pe) w =
w & cWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles . at eo ?~ ()) . FGL.delEdge (x, y)
| otherwise =
w & cWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles . at eo .~ Nothing) . FGL.delEdge (x, y)
updateDoorEdge :: EdgeObstacle -> World -> (Int,Int) -> World
--updateDoorEdge eo w (i,j) = w
updateDoorEdge _ w _ = w
-- | not . null $ overlapSegWalls (_peStart pe) (_peEnd pe) $ wlsNearSeg (_peStart pe) (_peEnd pe) w =
-- w & cWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles . at eo ?~ ()) . FGL.delEdge (x, y)
-- | otherwise =
-- w & cWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles . at eo .~ Nothing) . FGL.delEdge (x, y)
plSlideDoor ::
Door ->