Automatically order placements
This commit is contained in:
+12
-4
@@ -80,9 +80,10 @@ setTile r gw = case _rmFloor r of
|
||||
. nubBy ((==) `on` roundPoint2) $ concat $ _rmPolys r
|
||||
|
||||
shuffleRoomPos :: RandomGen g => Room -> State g Room
|
||||
shuffleRoomPos rm = do
|
||||
newPos <- shuffle $ _rmPos rm
|
||||
return $ rm & rmPos .~ newPos
|
||||
shuffleRoomPos = rmPos shuffle
|
||||
--shuffleRoomPos rm = do
|
||||
-- newPos <- shuffle $ _rmPos rm
|
||||
-- return $ rm & rmPos .~ newPos
|
||||
|
||||
doInPlacements :: GenWorld -> GenWorld
|
||||
doInPlacements w = foldl' (\gw (i,(_,f)) -> placeSpot i gw (f gw)) w
|
||||
@@ -103,10 +104,17 @@ doIndividualPlacements gw = foldl' doRoomPlacements gw (_genRooms gw)
|
||||
|
||||
doRoomPlacements :: GenWorld -> Room -> GenWorld
|
||||
doRoomPlacements w rm = foldl' (placeSpot i) (w & genRooms . ix i . rmPmnts .~ mempty)
|
||||
$ _rmPmnts rm
|
||||
. sortOn plPriority $ _rmPmnts rm
|
||||
where
|
||||
i = rm ^?! rmMID . _Just
|
||||
|
||||
plPriority :: Placement -> Int
|
||||
plPriority pl = case pl ^. plType of
|
||||
PutChasm {} -> 0
|
||||
PutBlock {} -> 1
|
||||
PutDoor {} -> 2
|
||||
_ -> 3
|
||||
|
||||
--placeSpot' :: Int -> GenWorld -> Placement -> GenWorld
|
||||
--placeSpot' = placeSpot
|
||||
--placeSpot' i gw x =
|
||||
|
||||
Reference in New Issue
Block a user