Some cleanup, sidetracked from inter-room placements

This commit is contained in:
2021-11-12 14:16:16 +00:00
parent 1d5b2ea765
commit 67e164c830
13 changed files with 160 additions and 116 deletions
+6 -3
View File
@@ -5,6 +5,7 @@ module Dodge.Room.Data
import Dodge.LevelGen.Data
import Geometry.Data
import Data.Tile
import Dodge.Data
import Control.Monad.State
import System.Random
@@ -22,17 +23,19 @@ assigning no bounds will allow rooms to overlap.
data Room = Room
{ _rmPolys :: [ [Point2] ]
, _rmLinks :: [(Point2,Float)]
, _rmUsedLinks :: [RoomPos]
, _rmPos :: [RoomPos]
, _rmPath :: [(Point2, Point2)]
, _rmPmnts :: [Placement]
, _rmLabelledPmnts :: IM.IntMap Placement
, _rmPartialPmnts :: IM.IntMap (Int -> Placement)
, _rmTriggers :: IM.IntMap (World -> Bool)
, _rmTriggerPmnts :: IM.IntMap ((World -> Bool) -> Placement)
, _rmBound :: [ [Point2] ]
, _rmFloor :: [Tile]
, _rmName :: String
, _rmShift :: (Point2, Float)
, _rmViewpoints :: [Point2]
, _rmRandPSs :: [State StdGen (Point2,Float)]
, _rmLabel :: Maybe Int
, _rmTakeFrom :: Maybe Int
}
data RoomPos
= OutLink Int Point2 Float
+23 -6
View File
@@ -1,12 +1,13 @@
{-
Rooms that connect other rooms, blocking sight.
-}
{- Rooms that connect other rooms, blocking sight. -}
module Dodge.Room.Door
where
import Geometry
import Dodge.Room.Data
import Dodge.Default.Room
import Dodge.Placements
import Color
import qualified Data.IntMap.Strict as IM
door :: Room
door = defaultRoom
@@ -17,8 +18,24 @@ door = defaultRoom
, _rmPmnts = [putAutoDoor (V2 0 20) (V2 40 20)]
-- note no bounds
}
where lnks = [(V2 20 35,0)
,(V2 20 5,pi)
]
where
lnks = [(V2 20 35,0)
,(V2 20 5,pi)
]
switchDoor :: Room
switchDoor = defaultRoom
{ _rmPolys = [rectNSWE 40 0 0 40]
, _rmLinks = lnks
, _rmPath = [(V2 20 35,V2 20 5)]
-- door extends into side walls (for shadows as rendered 12/03)
, _rmTriggerPmnts = IM.fromList
[(0,\cond -> putDoubleDoor False red cond (V2 0 20) (V2 40 20) 2)]
-- note no bounds
}
where
lnks = [(V2 20 35,0)
,(V2 20 5,pi)
]
+3 -5
View File
@@ -1,10 +1,8 @@
{-
Concerns link pairs of rooms.
{- Concerns link pairs of rooms.
Link pairs determine where rooms can attach to each other; each pair consists
of a position and a rotation.
The last link in the list is considered the incoming link, the other links are
the outgoing links.
-}
the outgoing links. -}
module Dodge.Room.Link
( shiftRoomToLink
, shiftRoomBy
@@ -111,5 +109,5 @@ setLastLinkToUsed :: Room -> Room
setLastLinkToUsed rm = case _rmLinks rm of
(_:_) -> rm
& rmLinks %~ init
& rmUsedLinks %~ (uncurry InLink (last (_rmLinks rm)) :)
& rmPos %~ (uncurry InLink (last (_rmLinks rm)) :)
_ -> rm