Allow for rooms to inherit floor tiling from parents

This commit is contained in:
2021-11-26 13:57:22 +00:00
parent 123bcd2c94
commit 040849a550
9 changed files with 75 additions and 29 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
{-# LANGUAGE TupleSections #-}
module Dodge.Room.Corridor
where
module Dodge.Room.Corridor where
import Data.Tile
import Dodge.LevelGen.Data
import Dodge.RoomLink
--import Dodge.Room.Foreground
@@ -22,7 +22,7 @@ corridor = defaultRoom
, _rmPath = concatMap (doublePair . (,) (V2 20 60) . fst) lnks
, _rmPmnts = [ spanLightI (V2 0 40) (V2 40 40) ]
, _rmBound = [ rectNSWE 50 30 0 40 ]
, _rmFloor = [makeTileFromPoly poly 2]
, _rmFloor = Tiled [makeTileFromPoly poly 2]
, _rmRandPSs = [psRandRanges (10,30) (30,60) (0,2*pi)]
, _rmName = "Corridor"
}
+1 -1
View File
@@ -134,7 +134,7 @@ shiftRoomBy shift r = r
& rmPath %~ map (shiftPathBy shift)
& rmBound %~ fmap (map (shiftPointBy shift))
& rmShift %~ shiftPosDirBy shift
& rmFloor %~ map
& rmFloor . tiles %~ map
( (tilePoly %~ map (shiftPointBy shift))
. (tileZero %~ shiftPointBy shift )
. (tileX %~ shiftPointBy shift )
+5 -2
View File
@@ -52,7 +52,7 @@ roomRect x y xn yn = defaultRoom
, _rmPos = map (`UnusedSpot` 0) posps
, _rmPmnts = []
, _rmBound = [rectNSWE (y+5) (-5) (-5) (x+5)]
, _rmFloor = [Tile
, _rmFloor = Tiled [Tile
{ _tilePoly = rectNSWE y 0 0 x
, _tileZero = V2 0 0
, _tileX = V2 1 0
@@ -93,7 +93,7 @@ combineRooms r r' = defaultRoom
, _rmPmnts = map (shiftPlacement $ _rmShift r) (_rmPmnts r)
++ map (shiftPlacement $ _rmShift r') (_rmPmnts r')
, _rmBound = _rmBound r ++ _rmBound r'
, _rmFloor = _rmFloor r ++ _rmFloor r'
, _rmFloor = combineFloors (_rmFloor r) (_rmFloor r')
, _rmShift = (V2 0 0 , 0)
}
-- not that this assumes that any link paths are integral
@@ -102,6 +102,9 @@ clampPath = bimap f f
where
f (V2 x y) = V2 (g x) (g y)
g = (fromIntegral :: Int -> Float) . floor
combineFloors :: Floor -> Floor -> Floor
combineFloors f _ = f
{- Randomly generate a top fourth of a room possibly with a wall.
Add a light and a 'PutNothing' placement. -}
quarterRoomFlat :: RandomGen g => Float -> State g Room
+3 -2
View File
@@ -1,4 +1,5 @@
module Dodge.Room.Room where
import Data.Tile
import Dodge.Data
import Dodge.PlacementSpot
import Dodge.RoomLink
@@ -206,7 +207,7 @@ roomOctogon = defaultRoom
, _rmPath = allPairs $ map fst lnks -- this is too much
, _rmPmnts = []
, _rmBound = [map toV2 [(-20,30),(20,30),(60,70),(60,110),(20,150),(-20,150),(-60,110),(-60,70)] ]
, _rmFloor = [makeTileFromPoly poly 7]
, _rmFloor = Tiled [makeTileFromPoly poly 7]
}
where
poly = map toV2 [(-20,40),(20,40),(50,70),(50,110),(20,140),(-20,140),(-50,110),(-50,70)]
@@ -228,7 +229,7 @@ roomNgon n x = defaultRoom
, _rmPath = [] -- TODO
, _rmPmnts = []
, _rmBound = [poly]
, _rmFloor = [makeTileFromPoly poly 9]
, _rmFloor = Tiled [makeTileFromPoly poly 9]
, _rmName = show n ++ "gon"
}
where