Fix room bugs

This commit is contained in:
2022-06-14 12:27:21 +01:00
parent 88e5f40f06
commit 79aab975c8
4 changed files with 14 additions and 48 deletions
+1
View File
@@ -41,6 +41,7 @@ initialAnoTree = OnwardList
$ intersperse (AnTree $ tToBTree "cori" . pure <$> shuffleLinks (cleatOnward corridor))
[ IntAnno $ AnTree . startRoom
-- , (SpecificRoom . return . tToBTree $ treePost [corridor,corridor,cleatOnward corridor])
, AnTree $ tToBTree "spawners" <$> spawnerRoom
, AnRoom $ pistolerRoom
, AnRoom doubleCorridorBarrels
, IntAnno $ PassthroughLockKeyLists
+5 -3
View File
@@ -16,8 +16,8 @@ import Picture
import qualified Data.IntMap.Strict as IM
{- | A passage with a switch that opens forward access while closing backwards access. -}
airlock :: RandomGen g => State g Room
airlock = takeOne [airlock0,airlock90,airlockCrystal,airlockZ]
--airlock = takeOne [airlockZ]
--airlock = takeOne [airlock0,airlock90,airlockCrystal,airlockZ]
airlock = takeOne [airlockCrystal]
{- | Straight airlock -}
airlock0 :: Room
airlock0 = defaultRoom
@@ -145,7 +145,9 @@ airlockCrystal = defaultRoom
, mntLS vShape (V2 150 70) (V3 110 70 70)
]
, _rmBound =
[ ]
[ rectNSWE 120 20 0 40
, orderPolygon $ map toV2 [ (39,20) , (150,60) , (150,80) , (39,120) ]
]
}
where
--cond w = or $ M.lookup (DoorNumOpen n) (_worldState w)
+1 -9
View File
@@ -35,19 +35,11 @@ crossPillar w' h' = ps0jPushPS (aline (V2 (-w) 0) (V2 w 0))
h = h' - 9
aline = PutLineBlock baseBlockPane StoneBlock 9 9
roomPillars :: RandomGen g => Float -> Float -> Float -> Int -> Int -> State g Room
roomPillars pillarsize w h wn hn = do
let rm = roomRect w h wn hn
npillars = length $ filter (S.member RoomPosOffPath . _rpType) $ _rmPos rm
let plmnts = -- sps0 (PutShape $ colorSH black $ girderV 96 20 10 (V2 0 120) (V2 w 120))
-- : sps0 (PutShape $ colorSH black $ girderV 96 20 10 (V2 220 h) (V2 220 (h/2 + 10)))
-- : sps0 (PutShape $ colorSH black $ girderV 96 20 10 (V2 120 0) (V2 120 (h/2 - 10)))
-- : sps (PS (V2 20 120) 0) (PutLS $ lsColPos 0.75 (V3 0 0 90))
-- : sps (PS (V2 (w - 20) 120) 0) (PutLS $ lsColPos 0.75 (V3 0 0 90))
-- : sps (PS (V2 220 (h-20)) 0) (PutLS $ lsColPos 0.75 (V3 0 0 90))
-- : sps (PS (V2 120 20) 0) (PutLS $ lsColPos 0.75 (V3 0 0 90))
replicate npillars (blockPillar (0.5*pilw) (0.5*pilh) & plSpot .~ rprBool
let plmnts = replicate npillars (blockPillar (0.5*pilw) (0.5*pilh) & plSpot .~ rprBool
(\rp _ -> RoomPosOffPath `S.member` _rpType rp
&& _rpPlacementUse rp == 0
&& _rpLinkStatus rp == NotLink )
+7 -36
View File
@@ -6,6 +6,7 @@ module Dodge.Room.Room
, roomCCrits
, doubleCorridorBarrels
, pistolerRoom
, spawnerRoom
) where
import Dodge.UseAll
import Dodge.Data
@@ -298,44 +299,14 @@ shootersRoom1 = shootersRoom' <&> rmPmnts %~
) :)
shootersRoom :: RandomGen g => State g Room
shootersRoom = shootersRoom' <&> rmPmnts %~
( map (\i -> spNoID (PSRoomRand i (uncurry PS)) (PutCrit autoCrit))
[0,1,2]
++ )
shootersRoom = shootersRoom' <&> rmPmnts .++~
map (\i -> spNoID (PSRoomRand i (uncurry PS)) (PutCrit autoCrit)) [0,1,2]
pillarGrid :: RandomGen g => State g Room
pillarGrid = do
let f2 x y = singleBlock (V2 x y)
f <- takeOne [f2]
h <- state $ randomR (200,400)
let w = h
i <- takeOne [3,4,5]
let j = fromIntegral i
-- the 20+etc here is to correct for the pathfinding grid, which matches up to
-- edges based on the size of doors (i.e. the line next to the wall is 20
-- away from it)
xs = take i [20+0.5*(w-40)/j,20+1.5*(w-40)/j..]
ys = take i [20+0.5*(h-40)/j,20+1.5*(h-40)/j..]
gap = 0.5 * h / (j+1)
rps = do
x <- takeOne xs
y <- takeOne ys
a <- state $ randomR (0,2*pi)
return (V2 (x+gap) y,a)
-- the following was used to stop lights from being mounted in corners and
-- potentially overlapping, might want to redo
-- cornerRestrict (V2 x y,_)
-- = (x > 40 && x < h - 40)
-- || (y > 40 && y < h - 40)
let plmnts = replicate 8 (mntLightLnkCond useUnusedLnk) ++ concat [f x y | x<-xs,y<-ys]
return $ roomRect w h (max i 2) (max i 2)
& rmPmnts .~ plmnts
& rmRandPSs .~ [rps]
-- TODO remove possible identical draws on random PSs
-- TODO stop from spawning on inlinks fromedge
pistolerRoom :: RandomGen g => State g Room
pistolerRoom = pillarGrid <&> rmPmnts .++~
replicate 3
pistolerRoom = do
(w,wn) <- takeOne [(200,3),(255,4)]
roomPillars 10 w 200 wn 3 <&> rmPmnts .++~ replicate 3
(spNoID (rprBool $ \rp _ -> _rpPlacementUse rp == 0 && RoomPosOnPath `S.member` _rpType rp)
(PutCrit pistolCrit))