Commit before changing links

This commit is contained in:
2021-11-11 22:51:02 +00:00
parent 8c45a02e46
commit d63c2ac943
11 changed files with 40 additions and 33 deletions
+7 -6
View File
@@ -28,17 +28,17 @@ import qualified Data.IntSet as IS
placeSpot :: (World,Room) -> Placement -> (World,Room)
placeSpot (w,rm) plmnt = case plmnt of
Placement{_placementSpot = PSRoomRand i}
Placement{_plSpot = PSRoomRand i}
-> let (ps,g) = runState (_rmRandPSs rm !! i) $_randGen w
in placeSpot (w & randGen .~ g,rm) (plmnt & placementSpot .~ uncurry PS ps)
Placement{_placementSpot = PSLnk{}} -> case lnks of
in placeSpot (w & randGen .~ g,rm) (plmnt & plSpot .~ uncurry PS ps)
Placement{_plSpot = PSLnk{}} -> case lnks of
((lnki,lnk):_) -> placeSpot (w & randGen .~ g,uselnk lnki) (updatePS (f lnk) plmnt)
[] -> case fallback of
Nothing -> (w,rm)
Just plmnt' -> placeSpot (w,rm) plmnt'
where
uselnk lnki = rm & rmLinks %~ deletei lnki
rps = _placementSpot plmnt
rps = _plSpot plmnt
fallback = _psFallback rps
test = _psLinkTest rps
(lnks,g) = runState (shuffle $ filter (test . snd) $ zip [0..]
@@ -49,8 +49,8 @@ placeSpot (w,rm) plmnt = case plmnt of
invShiftLinkBy :: (Point2,Float) -> (Point2,Float) -> (Point2,Float)
invShiftLinkBy (pos,rot) (p,r) = (invShiftPointBy (pos,rot) p, r - rot)
Placement{} ->
let (i,w') = placeSpotID (shiftPSBy shift (_placementSpot plmnt)) (_psType plmnt) w
in maybe (w',rm) (placeSpot (w',rm)) (_idPlacement plmnt i)
let (i,w') = placeSpotID (shiftPSBy shift (_plSpot plmnt)) (_plType plmnt) w
in maybe (w',rm) (placeSpot (w',rm)) (_plIDCont plmnt i)
PlacementUsingPos p subpl -> placeSpot (w,rm) (subpl (shiftPoint3By shift p))
RandomPlacement rplmnt -> placeSpot (w & randGen .~ g,rm) plmnt'
where
@@ -97,6 +97,7 @@ placeSpotID ps pt w = case pt of
PutForeground sh -> (0,w & foregroundShape %~ ((uncurryV translateSHf p . rotateSH rot) sh <>))
PutNothing -> (0,w)
PutID i -> (i, w)
PutWorldUpdate f -> (0,f ps w)
where
p@(V2 px py) = _psPos ps
p' = V3 px py 0