Tweak starting rooms

This commit is contained in:
2021-11-16 22:48:45 +00:00
parent 5d0b48829c
commit 559d7e3a23
6 changed files with 102 additions and 92 deletions
+12 -8
View File
@@ -44,7 +44,7 @@ generateLevelFromRoomList gr' w
. flip (mapAccumR doRoomPlacements) rs'
$ w { _walls = wallsFromRooms rs
, _floorTiles = floorsFromRooms rs
, _gameRooms = gameRoomsFromRooms rs
, _gameRooms = gameRoomsFromRooms rs'
, _pathGraph = path
, _pathGraphP = pairPath
}
@@ -155,10 +155,10 @@ gameRoomsFromRooms = map gameRoomFromRoom
gameRoomFromRoom :: Room -> GameRoom
gameRoomFromRoom rm = GameRoom
{ _grViewpoints = _rmViewpoints rm ++ (map fst . foldl' (flip cutWalls) [] $ _rmPolys rm)
{ _grViewpoints = map doshift $ _rmViewpoints rm ++ (map fst . foldl' (flip cutWalls) [] $ _rmPolys rm)
-- ++ map fst (_rmLinks rm)
, _grViewpointsEx = mapMaybe unpos (_rmPos rm)
, _grBound = expandPolyCorners 50 . convexHullSafe . nubBy closePoints
, _grViewpointsEx = concatMap unpos (_rmPos rm)
, _grBound = map doshift $ expandPolyCorners 50 . convexHullSafe . nubBy closePoints
. concat $ _rmBound rm ++ _rmPolys rm
, _grDir = getDir $ _rmPos rm
, _grLinkDirs = mapMaybe undir $ _rmPos rm
@@ -166,14 +166,18 @@ gameRoomFromRoom rm = GameRoom
}
where
doshift = shiftPointBy (_rmShift rm)
unpos (OutLink _ p _) = Just $ doshift p
unpos (InLink p _) = Just $ doshift p
unpos _ = Nothing
doubleShift p a = map doshift
[p +.+ 10 *.* unitVectorAtAngle a
,p -.- 10 *.* unitVectorAtAngle a
]
unpos (OutLink _ p a) = doubleShift p a
unpos (InLink p a) = doubleShift p a
unpos _ = []
undir (OutLink _ _ a) = Just $ 0.5*pi + a + snd (_rmShift rm)
undir (InLink _ a) = Just $ 0.5*pi + a + snd (_rmShift rm)
undir _ = Nothing
closePoints x y = roundPoint2 x == roundPoint2 y
getDir (InLink _ a:_) = a -- + snd (_rmShift rm)
getDir (InLink _ a:_) = a + snd (_rmShift rm)
getDir (_:xs) = getDir xs
getDir _ = 0 -- fallback