Allow arbitrary changes to a room when using a link slot
This commit is contained in:
@@ -8,6 +8,7 @@ import Dodge.LevelGen.Data
|
||||
import Dodge.Room.Link
|
||||
import Dodge.Layout.Tree.Polymorphic
|
||||
import Geometry.ConvexPoly
|
||||
import Geometry.Data
|
||||
|
||||
import Data.Tree
|
||||
import Data.Sequence hiding (zipWith)
|
||||
@@ -40,13 +41,18 @@ posRms bounds (r,i) (t@(Node (_,i') _):ts) tseq = do
|
||||
| clipping = tryLinks (j+1) ls
|
||||
| otherwise = do
|
||||
putStrLn $ "placing at link " ++ show j
|
||||
mayrs <- posRms (convexBounds ++ bounds) useLink ts (tseq |> shiftedt)
|
||||
mayrs <- posRms (convexBounds ++ bounds) newr ts (tseq |> shiftedt)
|
||||
case mayrs of
|
||||
Nothing -> do putStr ("Backtracking to room " ++ show i' ++ ": ") >> tryLinks (j+1) ls
|
||||
Just rs -> return (Just rs)
|
||||
where
|
||||
convexBounds = map pointsToPoly $ _rmBound r'
|
||||
clipping = or (convexPolysOverlap <$> convexBounds <*> bounds)
|
||||
useLink = (r & rmLinks %~ delete l & rmPos %~ (uncurry (OutLink (Prelude.length ts)) l :)
|
||||
newr = (lnkEff l $ r & rmLinks %~ delete l & rmPos %~ (uncurry (OutLink j) l :)
|
||||
, i)
|
||||
shiftedt@(Node (r',_) _) = applyToRoot (first $ shiftRoomToLink l) t
|
||||
|
||||
lnkEff :: (Point2,Float) -> Room -> Room
|
||||
lnkEff x rm = case _rmLinkEff rm of
|
||||
(eff:effs) -> eff x $ rm & rmLinkEff .~ effs
|
||||
_ -> rm
|
||||
|
||||
Reference in New Issue
Block a user