Work on placements

This commit is contained in:
2025-09-23 12:59:28 +01:00
parent a9ecd7de2e
commit ef90e5702b
3 changed files with 59 additions and 66 deletions
-1
View File
@@ -109,7 +109,6 @@ doIndividualPlacements gw =
in gw' & genRooms .~ rms
doRoomPlacements :: GenWorld -> Room -> (GenWorld, Room)
--doRoomPlacements w rm = foldl' (\wr -> fst . placeSpot wr) (w, rm) $ _rmPmnts rm
doRoomPlacements w rm = foldl' (\wr -> fst . placeSpot wr) (w, rm & rmPmnts .~ mempty)
$ _rmPmnts rm
+10 -12
View File
@@ -39,12 +39,13 @@ placeSpot (w, rm) plmnt = case plmnt of
placePlainPSSpot
:: GenWorld -> Room -> Placement -> DPoint2 -> ((GenWorld, Room), [Placement])
placePlainPSSpot w rm plmnt shift =
let (i, w') = placeSpotID (shiftPSBy shift (_plSpot plmnt)) (_plType plmnt) w
let (i, w') = placeSpotID rm (shiftPSBy shift (_plSpot plmnt)) (_plType plmnt) w
newplmnt = plmnt & plMID ?~ i
in maybe ((w', rm & rmPmnts .:~ newplmnt), [newplmnt]) (recrPlace newplmnt w') (_plIDCont plmnt (w') newplmnt)
in maybe ((w', rm & rmPmnts .:~ newplmnt), [newplmnt])
(recrPlace newplmnt w') (_plIDCont plmnt w' newplmnt)
where
recrPlace newplmnt w' pl =
let (wr, newplmnts) = placeSpot (w', rm) pl
let (wr, newplmnts) = placeSpot (w', rm & rmPmnts .:~ newplmnt) pl
in (wr, newplmnt : newplmnts)
-- this should be tidied up
@@ -78,14 +79,10 @@ 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)
--placeSpotID :: PlacementSpot -> PSType -> GenWorld -> (Int, GenWorld)
--placeSpotID ps pt gw =
-- let (i, w) = placeSpotID' ps pt (_gwWorld gw)
-- in (i, gw & gwWorld .~ w)
-- the Int here is some id that is assigned when the placement is placed
placeSpotID :: PlacementSpot -> PSType -> GenWorld -> (Int, GenWorld)
placeSpotID ps pt w = case pt of
placeSpotID :: Room -> PlacementSpot -> PSType -> GenWorld -> (Int, GenWorld)
placeSpotID rm ps pt w = case pt of
PutTrigger cnd -> plNewID (gwWorld . cWorld . lWorld . triggers) cnd w
PutMod mdi -> plNewUpID (gwWorld . cWorld . lWorld . modifications) mdID mdi w
PutProp prp -> plNewUpID (gwWorld . cWorld . lWorld . props) prID (mvProp p rot prp) w
@@ -107,7 +104,7 @@ placeSpotID ps pt w = case pt of
PutMachine pps mc wl mitm -> plMachine (map doShift pps) mc wl mitm p rot w
PutLS ls -> plNewUpID (gwWorld . cWorld . lWorld . lightSources) lsID (mvLS p' rot ls) w
PutPPlate pp -> plNewUpID (gwWorld . cWorld . lWorld . pressPlates) ppID (mvPP p rot pp) w
RandPS rgn -> evaluateRandPS rgn ps w
RandPS rgn -> evaluateRandPS rm rgn ps w
PutDoor col eo f pss -> plDoor col eo f (map (bimap doShift doShift) pss) w
PutCoord cp -> plNewID (gwWorld . coordinates) (doShift cp) w
PutSlideDr wl dr eo off a b ->
@@ -130,8 +127,9 @@ placeSpotID ps pt w = case pt of
rot = _psRot ps
doShift = shiftPointBy (p, rot)
evaluateRandPS :: State StdGen PSType -> PlacementSpot -> GenWorld -> (Int, GenWorld)
evaluateRandPS rgen ps w = placeSpotID ps evaluatedType (set (gwWorld . randGen) g w)
evaluateRandPS
:: Room -> State StdGen PSType -> PlacementSpot -> GenWorld -> (Int, GenWorld)
evaluateRandPS rm rgen ps w = placeSpotID rm ps evaluatedType (set (gwWorld . randGen) g w)
where
(evaluatedType, g) = runState rgen (_randGen $ _gwWorld w)