Start updating rooms "in place" during placement

This commit is contained in:
2025-09-24 22:30:15 +01:00
parent 91e67e37dc
commit eab27fea8b
2 changed files with 15 additions and 4 deletions
+14 -3
View File
@@ -89,14 +89,25 @@ doRoomInPlacements w rm = foldr f (w, rm) $ _rmInPmnt rm
f plf (w', r') = placeSpot (w', r') (plf w')
doIndividualPlacements :: GenWorld -> GenWorld
doIndividualPlacements gw =
let (gw', rms) = mapAccumR doRoomPlacements gw (_genRooms gw)
in gw' & genRooms .~ rms
doIndividualPlacements gw = foldl' doRoomPlacements' gw (_genRooms gw)
-- let (gw', rms) = mapAccumR doRoomPlacements gw (_genRooms gw)
-- in gw' & genRooms .~ rms
doRoomPlacements :: GenWorld -> Room -> (GenWorld, Room)
doRoomPlacements w rm = foldl' placeSpot (w, rm & rmPmnts .~ mempty)
$ _rmPmnts rm
doRoomPlacements' :: GenWorld -> Room -> GenWorld
doRoomPlacements' w rm = foldl' (placeSpot' i) (w & genRooms . ix i . rmPmnts .~ mempty)
$ _rmPmnts rm
where
i = rm ^?! rmMID . _Just
placeSpot' :: Int -> GenWorld -> Placement -> GenWorld
placeSpot' i gw x =
let (gw',r') = placeSpot (gw,(gw ^?! genRooms . ix i)) x
in gw' & genRooms . ix i .~ r'
setupWorldBounds :: World -> World
setupWorldBounds w =
w & cWorld . cwGen . cwgWorldBounds