Commit before static wall overhaul

This commit is contained in:
2021-07-19 01:33:52 +02:00
parent e657d8e852
commit 6905c6f154
17 changed files with 58 additions and 51 deletions
+14 -1
View File
@@ -28,7 +28,8 @@ import Data.Graph.Inductive.Graph (labNodes)
import qualified Data.Map as M
generateLevelFromRoomList :: State StdGen [Room] -> World -> World
generateLevelFromRoomList gr w = updateWallZoning
generateLevelFromRoomList gr w = initializeStaticWalls
. updateWallZoning
. placeSpots plmnts
-- . addRoomPolyDecorations rs
-- . addRoomLinkDecorations rs
@@ -58,6 +59,18 @@ generateFromTree t w = updateWallZoning $ placeSpots plmnts
insertPoint pp@(_,(x,y)) = insertInZoneWith (floorHun x) (floorHun y) (++) [pp]
pinc = M.fromList $ pairsToIncidence pairGraph
initializeStaticWalls :: World -> World
initializeStaticWalls w = w & staticWalls %~ (\wls' -> foldr wallToWall wls' wls)
where
wls = [wl | wl@Wall{} <- (IM.elems $ _walls w)]
wallToWall :: Wall -> IM.IntMap (IM.IntMap [Wall']) -> IM.IntMap (IM.IntMap [Wall'])
wallToWall wl wls = foldr f wls is
where
is = uncurry zoneOfLine (_wlLine wl)
wl' = Wall' {_wlLine' = _wlLine wl, _wlColor' = _wlColor wl}
f (x,y) = insertInZoneWith x y (++) [wl']
updateWallZoning :: World -> World
updateWallZoning w = set wallsZone (IM.foldr wallInZone IM.empty (_walls w)) w
where