Cleanup. Add room-wise random placement spots

This commit is contained in:
2021-11-07 19:46:14 +00:00
parent f380e140e1
commit 5681a37953
18 changed files with 179 additions and 141 deletions
+10
View File
@@ -33,6 +33,8 @@ data PlacementSpot
| PSLnk { _psLinkTest :: (Point2,Float) -> Bool
, _psLinkShift :: (Point2,Float) -> (Point2,Float)
}
| PSRoomRand
{ _psRoomRandPointNum :: Int }
data Placement = Placement
{ _placementSpot :: PlacementSpot
, _psType :: PSType
@@ -68,6 +70,14 @@ jps0 pst = Just . Placement (PS (V2 0 0) 0) pst
ps0j :: PSType -> Placement -> Placement
ps0j pst plmnt = Placement (PS (V2 0 0) 0) pst (const $ Just plmnt)
addPlmnt :: Placement -> Placement -> Placement
addPlmnt pl (PlacementUsingPos p f) = PlacementUsingPos p (fmap (addPlmnt pl) f)
addPlmnt pl (RandomPlacement rp) = RandomPlacement $ fmap (addPlmnt pl) rp
addPlmnt pl (Placement ps pt f) = Placement ps pt (fmap g f)
where
g Nothing = Just pl
g (Just pl') = Just $ addPlmnt pl pl'
makeLenses ''PSType
makeLenses ''PlacementSpot
makeLenses ''Placement