Improve rooms

This commit is contained in:
2022-03-17 19:37:17 +00:00
parent f8f60537c6
commit c4a8912441
7 changed files with 58 additions and 59 deletions
+28 -26
View File
@@ -7,7 +7,8 @@ import Dodge.Default.Room
import Dodge.Item.Weapon.BulletGuns
import Dodge.Item.Weapon.Launcher
import Dodge.Creature
import Dodge.Room.Foreground
import Dodge.Room.Pillar
import Dodge.Room.Modify.Girder
import Dodge.LevelGen.Data
import Dodge.RandomHelp
import Dodge.Default.Wall
@@ -23,8 +24,9 @@ import Geometry
import Tile
import MonadHelp
import LensHelp
--import Color
--import qualified Data.Set as S
import qualified Data.Set as S
import Control.Monad.State
--import Control.Monad.Loops
import System.Random
@@ -54,18 +56,6 @@ roomPadCut ps p = defaultRoom
, _rmLinks = muout [(p,0)] ++ muin [(V2 0 0,pi)]
, _rmPath = [(V2 0 0,p)]
}
roomPillars :: Room
roomPillars = roomRect 240 240 2 2
& rmPmnts .~ plmnts
where
plmnts = spanLightI (V2 120 24) (V2 120 216)
: mntLS vShape (V2 12 12) (V3 25 25 70)
: mntLS vShape (V2 228 228) (V3 215 215 70)
: sps0 (PutShape $ thinHighBar 75 (V2 26 25) (V2 120 25))
: sps0 (PutShape $ thinHighBar 75 (V2 214 215) (V2 120 215))
: g 180 150 90 60
f a x b y = putBlockRect a x b y
g a b c d = f a b a b ++ f a b c d ++ f c d a b ++ f c d c d
branchWith :: Room -> [Tree Room] -> SubCompTree Room
branchWith r ts = Node (PassDown r) $ return (UseAll door) : fmap (fmap PassDown) ts
@@ -74,7 +64,6 @@ branchWith r ts = Node (PassDown r) $ return (UseAll door) : fmap (fmap PassDown
manyDoors :: Int -> SubCompTree Room
manyDoors i = treeFromPost (replicate i (PassDown door)) $ UseAll door
glassSwitchBack :: RandomGen g => State g Room
glassSwitchBack = do
wth <- state $ randomR (200,400)
@@ -102,6 +91,7 @@ glassSwitchBack = do
return $ roomRect wth hgt 2 4
& rmPmnts .~ plmnts
& rmRandPSs .~ [northPSs,midPS]
& rmName .~ "glassSwitchBack"
glassSwitchBackCrits :: RandomGen g => State g Room
glassSwitchBackCrits = glassSwitchBack
@@ -143,7 +133,7 @@ rot90Around cen p = cen +.+ vNormal (p -.- cen)
roomMiniIntro :: RandomGen g => State g (SubCompTree Room)
roomMiniIntro = do
midroom <- join $ takeOne [miniTree2] --,glassLesson]
return $ chainUses [return $ UseAll door, midroom,return $ UseAll corridor]
return $ chainUses [return $ UseAll corridor,return $ UseAll corridor,return $ UseAll corridor,return $ UseAll door, midroom,return $ UseAll corridor]
roomCenterPillar :: RandomGen g => State g Room
roomCenterPillar = randomiseAllLinks . restrictInLinks ((\p -> dist p (V2 120 0) < 10) . fst)
@@ -206,7 +196,8 @@ weaponEmptyRoom = do
,mntLightLnkCond useUnusedLnk
]
f (V2 x y,a) = (a == pi && x > 25 && x < w - 25) || (a /= 0 && y > w - 30)
rm <- shuffleLinks $ restrictRMInLinksPD f (roomRect w h 2 2 & rmPmnts .~ plmnts)
rm <- addHighGirder >=> shuffleLinks
$ restrictRMInLinksPD f (roomRect w h 2 2 & rmPmnts .~ plmnts)
return $ treeFromTrunk [PassDown corridor] (singleUseAll rm )
weaponUnderCrits :: RandomGen g => State g (SubCompTree Room)
@@ -222,7 +213,7 @@ weaponUnderCrits = do
(singleUseAll (set rmPmnts plmnts corridorN))
rcp <- roomCenterPillar
deadEndRoom' <- takeOne
[ addwpat (V2 120 20) roomPillars
[ addwpat (V2 120 20) (roomPillars 0 240 240 2 2)
, addwpat (V2 120 20) rcp]
junctionRoom <- takeOne [PassDown tEast,PassDown tWest]
return $ treeFromTrunk [PassDown corridorN,PassDown corridorN]
@@ -251,10 +242,21 @@ weaponBehindPillar = do
weaponBetweenPillars :: RandomGen g => State g (SubCompTree Room)
weaponBetweenPillars = do
let wpPos = unusedSpotNearInLink 100
w <- state $ randomR (240,360)
h <- state $ randomR (240,360)
let wpPos = rprBool $ \rp r -> and
[ RoomPosOnPath `S.member` _rpType rp
, _rpPlacementUse rp == 0
, _rpLinkStatus rp == NotLink
, any ((<100) . dist (_rpPos rp)) (usedRoomInLinkPoss r)
]
ncrits <- state $ randomR (1,3)
critPlacementSpots <- replicateM ncrits $ randDirPS $ unusedSpotAwayFromInLink 100
let theRoom = roomPillars & rmPmnts .++~
critPlacementSpots <- replicateM ncrits $ randDirPS $ rprBool $ \rp r -> and
[ RoomPosOnPath `S.member` _rpType rp
, _rpPlacementUse rp == 0
, all ((>100) . dist (_rpPos rp)) (usedRoomLinkPoss r)
]
let theRoom = roomPillars 0 w h 1 1 & rmPmnts .++~
sps wpPos (RandPS randFirstWeapon) : map (`sps` randC1) critPlacementSpots
return $ singleUseAll theRoom
@@ -290,11 +292,11 @@ deadEndRoom = defaultRoom
{- A random Either tree with a weapon and melee monster challenge. -}
weaponRoom :: RandomGen g => State g (SubCompTree Room)
weaponRoom = join $ takeOne
[ weaponEmptyRoom
, weaponUnderCrits
, weaponBehindPillar
, weaponBetweenPillars
, weaponLongCorridor
-- [ weaponEmptyRoom
-- , weaponUnderCrits
-- , weaponBehindPillar
[ weaponBetweenPillars
-- , weaponLongCorridor
]
roomCCrits :: RandomGen g => State g Room