Cleanup and various bugfixes
This commit is contained in:
@@ -66,14 +66,15 @@ roomRect x y xn yn = defaultRoom
|
||||
lnks = nlnks ++ elnks ++ wlnks ++ slnks
|
||||
pth = linksAndPath lnks $ map (bimap (+.+ V2 20 20) (+.+ V2 20 20)) (makeGrid xd xn yd yn)
|
||||
{- Creates a rectangular room, automatically creates links and pathfinding graph at a sensible size. -}
|
||||
-- it is not clear to me that this works for very small rooms (but it does seem
|
||||
-- to do so)
|
||||
roomRectAutoLinks :: Float -> Float -> Room
|
||||
roomRectAutoLinks x y = (roomRect x y ((ceiling x - 40) `div` 60) ((ceiling y - 40) `div` 60))
|
||||
roomRectAutoLinks x y = (roomRect x y xn yn)
|
||||
{_rmPmnts = plmnts}
|
||||
where
|
||||
plmnts =
|
||||
[mntLightLnkCond unusedLnkToPS
|
||||
-- ,sps0 $ PutForeground $ thinHighBarChain 50 $ rectNSWE y 0 0 x
|
||||
]
|
||||
xn = max 1 $ (ceiling x - 40) `div` 60
|
||||
yn = max 1 $ (ceiling y - 40) `div` 60
|
||||
plmnts = [mntLightLnkCond unusedLnkToPS ]
|
||||
{- Combines two rooms into one room.
|
||||
Mostly involves concatenation. -}
|
||||
combineRooms :: Room -> Room -> Room
|
||||
|
||||
+48
-8
@@ -1,7 +1,10 @@
|
||||
module Dodge.Room.Start where
|
||||
import Dodge.LevelGen.Data
|
||||
import Dodge.Data
|
||||
import Dodge.Layout.Tree.Either
|
||||
import Dodge.RandomHelp
|
||||
import Dodge.Room.Door
|
||||
import Dodge.Room.Room
|
||||
import Dodge.Room.Link
|
||||
import Dodge.Room.Procedural
|
||||
import Dodge.Room.Foreground
|
||||
@@ -23,23 +26,38 @@ import System.Random
|
||||
--import qualified Data.IntMap.Strict as IM
|
||||
|
||||
rezBox :: Room
|
||||
--rezBox = shiftRoomBy (V2 (-20) (-10),0) $ roomRect 40 20 1 1
|
||||
rezBox = roomRect 40 60 1 1
|
||||
& rmPmnts .~ [ spanColLightI (V3 0 0 0.5) 95 (V2 0 1) (V2 40 1) ]
|
||||
& rmPmnts .~ [ spanColLightI rezcol 95 (V2 0 1) (V2 40 1) ]
|
||||
|
||||
rezcol :: Point3
|
||||
rezcol = V3 0.0 0.1 0.5
|
||||
|
||||
rezInvBox :: Room
|
||||
rezInvBox = roomRect 40 60 1 1
|
||||
& rmPmnts .~ [ spanColLightI (V3 0 0 0.5) 95 (V2 0 59) (V2 40 59) ]
|
||||
& rmPmnts .~ [ spanColLightI rezcol 95 (V2 0 59) (V2 40 59) ]
|
||||
|
||||
crRezBox :: Room
|
||||
crRezBox = rezInvBox -- & rmPmnts %~ (sPS (V2 20 0) pi randC1 :)
|
||||
crRezBox = rezInvBox & rmPmnts %~ (sPS (V2 20 50) (1.5*pi) randC1 :)
|
||||
|
||||
wpRezBox :: Item -> Room
|
||||
wpRezBox wp = rezInvBox & rmPmnts %~ (sPS (V2 15 30) 1 (PutFlIt wp) :)
|
||||
|
||||
rezBoxesThenWeaponRoom :: RandomGen g => State g (Tree (Either Room Room))
|
||||
rezBoxesThenWeaponRoom = do
|
||||
rboxes <- rezBoxes
|
||||
wroom <- weaponRoom
|
||||
return $ rboxes `appendEitherTree` [wroom]
|
||||
|
||||
startRoom :: RandomGen g => State g (Tree (Either Room Room))
|
||||
startRoom = do
|
||||
w <- state $ randomR (100,400)
|
||||
startRoom = join $ takeOne
|
||||
[-- rezBoxesWp
|
||||
rezBoxesThenWeaponRoom
|
||||
--, rezBoxesWpCrit
|
||||
]
|
||||
|
||||
rezBoxesWpCrit :: RandomGen g => State g (Tree (Either Room Room))
|
||||
rezBoxesWpCrit = do
|
||||
w <- state $ randomR (200,400)
|
||||
h <- state $ randomR (40,40)
|
||||
theweapon <- randBlockBreakWeapon
|
||||
let bottomEdgeTest (V2 _ y,_) = y < 1
|
||||
@@ -63,8 +81,30 @@ startRoom = do
|
||||
adddoor rm = treeFromPost [Left door] (Left rm)
|
||||
onwardtree blcor = treeFromPost [Left door] (Right blcor)
|
||||
|
||||
randomRezBoxes :: RandomGen g => State g (Tree (Either Room Room))
|
||||
randomRezBoxes = do
|
||||
rezBoxesWp :: RandomGen g => State g (Tree (Either Room Room))
|
||||
rezBoxesWp = do
|
||||
w <- state $ randomR (100,400)
|
||||
h <- state $ randomR (40,40)
|
||||
theweapon <- randBlockBreakWeapon
|
||||
let bottomEdgeTest (V2 _ y,_) = y < 1
|
||||
centralRoom <- randomiseOutLinks =<< changeLinkTo bottomEdgeTest
|
||||
((roomRectAutoLinks w h) {_rmPmnts = []})
|
||||
blcor <- blockedCorridor'
|
||||
let n = length $ filter bottomEdgeTest $ _rmLinks centralRoom
|
||||
let rezrooms = map adddoor
|
||||
$ wpRezBox theweapon : replicate (n-2) rezInvBox
|
||||
centralRoom' <- changeLinkFrom bottomEdgeTest centralRoom
|
||||
return $ treeFromTrunk [Left rezBox
|
||||
, Left door
|
||||
]
|
||||
(Node (Left centralRoom') (rezrooms ++ [onwardtree blcor]))
|
||||
where
|
||||
--dbox = treeFromPost [Left door] (Left rezInvBox)
|
||||
adddoor rm = treeFromPost [Left door] (Left rm)
|
||||
onwardtree blcor = treeFromPost [Left door] (Right blcor)
|
||||
|
||||
rezBoxes :: RandomGen g => State g (Tree (Either Room Room))
|
||||
rezBoxes = do
|
||||
w <- state $ randomR (100,400)
|
||||
h <- state $ randomR (40,40)
|
||||
let bottomEdgeTest (V2 _ y,_) = y < 1
|
||||
|
||||
Reference in New Issue
Block a user