Restruction room code

This commit is contained in:
2021-04-25 13:21:58 +02:00
parent 17986651c5
commit 5d8575b03f
3 changed files with 82 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
{-
Collections of rooms that branch into multiple paths.
-}
module Dodge.Room.Branch
where
import Geometry
import Dodge.Room.Data
import Dodge.Room.Door
import Dodge.Room.Link
import Dodge.Room.Procedural
import Dodge.LevelGen.Data
import Dodge.Layout.Tree.Polymorphic
import Control.Monad.State
import System.Random
import Data.Tree
branchRectWith :: RandomGen g => State g (Tree (Either Room Room)) -> State g (Tree (Either Room Room))
branchRectWith t = do
x <- state $ randomR (100,200)
y <- state $ randomR (100,200)
b <- t
root <- randomiseOutLinks $ roomRectAutoLinks x y
return $ Node (Left root) [Node (Right door) [], fmap rToL $ treeTrunk [Left door] b]
where rToL :: Either a a -> Either a a
rToL (Right r) = Left r
rToL (Left r) = Left r