Work toward adding wiring

This commit is contained in:
2021-11-14 00:39:24 +00:00
parent 96c72ef578
commit 4a089ff0cc
34 changed files with 154 additions and 214 deletions
+4 -5
View File
@@ -15,9 +15,6 @@ data Annotation g
= Lock Int
| Key Int
| Corridor
| CorridorDebug
| SwitchDoorAno
| DoorNumAno Int
| AirlockAno
| FirstWeapon
| StartRoom
@@ -28,6 +25,7 @@ data Annotation g
| TreasureAno [Creature] [Item]
| SetLabel Int (State g Room)
| UseLabel Int (State g Room)
| ChainAnos [[Annotation g]]
addLock :: RandomGen g => Int -> Tree [Annotation g] -> State g (Tree [Annotation g])
addLock i t = do
@@ -59,12 +57,13 @@ anoToRoomTree anos = case anos of
[UseLabel i randrm] -> do
rm <- randrm
return $ connectRoom $ rm & rmTakeFrom ?~ i
[ChainAnos ass] -> do
rms <- mapM anoToRoomTree ass
return $ linkEitherTrees rms
[OrAno as] -> do
a <- takeOne as
anoToRoomTree a
[Corridor] -> pure . Right <$> randomiseOutLinks corridor
[CorridorDebug] -> pure . Right <$> randomiseOutLinks corridorDebug
-- [DoorAno] -> roomThenCorridor door
[AirlockAno] -> airlock >>= roomThenCorridor
[FirstWeapon] -> do
branchWP <- branchRectWith weaponRoom
+6
View File
@@ -7,6 +7,7 @@ module Dodge.Layout.Tree.Either
, connectRoom
, connectTrunk
, deadRoom
, linkEitherTrees
) where
import Data.Tree
@@ -32,6 +33,11 @@ appendEitherTree
appendEitherTree (Node (Left x) ts) ts' = Node (Left x) $ map (`appendEitherTree` ts') ts
appendEitherTree (Node (Right x) _) ts' = Node (Left x) ts'
linkEitherTrees :: [Tree (Either a a)] -> Tree (Either a a)
linkEitherTrees (t:s:ts) = linkEitherTrees (appendEitherTree t [s]:ts)
linkEitherTrees [t] = t
linkEitherTrees [] = error "tried to concatenate an empty list of either trees"
removeEither :: Either p p -> p
removeEither (Left y) = y
removeEither (Right y) = y
+1 -1
View File
@@ -4,7 +4,7 @@ Creates a list of rooms; after this step the structure is determined by the actu
module Dodge.Layout.Tree.Shift
( positionRooms
) where
import Dodge.Room.Data
import Dodge.LevelGen.Data
import Dodge.Room.Link
import Dodge.Layout.Tree.Polymorphic
import Geometry.ConvexPoly