Cleanup
This commit is contained in:
@@ -31,7 +31,7 @@ roomGlassOctogon x =
|
||||
]
|
||||
, _rmLinks = lnks'
|
||||
, _rmPath =
|
||||
linksAndPath'
|
||||
linksGridToPath
|
||||
lnks'
|
||||
[ (V2 0 x, V2 0 (- (x + 40)))
|
||||
, (V2 0 (- (x + 40)), V2 0 x)
|
||||
|
||||
@@ -2,7 +2,6 @@ module Dodge.Room.CheckConsistency where
|
||||
|
||||
import Dodge.Data.GenWorld
|
||||
import Dodge.Graph
|
||||
import Dodge.RoomLink
|
||||
|
||||
linksOnPath :: Room -> Bool
|
||||
linksOnPath r = all pointOnPath linkPoints
|
||||
|
||||
@@ -29,6 +29,7 @@ roomNgon n x = do
|
||||
rot = 2 * pi / fromIntegral n
|
||||
rots = map ((rot *) . fromIntegral) [0 .. n -1]
|
||||
poly = polyOrthDist n x
|
||||
path1 = polyOrthDist n (x-10)
|
||||
lnks =
|
||||
sortOn ((\(V2 a b) -> (negate b, a)) . fst . snd)
|
||||
. zip [0 ..]
|
||||
|
||||
+6
-16
@@ -1,6 +1,6 @@
|
||||
module Dodge.Room.Path (
|
||||
gridPoints,
|
||||
linksAndPath',
|
||||
linksGridToPath,
|
||||
makeGrid,
|
||||
createPathGrid,
|
||||
gridPoints'',
|
||||
@@ -14,17 +14,14 @@ import Data.Maybe
|
||||
import qualified Data.Set as S
|
||||
import Dodge.Data.GenWorld
|
||||
import Dodge.LevelGen.StaticWalls
|
||||
import Dodge.RoomLink
|
||||
import Geometry
|
||||
import Grid
|
||||
|
||||
createPathGrid :: Room -> Room
|
||||
createPathGrid rm =
|
||||
rm
|
||||
{ _rmPath = linksAndPath' (_rmLinks rm) filterGrid
|
||||
}
|
||||
createPathGrid rm = rm & rmPath .~ linksGridToPath (_rmLinks rm) filterGrid
|
||||
where
|
||||
filterGrid = filter (\p -> pairInPolys (_rmPolys rm) p && testCrossWalls outerWalls p) grid
|
||||
filterGrid = filter
|
||||
(\p -> pairInPolys (_rmPolys rm) p && testCrossWalls outerWalls p) grid
|
||||
grid = fromMaybe [] $ shiftedGrid <$> minx <*> maxx <*> miny <*> maxy
|
||||
outerWalls = foldr cutPoly [] $ _rmPolys rm
|
||||
outerPoints = map fst outerWalls
|
||||
@@ -36,17 +33,10 @@ createPathGrid rm =
|
||||
<*> L.premap sndV2 L.minimum
|
||||
<*> L.premap sndV2 L.maximum
|
||||
|
||||
--linksAndPath :: [(Point2, Float)] -> [(Point2, Point2)] -> S.Set (Point2, Point2)
|
||||
--linksAndPath lnks subpth = S.fromList subpth <> foldMap linkClosest lnks
|
||||
-- where
|
||||
-- linkClosest (p, _) = doublePairSet (p, minimumBy (compare `on` dist p) $ map fst subpth)
|
||||
|
||||
linksAndPath' :: [RoomLink] -> [(Point2, Point2)] -> S.Set (Point2, Point2)
|
||||
linksAndPath' lnks subpth = S.fromList subpth
|
||||
<> foldMap (linkClosest . (^. rlPos) ) lnks
|
||||
linksGridToPath :: [RoomLink] -> [(Point2, Point2)] -> S.Set (Point2, Point2)
|
||||
linksGridToPath lnks subpth = S.fromList subpth <> foldMap (linkClosest . (^. rlPos)) lnks
|
||||
where
|
||||
linkClosest p = doublePairSet (p, minimumBy (compare `on` dist p) $ map fst subpth)
|
||||
--linksAndPath' = linksAndPath . map lnkPosDir
|
||||
|
||||
testCrossWalls :: [(Point2, Point2)] -> (Point2, Point2) -> Bool
|
||||
testCrossWalls wls (a, b) = not $ any (isJust . uncurry (intersectSegSeg a b)) wls
|
||||
|
||||
@@ -95,7 +95,8 @@ roomRect x y xn yn =
|
||||
m edge edgefrom1 edgefrom2 =
|
||||
zipWith (lnkBothAnd (OnEdge edge) edgefrom1 edgefrom2) [0 ..]
|
||||
. zipCountDown
|
||||
pth = linksAndPath' lnks $ map (bimap (+.+ V2 20 20) (+.+ V2 20 20)) (makeGrid xd xn yd yn)
|
||||
pth = linksGridToPath lnks
|
||||
$ map (bimap (+.+ V2 20 20) (+.+ V2 20 20)) (makeGrid xd xn yd yn)
|
||||
makeonpos (p, a) = RoomPos p 0 (S.singleton $ RoomPosOnPath $ makerpedges a)
|
||||
NotLink mempty
|
||||
makerpedges (a, b) =
|
||||
|
||||
Reference in New Issue
Block a user