Slight cleanup of placement spots

This commit is contained in:
2021-11-07 20:38:40 +00:00
parent 5681a37953
commit 2d98c74ab3
2 changed files with 36 additions and 13 deletions
+4 -7
View File
@@ -53,7 +53,8 @@ generateLevelFromRoomList gr w
where
path = pairsToGraph dist pairPath
pairPath = concatMap _rmPath rs
plmnts = concat . snd $ mapAccumR assignPlacementSpots (_randGen w) rs
plmnts = concatMap (\rm -> map (rm,) (_rmPS rm)) rs
--plmnts = concat . snd $ mapAccumR assignPlacementSpots (_randGen w) rs
rs = zipWith addTile zs . evalState gr $ _randGen w
zs = map fromIntegral $ randomRs (0,63::Int) $ _randGen w
@@ -63,18 +64,14 @@ generateLevelFromRoomList gr w
-- first it takes the random placements and derandomises them
-- then it deals with link placement spots
-- TODO use state monad here
assignPlacementSpots :: StdGen -> Room -> (StdGen, [((Point2,Float),Placement)])
assignPlacementSpots :: StdGen -> Room -> (StdGen, [(Room,Placement)])
assignPlacementSpots g rm = (g'
, map (_rmShift rm,)
, map (rm,)
$ plmnts ++ updatedLnkPlmnts
)
where
(randPlmnts, detPlmnts) = partition isRand (_rmPS rm)
isRand RandomPlacement{} = True
isRand _ = False
(unrandPlmnts, g'') = runState (mapM (derandPlacement rm) (_rmPS rm)) g
(lnkplmnts, plmnts) = partition islnk unrandPlmnts
--(lnkplmnts, plmnts) = partition islnk (unrandPlmnts ++ detPlmnts)
islnk Placement{_placementSpot=PSLnk{}} = True
islnk _ = False
(shuffledLnks,g') = runState (shuffle $ _rmLinks rm) g''