Move to using RoomLink datatype
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
module Dodge.Room.Path
|
||||
( gridPoints
|
||||
, linksAndPath
|
||||
, linksAndPath'
|
||||
, makeGrid
|
||||
, createPathGrid
|
||||
)
|
||||
where
|
||||
import Dodge.LevelGen.Data
|
||||
import Dodge.LevelGen.StaticWalls
|
||||
import Dodge.RoomLink
|
||||
import Geometry
|
||||
|
||||
import Data.Function (on)
|
||||
@@ -18,7 +20,7 @@ import qualified Control.Foldl as L
|
||||
|
||||
createPathGrid :: Room -> Room
|
||||
createPathGrid rm = rm
|
||||
{ _rmPath = linksAndPath (_rmOutLinks rm ++ _rmInLinks rm) filterGrid }
|
||||
{ _rmPath = linksAndPath (map lnkPosDir $ _rmOutLinks rm ++ _rmInLinks rm) filterGrid }
|
||||
where
|
||||
filterGrid = filter (\p -> pairInPolys (_rmPolys rm) p && testCrossWalls outerWalls p) grid
|
||||
grid = fromMaybe [] $ shiftedGrid <$> minx <*> maxx <*> miny <*> maxy
|
||||
@@ -37,6 +39,9 @@ linksAndPath lnks subpth = subpth ++ concatMap linkClosest lnks
|
||||
where
|
||||
linkClosest (p,_) = doublePair (p, minimumBy (compare `on` dist p) $ map fst subpth)
|
||||
|
||||
linksAndPath' :: [RoomLink] -> [(Point2,Point2)] -> [(Point2,Point2)]
|
||||
linksAndPath' = linksAndPath . map lnkPosDir
|
||||
|
||||
testCrossWalls
|
||||
:: [(Point2,Point2)]
|
||||
-> (Point2,Point2)
|
||||
|
||||
Reference in New Issue
Block a user