Random tree structure generation of rooms
This commit is contained in:
@@ -5,6 +5,10 @@ module Dodge.Layout.Tree.Annotate
|
||||
where
|
||||
import Dodge.RandomHelp
|
||||
import Dodge.Layout.Tree.Polymorphic
|
||||
import Dodge.Room.Procedural
|
||||
import Dodge.Room.Link
|
||||
import Dodge.Room.Data
|
||||
import Dodge.Room
|
||||
|
||||
import Data.Tree
|
||||
import Control.Monad.State
|
||||
@@ -13,6 +17,7 @@ import System.Random
|
||||
data Annotation
|
||||
= Lock Int
|
||||
| Key Int
|
||||
| Corridor
|
||||
|
||||
addLock :: RandomGen g => Int -> Tree [Annotation] -> State g (Tree [Annotation])
|
||||
addLock i t = do
|
||||
@@ -20,5 +25,9 @@ addLock i t = do
|
||||
newBefore <- applyToRandomNode (Key i :) beforeLock
|
||||
return $ addToTrunk newBefore [Node [Lock i] afterLock]
|
||||
|
||||
--annoToRoom :: RandomGen g => [Annotation] -> State g (Either Room Room)
|
||||
--annoToRoom as = undefined
|
||||
padCorridors :: Tree [Annotation] -> Tree [Annotation]
|
||||
padCorridors (Node x xs) = Node [Corridor] [Node x (map padCorridors xs)]
|
||||
|
||||
annoToRoom :: RandomGen g => [Annotation] -> State g Room
|
||||
annoToRoom [Corridor] = takeOne [corridor]
|
||||
annoToRoom _ = randLinks $ roomRectAutoLinks 200 200
|
||||
|
||||
Reference in New Issue
Block a user