Commit before working on debugging

This commit is contained in:
2025-10-13 23:43:29 +01:00
parent c3a0cb0527
commit 3d602b4f57
7 changed files with 144 additions and 102 deletions
+7 -6
View File
@@ -48,15 +48,14 @@ generateLevelFromRoomList gr' w =
& pnZoning .~ foldl' (flip zonePn) mempty (labNodes path)
& peZoning .~ foldl' (flip zonePe) mempty (map fromEdgeTuple $ labEdges path)
where
(_, path) = pairsToGraph pairPath'
pairPath = foldMap _rmPath rs
pairPath' = snapToGrid pairPath
(_, path) = pairsToGraph . snapToGrid $ foldMap _rmPath rs
rs = map doRoomShift $ IM.elems rs'
rs' = mapM shuffleRoomPos gr' & evalState $ _randGen w
randomCompass :: World -> World
randomCompass w = w & wCam . camRot .~ (takeOne [0, 0.5 * pi, pi, 1.5 * pi] & evalState $ _randGen w)
randomCompass w = w
& wCam . camRot .~ (takeOne [0, 0.5 * pi, pi, 1.5 * pi] & evalState $ _randGen w)
-- note the order of traversal of the rooms is important
-- hence the reverse
@@ -67,12 +66,14 @@ setTiles gw = foldr setTile gw . reverse . IM.elems $ _genRooms gw
setTile :: Room -> GenWorld -> GenWorld
setTile r gw = case _rmFloor r of
Tiled{} -> gw
InheritFloor -> gw & genRooms . ix (fromJust (_rmMID r)) . rmFloor .~ Tiled [t & tilePoly .~ poly]
InheritFloor -> gw
& genRooms . ix (fromJust (_rmMID r)) . rmFloor .~ Tiled [t & tilePoly .~ poly]
where
t = case _rmMParent r of
Nothing -> Tile poly (V2 0 0) (V2 1 0) 16
Just pid -> head $ _tiles $ _rmFloor $ _genRooms gw IM.! pid
poly = orderPolygon . convexHullSafe . nubBy ((==) `on` roundPoint2) $ concat $ _rmPolys r
poly = orderPolygon . convexHullSafe
. nubBy ((==) `on` roundPoint2) $ concat $ _rmPolys r
shuffleRoomPos :: RandomGen g => Room -> State g Room
shuffleRoomPos rm = do