64 lines
1.7 KiB
Haskell
64 lines
1.7 KiB
Haskell
{- |
|
|
Rooms that contain valuable items, typically protected in some manner.
|
|
Typically dead ends.
|
|
-}
|
|
module Dodge.Room.Treasure where
|
|
|
|
--import Control.Monad.State
|
|
import Control.Monad.Trans.State.Lazy
|
|
import Dodge.Data.GenWorld
|
|
import Dodge.Default.Room
|
|
import Dodge.LevelGen.PlacementHelper
|
|
import Dodge.Placement.Instance
|
|
import Dodge.RoomLink
|
|
import Geometry
|
|
|
|
--import Control.Lens
|
|
--import System.Random
|
|
|
|
{- | A triangular room with loot at the top (with 'PutID' 2),
|
|
creatures in the bottom two corners (with 'PutID' 0),
|
|
and (single) entrance bottom middle.
|
|
-}
|
|
triLootRoom ::
|
|
Float -> -- Width
|
|
Float -> -- Height
|
|
State g Room
|
|
triLootRoom w h =
|
|
pure $
|
|
defaultRoom
|
|
{ _rmPolys =
|
|
[ tri
|
|
, base
|
|
]
|
|
, _rmLinks = [inLink (V2 0 (-80)) pi]
|
|
, _rmPath = doublePairSet (V2 0 (-80), V2 0 (h / 2))
|
|
, _rmPmnts =
|
|
[ sPS (V2 (15 - w) 15) 0 $ PutID 0
|
|
, sPS (V2 (w -15) 15) pi $ PutID 0
|
|
, sPS (V2 0 (h -35)) 0 $ PutID 2
|
|
, mntLS vShape (V2 0 (h -20)) (V3 0 (h -80) 70)
|
|
, sPS (V2 0 (-60)) 0 putLamp
|
|
]
|
|
, _rmBound = [tri, base]
|
|
}
|
|
where
|
|
tri =
|
|
map
|
|
toV2
|
|
[ (- w, 30)
|
|
, (- w, 0)
|
|
, (w, 0)
|
|
, (w, 30)
|
|
, (20, h)
|
|
, (-20, h)
|
|
]
|
|
base = rectNSWE 20 (-80) (-20) 20
|
|
|
|
-- | Create a random room with one entrance containing given creatures and items.
|
|
lootRoom :: [Creature] -> [Item] -> State g Room
|
|
lootRoom crs itms = do
|
|
let w = 300
|
|
h = 700
|
|
replacePutID 0 (map PutCrit crs) . replacePutID 2 (map PutFlIt itms) <$> triLootRoom w h
|