Automatically order placements

This commit is contained in:
2026-03-17 23:38:14 +00:00
parent 3b4cf68a15
commit d1c2870d63
25 changed files with 527 additions and 479 deletions
+12 -4
View File
@@ -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 =