Add in "linear" lWorld to separate time reversable worlds

This commit is contained in:
2022-10-28 12:24:51 +01:00
parent 5f6bd43599
commit 7e790b7153
130 changed files with 827 additions and 980 deletions
+8 -8
View File
@@ -27,7 +27,7 @@ plBlock [] _ _ _ = error "Trying to add a block with incomplete polygon"
plBlock (p : ps) bl wl w =
(,) blid $
w
& cWorld . blocks . at blid
& cWorld . lWorld . blocks . at blid
?~ bl
{ _blID = blid
, _blWallIDs = IS.fromList is
@@ -36,9 +36,9 @@ plBlock (p : ps) bl wl w =
}
& insertWalls blid wls
where
blid = IM.newKey $ _blocks (_cWorld w)
blid = IM.newKey $ w ^. cWorld . lWorld . blocks
lns = zip (p : ps) (ps ++ [p])
i = IM.newKey $ _walls (_cWorld w)
i = IM.newKey $ w ^. cWorld . lWorld . walls
is = [i .. i + length lns -1]
wls =
zipWith
@@ -72,12 +72,12 @@ plLineBlock basePane blwidth a b gw =
cornerPoints = reverse $ rectWH halfBlockWidth depth -- goes clockwise around the block
cornersAt p = fmap ((p +.+) . rotateV (argV (b -.- a))) cornerPoints
linesAt p = loopPairs $ cornersAt p
wlid = IM.newKey $ _walls (_cWorld gw)
blid = IM.newKey $ _blocks (_cWorld gw)
wlid = IM.newKey $ gw ^. cWorld . lWorld . walls
blid = IM.newKey $ gw ^. cWorld . lWorld . blocks
insertBlock (i, p) =
insertWalls (i + blid) (makeWallAt p i)
. over
(cWorld . blocks)
(cWorld . lWorld . blocks)
( IM.insert
(i + blid)
Block
@@ -115,11 +115,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 . blocks . ix blid . blObstructs .~ Set.unions paths
insertWalls blid wls w = w' & cWorld . lWorld . blocks . ix blid . blObstructs .~ Set.unions paths
where
(w', paths) = mapAccumR (flip insertWall) w wls
insertWall :: Wall -> World -> (World, Set PathEdgeNodes)
insertWall wl =
uncurry (obstructPathsCrossing BlockObstacle) (_wlLine wl)
. (cWorld . walls . at (_wlID wl) ?~ wl)
. (cWorld . lWorld . walls . at (_wlID wl) ?~ wl)
+10 -10
View File
@@ -29,9 +29,9 @@ plDoor ::
[(Point2, Point2)] ->
World ->
(Int, World)
plDoor col eo cond pss gw = (drid, addWalls $ gw & cWorld . doors %~ addDoor) -- carefull with the ordering of addWalls
plDoor col eo cond pss gw = (drid, addWalls $ gw & cWorld . lWorld . doors %~ addDoor) -- carefull with the ordering of addWalls
where
drid = IM.newKey $ _doors (_cWorld gw)
drid = IM.newKey $ _doors (_lWorld (_cWorld gw))
addDoor =
IM.insert drid $
defaultDoor
@@ -46,14 +46,14 @@ plDoor col eo cond pss gw = (drid, addWalls $ gw & cWorld . doors %~ addDoor) --
, _drObstacleType = eo
}
nsteps = length pss - 1
wlids = take 4 [IM.newKey $ _walls (_cWorld gw) ..]
wlids = take 4 [IM.newKey $ _walls (_lWorld (_cWorld gw)) ..]
wlps' = uncurry (rectanglePairs 9) $ head pss
addWalls w' = foldl' (addDoorWall eo drid $ switchWallCol col) w' $ zip wlids wlps'
addDoorWall :: EdgeObstacle -> Int -> Wall -> World -> (Int, (Point2, Point2)) -> World
addDoorWall eo drid wl w (wlid, wlps) =
w'
& cWorld . walls
& cWorld . lWorld . walls
%~ IM.insert
wlid
wl
@@ -61,7 +61,7 @@ addDoorWall eo drid wl w (wlid, wlps) =
, _wlID = wlid
, _wlStructure = DoorPart drid
}
& cWorld . doors . ix drid . drObstructs <>~ es
& cWorld . lWorld . doors . ix drid . drObstructs <>~ es
where
(w', es) = uncurry (obstructPathsCrossing eo) wlps w
@@ -71,9 +71,9 @@ maybeClearDoorPaths eo es w = foldl' (maybeClearDoorPath 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)
w & cWorld . lWorld . 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)
w & cWorld . lWorld . pathGraph %~ FGL.insEdge (x, y, pe & peObstacles . at eo .~ Nothing) . FGL.delEdge (x, y)
plSlideDoor ::
Door ->
@@ -85,9 +85,9 @@ plSlideDoor ::
World ->
(Int, World)
plSlideDoor dr wl eo shiftOffset a b gw =
(drid, addDoorWalls $ gw & cWorld . doors %~ addDoor)
(drid, addDoorWalls $ gw & cWorld . lWorld . doors %~ addDoor)
where
drid = IM.newKey $ _doors (_cWorld gw)
drid = IM.newKey $ _doors (_lWorld (_cWorld gw))
addDoor =
IM.insert drid $
dr
@@ -103,7 +103,7 @@ plSlideDoor dr wl eo shiftOffset a b gw =
addDoorWalls w' = foldl' (addDoorWall eo drid wl) w' $ zip wlids pairs
pairs = rectanglePairs 9 a b
shiftLeft = (+.+ (a -.- b +.+ shiftOffset *.* normalizeV (b -.- a)))
wlids = take 4 [IM.newKey $ _walls (_cWorld gw) ..]
wlids = take 4 [IM.newKey $ _walls (_lWorld (_cWorld gw)) ..]
-- old code that may help with pathing
--import Dodge.LevelGen.Pathing