Move to using RoomLink datatype

This commit is contained in:
2021-11-23 20:45:39 +00:00
parent a66ea1d922
commit 1f2d767d5e
18 changed files with 160 additions and 122 deletions
+13 -13
View File
@@ -13,6 +13,7 @@ import Dodge.Data
import Dodge.Default.Wall
import Dodge.PlacementSpot
import Dodge.Placement.Instance
import Dodge.RoomLink
import Dodge.Item.Weapon.Utility
import Dodge.Room.Link
import Dodge.Room.Path
@@ -66,8 +67,8 @@ roomRect x y xn yn = defaultRoom
wlnks = zip (map (+.+ V2 x 20) $ gridPoints 0 1 yd (yn+1)) (repeat (-pi/2))
nlnks = zip (map (+.+ V2 20 y) $ gridPoints xd (xn+1) 0 1 ) (repeat 0 )
slnks = zip (map (+.+ V2 20 0) $ gridPoints xd (xn+1) 0 1 ) (repeat pi )
lnks = nlnks ++ elnks ++ wlnks ++ slnks
pth = linksAndPath lnks $ map (bimap (+.+ V2 20 20) (+.+ V2 20 20)) (makeGrid xd xn yd yn)
lnks = map toBothLnk $ nlnks ++ elnks ++ wlnks ++ slnks
pth = linksAndPath' lnks $ map (bimap (+.+ V2 20 20) (+.+ V2 20 20)) (makeGrid xd xn yd yn)
{- Creates a rectangular room, automatically creates links and pathfinding graph at a sensible size. -}
-- it is not clear to me that this works for very small rooms (but it does seem
-- to do so)
@@ -122,8 +123,8 @@ quarterRoomFlat w = do
]
pure $ defaultRoom
{ _rmPolys = [ [V2 0 0,V2 w w,V2 (-w) w] ]
, _rmOutLinks = [(V2 0 w, 0)]
, _rmInLinks = [(V2 0 w, 0)]
, _rmOutLinks = [toBothLnk (V2 0 w, 0)]
, _rmInLinks = [toBothLnk (V2 0 w, 0)]
, _rmPath = concatMap doublePair
[(V2 0 w,V2 0 (w-20))
,(V2 0 (w-20),V2 (w-20) (w-20))
@@ -158,12 +159,12 @@ fourthCornerWall w = do
pure $ defaultRoom
{ _rmPolys = [ map toV2 [(0,0),(w,w),(0,2*w),(-w,w)] ]
, _rmOutLinks =
[(V2 (w/2) (3*w/2), negate $ pi/4)
,(V2 (negate $ w/2) (3*w/2), pi/4)
[toBothLnk (V2 (w/2) (3*w/2), negate $ pi/4)
,toBothLnk (V2 (negate $ w/2) (3*w/2), pi/4)
]
, _rmInLinks =
[(V2 (w/2) (3*w/2), negate $ pi/4)
,(V2 (negate $ w/2) (3*w/2), pi/4)
[toBothLnk (V2 (w/2) (3*w/2), negate $ pi/4)
,toBothLnk (V2 (negate $ w/2) (3*w/2), pi/4)
]
, _rmPath = concatMap doublePair
[(V2 (0.5*w) (1.5*w),V2 (0.5*w-20) (1.5*w-20))
@@ -225,11 +226,10 @@ centerVaultRoom w h d = do
return $ defaultRoom
{ _rmPolys = [rectNSWE h (-h) (-w) w]
, _rmOutLinks =
[(V2 0 h , 0 )
,(V2 w 0 ,-pi/2)
,(V2 (-w) 0 , pi/2) ]
, _rmInLinks = [(V2 0 (-h), pi )
]
[outLink (V2 0 h) 0
,outLink (V2 w 0) (-pi/2)
,outLink (V2 (-w) 0) (pi/2) ]
, _rmInLinks = [inLink (V2 0 (-h)) pi ]
, _rmPath = []
, _rmPmnts =
[sps0 $ PutWall (rectNSEW d (d - 30) d (d - 30)) defaultWall