44 lines
1.1 KiB
Haskell
44 lines
1.1 KiB
Haskell
{-# LANGUAGE StrictData #-}
|
|
{-# LANGUAGE TemplateHaskell #-}
|
|
|
|
module Dodge.Annotation.Data where
|
|
|
|
import Control.Lens
|
|
import Control.Monad.State
|
|
import Dodge.Data.GenWorld
|
|
import Dodge.Data.MetaTree
|
|
import System.Random
|
|
|
|
type MTRS = MetaTree Room String
|
|
|
|
data LayoutVars = LayVars
|
|
{ _lyGen :: StdGen
|
|
, _lyCounter :: Int
|
|
}
|
|
|
|
data Annotation
|
|
= OnwardList [Annotation]
|
|
-- | IntAnno (Int -> Annotation)
|
|
-- | AnRoom (State StdGen Room)
|
|
| AnTree (State LayoutVars (MetaTree Room String))
|
|
| PassthroughLockKeyLists
|
|
[(Int -> State StdGen (MetaTree Room String), State StdGen ItemType)]
|
|
[(ItemType, State StdGen (MetaTree Room String))]
|
|
-- Int
|
|
|
|
makeLenses ''Annotation
|
|
makeLenses ''LayoutVars
|
|
|
|
instance RandomGen LayoutVars where
|
|
genWord32 x = let (y,g) = genWord32 (x ^. lyGen)
|
|
in (y,x & lyGen .~ g)
|
|
genWord64 x = let (y,g) = genWord64 (x ^. lyGen)
|
|
in (y,x & lyGen .~ g)
|
|
split x = let (g,h) = split (x ^. lyGen) in (x & lyGen .~ g, x & lyGen .~ h)
|
|
|
|
nextLayoutInt :: State LayoutVars Int
|
|
nextLayoutInt = do
|
|
LayVars g i <- get
|
|
put $ LayVars g (i + 1)
|
|
return i
|