This commit is contained in:
2022-06-10 23:10:38 +01:00
parent 6966e76206
commit ad576014fb
8 changed files with 41 additions and 37 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ import RandomHelp
initialAnoTree :: Tree [Annotation] initialAnoTree :: Tree [Annotation]
initialAnoTree = padSucWithDoors $ treeFromPost initialAnoTree = padSucWithDoors $ treeFromPost
[[AnoApplyInt 0 startRoom] [[AnoApplyInt 110 startRoom]
, [PassthroughLockKeyLists 2 keyCardRunPastRand itemRooms] , [PassthroughLockKeyLists 2 keyCardRunPastRand itemRooms]
, [SpecificRoom $ warningRooms 7] , [SpecificRoom $ warningRooms 7]
, [SpecificRoom $ return ( toOnward "chaseCrit+armourChaseCrit rectRoom" , [SpecificRoom $ return ( toOnward "chaseCrit+armourChaseCrit rectRoom"
+2 -6
View File
@@ -15,9 +15,7 @@ import Dodge.Item
bossKeyItems :: RandomGen g => [ (State g (Tree Room), State g ItemBaseType) ] bossKeyItems :: RandomGen g => [ (State g (Tree Room), State g ItemBaseType) ]
bossKeyItems = bossKeyItems = [(return . useAll <$> bossRoom autoCrit, takeOne [PISTOL]) ]
[(return . useAll <$> bossRoom autoCrit, takeOne [PISTOL])
]
lockRoomMultiItems :: RandomGen g => [ ( State g (LabTree Room) , State g [ItemBaseType] ) ] lockRoomMultiItems :: RandomGen g => [ ( State g (LabTree Room) , State g [ItemBaseType] ) ]
lockRoomMultiItems = lockRoomMultiItems =
@@ -40,9 +38,7 @@ lockRoomKeyItems =
,(keyCardRoomRunPast 0, return (KEYCARD 0)) ,(keyCardRoomRunPast 0, return (KEYCARD 0))
] ]
keyCardRunPastRand :: RandomGen g => [ (Int -> State g (LabTree Room) , State g ItemBaseType ) ] keyCardRunPastRand :: RandomGen g => [ (Int -> State g (LabTree Room) , State g ItemBaseType ) ]
keyCardRunPastRand = keyCardRunPastRand = [(keyCardRoomRunPast 0, return (KEYCARD 0)) ]
[(keyCardRoomRunPast 0, return (KEYCARD 0))
]
itemRooms :: RandomGen g => [(ItemBaseType, State g (LabTree Room))] itemRooms :: RandomGen g => [(ItemBaseType, State g (LabTree Room))]
itemRooms = itemRooms =
+1 -3
View File
@@ -75,9 +75,7 @@ extTrigLitPos ps f = psPtCont ps (PutTrigger (const False))
} }
thels = lsColPosRad (V3 0.5 0 0) (V3 0 0 78) 75 thels = lsColPosRad (V3 0.5 0 0) (V3 0 0 78) 75
putLitButOnPosExtTrig :: Color putLitButOnPosExtTrig :: Color -> PlacementSpot -> Placement
-> PlacementSpot
-> Placement
putLitButOnPosExtTrig col thePS = putLitButOnPosExtTrig' col thePS (const . const . const Nothing) putLitButOnPosExtTrig col thePS = putLitButOnPosExtTrig' col thePS (const . const . const Nothing)
putLitButOnPosExtTrig' :: Color putLitButOnPosExtTrig' :: Color
+1 -3
View File
@@ -62,9 +62,7 @@ randomiseAllLinks r = do
{- Shuffle the order of all links of a room randomly. {- Shuffle the order of all links of a room randomly.
- Note this does not change their types. -} - Note this does not change their types. -}
shuffleLinks :: RandomGen g => Room -> State g Room shuffleLinks :: RandomGen g => Room -> State g Room
shuffleLinks r = do shuffleLinks = rmLinks %%~ shuffle
newLinks <- shuffle $ _rmLinks r
return $ r {_rmLinks = newLinks }
filterLinks :: RandomGen g => ((Point2,Float) -> Bool) -> Room -> State g Room filterLinks :: RandomGen g => ((Point2,Float) -> Bool) -> Room -> State g Room
filterLinks cond r = do filterLinks cond r = do
+11 -13
View File
@@ -2,7 +2,7 @@ module Dodge.Room.RunPast where
import Dodge.UseAll import Dodge.UseAll
import Dodge.LevelGen.Data import Dodge.LevelGen.Data
import Dodge.LightSource import Dodge.LightSource
import Dodge.RoomLink --import Dodge.RoomLink
import Dodge.Data import Dodge.Data
--import Dodge.Default --import Dodge.Default
--import Dodge.Layout.Tree.Either --import Dodge.Layout.Tree.Either
@@ -44,14 +44,13 @@ critRoom = corridorWallN & rmRandPSs .~ [psRandRanges (15,25) (30,45) (pi,2*pi)]
runPastRoom :: RandomGen g => Int -> State g (Tree Room) runPastRoom :: RandomGen g => Int -> State g (Tree Room)
runPastRoom i = do runPastRoom i = do
h <- state $ randomR (200,400::Float) h <- state $ randomR (200,400::Float)
theedgetest <- takeOne [horEdgeTest (<1), horEdgeTest (>39)] thels <- roomCritLS
thels <- roomCritLS theweapon <- randBlockBreakWeapon
theweapon <- randBlockBreakWeapon --cenroom <- shuffleLinks $ restrictRMInLinksPD (\(V2 _ y,_) -> y < 1)
cenroom <- shuffleLinks $ restrictRMInLinksPD (\(V2 _ y,_) -> y < 1) cenroom <- shuffleLinks
$ roomRectAutoLinks 40 h & rmPmnts .~ [plRRpt 0 (PutFlIt theweapon)] $ roomRectAutoLinks 40 h & rmPmnts .~ [plRRpt 0 (PutFlIt theweapon)]
theedge <- takeOne [West,East] theedge <- takeOne $ map OnEdge [West,East]
--let cenroom = filterSortOutLinksOn theedgetest ((\(V2 a b) -> (a,b)) . fst)
let linkcor = critRoom & rmPmnts .~ [ spanLS thels (V2 0 65) (V2 40 65) ] let linkcor = critRoom & rmPmnts .~ [ spanLS thels (V2 0 65) (V2 40 65) ]
critroom = linkcor & rmPmnts .:~ plRRpt 0 randC1 critroom = linkcor & rmPmnts .:~ plRRpt 0 randC1
aswitchroom = corridorWallN aswitchroom = corridorWallN
@@ -59,11 +58,10 @@ runPastRoom i = do
,_rmPmnts = [] ,_rmPmnts = []
} }
switchdoor = triggerDoorRoom i switchdoor = triggerDoorRoom i
n = length $ filter theedgetest $ map lnkPosDir $ _rmLinks cenroom n = length $ filter (elem theedge . _rlType) $ _rmLinks cenroom
controom = treeFromPost [ switchdoor, linkcor,corridor,corridor] (useAll door) controom = treeFromPost [ switchdoor, linkcor,corridor,corridor] (useAll door)
critrooms :: [Tree Room] doorrooms = treeFromPost [ switchdoor] critroom
critrooms = treeFromPost [ switchdoor] critroom
: replicate (n-2) (treeFromPost [ switchdoor] linkcor) : replicate (n-2) (treeFromPost [ switchdoor] linkcor)
return $ Node cenroom $ return $ Node cenroom $
map (over root $ rmConnectsTo .~ S.member (OnEdge theedge)) (controom : critrooms) map (over root $ rmConnectsTo .~ S.member theedge) (controom : doorrooms)
++ [return aswitchroom] ++ [return aswitchroom]
+11 -8
View File
@@ -1,4 +1,4 @@
--{-# LANGUAGE TupleSections #-} {-# LANGUAGE TupleSections #-}
module Dodge.Room.Start where module Dodge.Room.Start where
import Dodge.UseAll import Dodge.UseAll
import Dodge.Data import Dodge.Data
@@ -53,12 +53,12 @@ startRoom i = join (takeOne
[-- (,) (0.5::Float) ((chainUses <$> sequence [powerFakeout,fmap fst $weaponRoom i]) [-- (,) (0.5::Float) ((chainUses <$> sequence [powerFakeout,fmap fst $weaponRoom i])
-- <&> (,TreeSubLabelling "chainUses <$> sequence [powerFakeout,weaponRoom i]" Nothing)) -- <&> (,TreeSubLabelling "chainUses <$> sequence [powerFakeout,weaponRoom i]" Nothing))
-- wat -- wat
rezBoxesWp >>= rToOnward "rezBoxesWp" -- rezBoxesWp >>= rToOnward "rezBoxesWp"
, rezBoxThenWeaponRoom i -- , rezBoxThenWeaponRoom i
, rezBoxesWpCrit >>= rToOnward "rezBoxesWpCrit" -- , rezBoxesWpCrit >>= rToOnward "rezBoxesWpCrit"
, runPastStart i >>= rToOnward ("runPastStart " ++ show i) runPastStart i >>= rToOnward ("runPastStart " ++ show i)
, startCrafts >>= roomsContaining' [] >>= rezBoxThenRooms -- , startCrafts >>= roomsContaining' [] >>= rezBoxThenRooms
>>= rToOnward "startCrafts >>= roomsContaining [] >>= rezBoxThenRooms" -- >>= rToOnward "startCrafts >>= roomsContaining [] >>= rezBoxThenRooms"
]) ])
randomChallenges :: RandomGen g => State g (LabTree Room) randomChallenges :: RandomGen g => State g (LabTree Room)
randomChallenges = shootingRange randomChallenges = shootingRange
@@ -72,7 +72,10 @@ runPastStart :: RandomGen g => Int -> State g (Tree Room)
runPastStart i = do runPastStart i = do
s <- rezBoxStart s <- rezBoxStart
rp <- runPastRoom i rp <- runPastRoom i
return $ s `passUntiluseAll` [rp] --return $ s `passUntiluseAll` [rp]
return . shiftChildren $ attachTree toOnward' rp $ fmap ([],) s
-- return . shiftChildren $ attachTree toOnward' (pure $ useAll corridor) $ fmap ([],) s
rezBoxStart :: RandomGen g => State g (Tree Room) rezBoxStart :: RandomGen g => State g (Tree Room)
rezBoxStart = do rezBoxStart = do
+7
View File
@@ -12,6 +12,8 @@ module Dodge.Tree.Compose
, overwriteLabel , overwriteLabel
, composeTree , composeTree
, composeTree' , composeTree'
, shiftChildren
, attachTree
, composeTreeRand , composeTreeRand
-- , compTree -- , compTree
) where ) where
@@ -124,6 +126,11 @@ newf t = safeUpdateSingleNode (isJust . upf . snd) ( (root . _2 %~ g) . (root .
upf = t ^?! root . _1 upf = t ^?! root . _1
g x = fromMaybe x (upf x) g x = fromMaybe x (upf x)
attachTree :: (a -> Maybe a) -> Tree a -> Tree ([Tree a],a) -> Tree ([Tree a],a)
attachTree upf t = safeUpdateSingleNode (isJust . upf . snd) ( (root . _2 %~ g) . (root . _1 .:~ t ) )
where
g x = fromMaybe x (upf x)
shiftChildren :: Tree ([Tree a],a) -> Tree a shiftChildren :: Tree ([Tree a],a) -> Tree a
shiftChildren (Node (ts,x) ts') = Node x (ts ++ map shiftChildren ts') shiftChildren (Node (ts,x) ts') = Node x (ts ++ map shiftChildren ts')
+5 -1
View File
@@ -8,9 +8,13 @@ import qualified Data.Set as S
toOnward :: String -> Room -> Maybe ([String],Room) toOnward :: String -> Room -> Maybe ([String],Room)
toOnward s rm toOnward s rm
| OnwardCluster `elem` rm ^?! rmClusterStatus . csLinks = Just ([s],rm) | OnwardCluster `elem` rm ^?! rmClusterStatus . csLinks
= Just ([s],rm & rmClusterStatus . csLinks . at OnwardCluster .~ Nothing)
| otherwise = Nothing | otherwise = Nothing
toOnward' :: Room -> Maybe Room
toOnward' = fmap snd . toOnward ""
rToOnward :: Monad m => String -> Tree Room -> m (Room -> Maybe ([String],Room), Tree Room) rToOnward :: Monad m => String -> Tree Room -> m (Room -> Maybe ([String],Room), Tree Room)
rToOnward s = return . (toOnward s ,) rToOnward s = return . (toOnward s ,)