Continue placement refactor

This commit is contained in:
2021-09-28 15:44:32 +01:00
parent b8af2ce9d8
commit 6b937b115e
10 changed files with 46 additions and 78 deletions
+3 -20
View File
@@ -31,7 +31,7 @@ import System.Random
--import Data.List
--import Data.Maybe
import Data.Tree
import Data.Graph.Inductive.Graph (labNodes)
--import Data.Graph.Inductive.Graph (labNodes)
--import qualified Data.Map as M
import Data.Foldable
import qualified Control.Foldl as L
@@ -43,7 +43,7 @@ generateLevelFromRoomList gr w
. setupWorldBounds
-- . initializeStaticWalls
-- . setupForegroundEdgeVerxs
. placeSpots plmnts
. flip (foldr placeSpot') plmnts
-- . addRoomPolyDecorations rs
-- . addRoomLinkDecorations rs
$ w { _walls = wallsFromRooms rs
@@ -55,7 +55,7 @@ generateLevelFromRoomList gr w
where
path = pairsToGraph dist pairPath
pairPath = concatMap _rmPath rs
plmnts = concatMap _rmPS rs
plmnts = concat $ map (\r -> map ((,) (_rmShift r)) (_rmPS r)) rs
rs = zipWith addTile zs rs'
zs = map fromIntegral $ randomRs (0,63::Int) $ _randGen w
rs' = evalState gr $ _randGen w
@@ -79,23 +79,6 @@ setupWorldBounds w = w
polyhedrasToEdges :: [Polyhedra] -> [Point3]
polyhedrasToEdges = concatMap tflat4 . concatMap polyToEdges
-- | connects a collection (tree) of rooms together
generateFromTree :: State StdGen (Tree Room) -> World -> World
generateFromTree t w = updateWallZoning $ placeSpots plmnts
$ w {_walls = wallsFromTree tr
,_pathGraph = path
,_pathGraphP = pairGraph
,_pathPoints = foldl' (flip insertPoint) IM.empty (labNodes path)
}
where
tr = evalState t $ _randGen w
plmnts = concatMap _rmPS $ flatten tr
path = pairsToGraph dist pairGraph
pairGraph = makePath tr
insertPoint pp@(_,V2 x y) = insertInZoneWith (floorHun x) (floorHun y) (++) [pp]
--pinc = M.fromList $ pairsToIncidence pairGraph
updateWallZoning :: World -> World
updateWallZoning w = set (wallsZone . znObjects) (foldl' (flip wallInZone) IM.empty (_walls w)) w
where