Attempt to incorporate free link positions into placement chain

This commit is contained in:
2021-11-04 10:38:30 +00:00
parent f45d19a787
commit a9b802b883
6 changed files with 39 additions and 7 deletions
+6 -1
View File
@@ -56,6 +56,8 @@ generateLevelFromRoomList gr w
rs = zipWith addTile zs . evalState gr $ _randGen w
zs = map fromIntegral $ randomRs (0,63::Int) $ _randGen w
-- the idea is to allow use of link coordinates for placements
-- though the implementation is clunky
assignPlacementSpots :: Room -> [Placement]
assignPlacementSpots rm = plmnts ++ plmnts'
where
@@ -63,9 +65,12 @@ assignPlacementSpots rm = plmnts ++ plmnts'
islnk Placement{_placementSpot=PSLnk{}} = True
islnk _ = False
(_,plmnts') = mapAccumR f (_rmLinks rm) lnkplmnts
(la,lb) = head $ _rmUsedLinks rm
lnkTo = (la,lb+1.5*pi)
f lnks plmnt =
let (x:xs,ys) = partition (_psLinkTest $ _placementSpot plmnt) lnks
thepair = _psLinkShift (_placementSpot plmnt) x
thepair = bimap (invShiftPointBy lnkTo) (\r -> r - snd lnkTo)
$ _psLinkShift (_placementSpot plmnt) x
in (xs++ys, updatePS (updatePSLnkUsing thepair) plmnt)
updatePSLnkUsing :: (Point2,Float) -> PlacementSpot -> PlacementSpot