Add laser central room, using new placement/roompos functionality

This commit is contained in:
2021-11-21 17:44:32 +00:00
parent 48cd59069c
commit 2f3896345d
12 changed files with 127 additions and 76 deletions
+11 -8
View File
@@ -7,27 +7,30 @@ import System.Random
-- TODO rename to any unused link facing out
anyLnkOutPS :: PlacementSpot
anyLnkOutPS = PSLnk f (const id) Nothing
anyLnkOutPS = PSPos f (const id) Nothing
where
f (UnusedLink p a) = Just $ PS p a
f (UnusedLink p a) = Just (PS p a, PosPl p a)
f _ = Nothing
fstLnkOut :: PlacementSpot
fstLnkOut = PSLnk f (const id) Nothing
fstLnkOut = PSPos f (const id) Nothing
where
f (OutLink 0 p a) = Just $ PS p a
f (OutLink 0 p a) = Just (PS p a, PosPl p a)
f _ = Nothing
anyLnkInPS :: Float -- ^ amount to shift inward
-> PlacementSpot
anyLnkInPS x = PSLnk f (const id) Nothing
anyLnkInPS x = PSPos f (const id) Nothing
where
f (UnusedLink v a) = Just $ PS (v -.- x *.* unitVectorAtAngle (a + 0.5 * pi)) (a+ pi)
f (UnusedLink v a) = Just (PS v' a' ,PosPl v' a')
where
v' = v -.- x *.* unitVectorAtAngle (a + 0.5 * pi)
a' = a + pi
f _ = Nothing
useLnkRoomPos :: RoomPos -> Maybe PlacementSpot
useLnkRoomPos :: RoomPos -> Maybe (PlacementSpot,RoomPos)
useLnkRoomPos rp = case rp of
(UnusedLink (V2 x y) a) -> Just $ PS (V2 x y) a
(UnusedLink (V2 x y) a) -> Just (PS (V2 x y) a , PosPl (V2 x y) a)
_ -> Nothing
psRandRanges :: (Float,Float) -> (Float,Float) -> (Float,Float) -> State StdGen (Point2,Float)