Refactor, try to limit dependencies

This commit is contained in:
2022-07-28 00:59:56 +01:00
parent 8aa5c17ab9
commit 160560af5f
418 changed files with 15104 additions and 13342 deletions
+47 -40
View File
@@ -2,52 +2,59 @@
Rooms that contain valuable items, typically protected in some manner.
Typically dead ends.
-}
module Dodge.Room.Treasure
where
import Dodge.Data
import Dodge.RoomLink
import Dodge.Placement.Instance
module Dodge.Room.Treasure where
import Control.Monad.State
import Dodge.Data.GenWorld
import Dodge.Default.Room
import Dodge.LevelGen.Data
import Dodge.Placement.Instance
import Dodge.RoomLink
import Geometry
--import Data.List
import Control.Monad.State
--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 = [uncurry 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]
}
--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 = [uncurry 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. -}
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