Fix placement movement bug

This commit is contained in:
2021-10-01 09:51:47 +01:00
parent 4b5a75f4af
commit 5f17841811
6 changed files with 23 additions and 26 deletions
+12 -18
View File
@@ -34,7 +34,8 @@ import Data.Tile
--import Data.List
--import Data.Function (on)
--import qualified Data.Tuple.Extra as Tup
import qualified Data.Map as M
--import qualified Data.Map.Strict as M
import qualified Data.IntMap.Strict as IM
import Control.Lens
import Control.Monad
import Control.Monad.State
@@ -215,19 +216,12 @@ randomFourCornerRoom = do
{- | Creates room with a central vault with doors around it.
-}
centerVaultRoom
:: Int -- ^ Door id
-> Float -- ^ Width
:: Float -- ^ Width
-> Float -- ^ Height
-> Float -- ^ Vault dimensions
-> State g Room
centerVaultRoom n w h d = do
let northPoly = rectNSWE h d (-w) w
nsDoors = rectNSWE (d + 20) (negate (d +20)) (-20) 20
weDoors = rectNSWE 20 (-20) (d + 20) (negate (d +20))
centerPoly = rectWdthHght (d - 20) (d - 20)
--polys = centerPoly : nsDoors : weDoors : take 4 (iterate (map vNormal) northPoly)
centerVaultRoom w h d = do
return $ defaultRoom
--{ _rmPolys = polys
{ _rmPolys = [rectNSWE h (-h) (-w) w]
, _rmLinks =
[(V2 0 h , 0 )
@@ -247,17 +241,17 @@ centerVaultRoom n w h d = do
,mountedLight (V2 w (h/2-20)) (V3 (w-20) (h/2-20) 70)
,mountedLightV (V2 0 (d-20)) (V3 0 0 70)
]
++ concat (zipWith (\i r -> map (shiftPSBy (V2 0 0,r)) $ theDoor i)
[n, n+1, n+2, n+3] [0,pi/2,pi,3*pi/2])
++ concat (map (\r -> map (shiftPSBy (V2 0 0,r)) $ theDoor)
[0,pi/2,pi,3*pi/2])
, _rmBound = [rectNSWE h (-h) (-w) w]
}
where
col = dim $ dim $ bright red
theDoor i =
[ sPS (V2 0 (d-10)) 0 $ PutDoubleDoor col (cond i) (V2 (-21) 0) (V2 21 0) 2
, sPS (V2 35 (d+4)) 0 $ PutButton $ makeSwitch col red
(over worldState (M.insert (DoorNumOpen i) True))
(over worldState (M.insert (DoorNumOpen i) False))
theDoor =
[ Placement (PS (V2 35 (d+4)) 0 $ PutButton $ makeSwitch col red id id)
$ \btid -> jspsJ (V2 0 (d-10)) 0 (PutSingleDoor col (cond' btid) (V2 (-21) 0) (V2 0 0) 2)
$ sPS (V2 0 (d-10)) 0 (PutSingleDoor col (cond' btid) (V2 21 0) (V2 0 0) 2)
]
cond i w' = or $ M.lookup (DoorNumOpen i) (_worldState w')
--cond i w' = or $ M.lookup (DoorNumOpen i) (_worldState w')
cond' btid w' = _btState (_buttons w' IM.! btid) == BtOn