Working implementation of light change when door opens
This commit is contained in:
@@ -17,7 +17,7 @@ corridor = defaultRoom
|
||||
, _rmLinks = lnks
|
||||
, _rmPath = concatMap (doublePair . (,) (V2 20 60) . fst) lnks
|
||||
, _rmPS =
|
||||
[sPS (V2 20 40) 0 $ PutLS (lightAt (V3 0 0 50) 0) (lampPic 50)
|
||||
[sPS (V2 20 40) 0 $ PutLS (lightAt (V3 0 0 50) 0)
|
||||
,sPS (V2 0 0) 0 $ PutForeground $ highPipe 55 (V2 0 40) (V2 40 40)
|
||||
]
|
||||
, _rmBound = [ rectNSWE 50 30 0 40 ]
|
||||
|
||||
@@ -24,7 +24,7 @@ import Control.Lens
|
||||
import Control.Monad.State
|
||||
import Data.Tree
|
||||
import qualified Data.Map as M
|
||||
--import qualified Data.IntMap as IM
|
||||
import qualified Data.IntMap as IM
|
||||
|
||||
twinSlowDoorRoom
|
||||
:: Int -- ^ Door id
|
||||
@@ -44,19 +44,24 @@ twinSlowDoorRoom drid w h x = defaultRoom
|
||||
[ sPS (V2 0 (h/2)) 0 putLamp
|
||||
, sPS (V2 25 5) 0 putLamp
|
||||
, sPS (V2 (negate 25) 5) 0 putLamp
|
||||
, sPS (V2 0 0) 0 $ PutSingleDoor col cond (V2 x 1) (V2 x h) 1
|
||||
, sPS (V2 0 0) 0 $ PutSingleDoor col cond (V2 (-x) 1) (V2 (-x) h) 1
|
||||
, sPS (V2 0 0) 0 $ PutSingleDoor col cond (V2 x 1) (V2 x h) 1
|
||||
, Placement (PS (V2 0 0) 0 $ PutSingleDoor col cond (V2 (-x) 1) (V2 (-x) h) 1)
|
||||
$ \did -> Just $ Placement (PS (V2 0 (h-1)) 0 $ PutLS (colorLightAt (V3 0.75 0 0) (V3 0 0 lampHeight) 0))
|
||||
$ \lsid -> Just $ sPS (V2 0 (h-1)) 0 $ PutProp $ addColorChange lsid did $ lampCoverWhen (drmoving did) lampHeight
|
||||
, sPS (V2 0 (h-5)) pi $ PutButton $ makeSwitch col red
|
||||
(worldState %~ M.insert (DoorNumOpen drid) True )
|
||||
(worldState %~ M.insert (DoorNumOpen drid) False)
|
||||
, sPS (V2 0 (h-1)) 0 $ PutLS (colorLightAt (V3 0.75 0 0) (V3 0 0 lampHeight) 0) (lampPic lampHeight)
|
||||
, sPS (V2 0 (h-1)) 0 $ PutProp $ lampCoverWhen drmoving lampHeight
|
||||
]
|
||||
, _rmBound = ps
|
||||
, _rmName = "twinSlowDoorRoom"
|
||||
}
|
||||
where
|
||||
drmoving _ = True -- DoorHalfway == _drStatus (_doors w' IM.! drid)
|
||||
addColorChange lsid drid = over pjUpdate $ chain $ const f
|
||||
where
|
||||
f w' | _drStatus (_doors w' IM.! drid) == DoorHalfway
|
||||
= w' & lightSources . ix lsid . lsIntensity .~ V3 8 0 0
|
||||
| otherwise = w' & lightSources . ix lsid . lsIntensity .~ 0.7
|
||||
drmoving i w' = DoorHalfway == _drStatus (_doors w' IM.! i)
|
||||
lampHeight = 41
|
||||
ps =
|
||||
[rectNSWE h 0 (-w) w
|
||||
|
||||
Reference in New Issue
Block a user