Simplify placements
This commit is contained in:
+2
-2
@@ -86,7 +86,7 @@ doInPlacements w =
|
||||
doRoomInPlacements :: GenWorld -> Room -> (GenWorld, Room)
|
||||
doRoomInPlacements w rm = foldr f (w, rm) $ _rmInPmnt rm
|
||||
where
|
||||
f plf (w', r') = fst $ placeSpot (w', r') (plf (w'))
|
||||
f plf (w', r') = placeSpot (w', r') (plf (w'))
|
||||
|
||||
--doOutPlacements :: GenWorld -> GenWorld
|
||||
--doOutPlacements w =
|
||||
@@ -109,7 +109,7 @@ doIndividualPlacements gw =
|
||||
in gw' & genRooms .~ rms
|
||||
|
||||
doRoomPlacements :: GenWorld -> Room -> (GenWorld, Room)
|
||||
doRoomPlacements w rm = foldl' (\wr -> fst . placeSpot wr) (w, rm & rmPmnts .~ mempty)
|
||||
doRoomPlacements w rm = foldl' (\wr -> placeSpot wr) (w, rm & rmPmnts .~ mempty)
|
||||
$ _rmPmnts rm
|
||||
|
||||
setupWorldBounds :: World -> World
|
||||
|
||||
@@ -28,7 +28,7 @@ import System.Random
|
||||
-- when placing a placement, we update the world and the room and assign an id
|
||||
-- to the placement. This id should be associated with the type of placement and
|
||||
-- match up with the created id for the object (creature id, flitid id, etc)
|
||||
placeSpot :: (GenWorld, Room) -> Placement -> ((GenWorld, Room), [Placement])
|
||||
placeSpot :: (GenWorld, Room) -> Placement -> (GenWorld, Room)
|
||||
placeSpot (w, rm) plmnt = case plmnt of
|
||||
Placement{_plSpot = PSRoomRand i f} -> placeSpotRoomRand rm i f plmnt w
|
||||
Placement{_plSpot = PSPos extract eff fallback} ->
|
||||
@@ -38,20 +38,20 @@ placeSpot (w, rm) plmnt = case plmnt of
|
||||
shift = _rmShift rm
|
||||
|
||||
placePlainPSSpot
|
||||
:: GenWorld -> Room -> Placement -> DPoint2 -> ((GenWorld, Room), [Placement])
|
||||
:: GenWorld -> Room -> Placement -> DPoint2 -> (GenWorld, Room)
|
||||
placePlainPSSpot w rm plmnt shift =
|
||||
let (i, w') = placeSpotID rm (shiftPSBy shift (_plSpot plmnt)) (_plType plmnt) w
|
||||
newplmnt = plmnt & plMID ?~ i
|
||||
((gw,rm'),plist) = maybe ((w', rm & rmPmnts .:~ newplmnt), [newplmnt])
|
||||
((gw,rm')) = maybe ((w', rm & rmPmnts .:~ newplmnt))
|
||||
(recrPlace newplmnt w') (_plIDCont plmnt w' newplmnt)
|
||||
in ((f newplmnt gw,rm'),plist)
|
||||
in ((f newplmnt gw,rm'))
|
||||
where
|
||||
f x gw = fromMaybe gw $ do
|
||||
j <- x ^. plExternalID
|
||||
return $ gw & genPmnt . at j ?~ x
|
||||
recrPlace newplmnt w' pl =
|
||||
let (wr, newplmnts) = placeSpot (w', rm & rmPmnts .:~ newplmnt) pl
|
||||
in (wr, newplmnt : newplmnts)
|
||||
let (wr) = placeSpot (w', rm & rmPmnts .:~ newplmnt) pl
|
||||
in (wr)
|
||||
|
||||
-- this should be tidied up
|
||||
placeSpotUsingLink ::
|
||||
@@ -61,11 +61,11 @@ placeSpotUsingLink ::
|
||||
(RoomPos -> Room -> Maybe (PlacementSpot, RoomPos)) ->
|
||||
(RoomPos -> Room -> Room) ->
|
||||
Maybe Placement ->
|
||||
((GenWorld, Room), [Placement])
|
||||
(GenWorld, Room)
|
||||
placeSpotUsingLink w rm plmnt extract eff fallback = case searchedPoss (_rmPos rm) of
|
||||
Just (ps, rmposs) -> placeSpot (w, eff (head rmposs) $ rm & rmPos .~ rmposs) (plmnt & plSpot .~ ps)
|
||||
Nothing -> case fallback of
|
||||
Nothing -> ((w, rm), [plmnt])
|
||||
Nothing -> ((w, rm))
|
||||
Just plmnt' -> placeSpot (w, rm) plmnt'
|
||||
where
|
||||
searchedPoss [] = Nothing
|
||||
@@ -79,7 +79,7 @@ placeSpotRoomRand ::
|
||||
(DPoint2 -> PlacementSpot) ->
|
||||
Placement ->
|
||||
GenWorld ->
|
||||
((GenWorld, Room), [Placement])
|
||||
(GenWorld, Room)
|
||||
placeSpotRoomRand rm i f plmnt w =
|
||||
let (ps, g) = runState (_rmRandPSs rm !! i) $ w ^. gwWorld . randGen
|
||||
in placeSpot (w & gwWorld . randGen .~ g, rm) (plmnt & plSpot .~ f ps)
|
||||
|
||||
Reference in New Issue
Block a user