Add laser central room, using new placement/roompos functionality

This commit is contained in:
2021-11-21 17:44:32 +00:00
parent 48cd59069c
commit 2f3896345d
12 changed files with 127 additions and 76 deletions
+27 -4
View File
@@ -12,6 +12,7 @@ import ShapePicture
import Data.Maybe
import Control.Lens
import qualified Data.IntMap.Strict as IM
triggerSwitchSPic :: (Button -> SPic) -> PlacementSpot -> Placement
triggerSwitchSPic sdraw ps = psPtCont ps (PutTrigger (const False))
@@ -56,7 +57,9 @@ putLitButtonID col p a subpl = mntLSOn aShape (Just col) ls p'' (addZ 40 p')
changeLight lsid = lightSources . ix lsid . lsIntensity .~ V3 0 0.5 0
ls = defaultLS { _lsRad = 75 , _lsIntensity = V3 0.5 0 0 }
putLitButOnPos :: Color -> (RoomPos -> Maybe PlacementSpot) -> (Int -> Maybe Placement) -> Placement
putLitButOnPos :: Color
-> (RoomPos -> Maybe (PlacementSpot,RoomPos))
-> (Int -> Maybe Placement) -> Placement
putLitButOnPos col f subpl
= plSpot .~ thePS $ mntLSOn aShape (Just col) ls 0 (V3 0 (-40) 40)
$ \plmnt -> let lsid = fromJust $ _plMID plmnt
@@ -65,9 +68,29 @@ putLitButOnPos col f subpl
where
changeLight lsid = lightSources . ix lsid . lsIntensity .~ V3 0 0.5 0
ls = defaultLS { _lsRad = 75 , _lsIntensity = V3 0.5 0 0 }
thePS = PSLnk f (const id) Nothing
thePS = PSPos f (const id) Nothing
putLitButOnPosExtTrig :: Color -> (RoomPos -> Maybe PlacementSpot) -> Placement
-- creates a lit external trigger, passes the trigger placement forward
extTrigLitPos :: PlacementSpot -> (Placement -> Maybe Placement) -> Placement
extTrigLitPos ps f = psPtCont ps (PutTrigger (const False))
$ \tp -> Just $ pContID (ps' tp) (PutLS thels)
$ \lsid -> Just $ pContID (ps' tp) (PutMod $ themod lsid tp)
$ const (f tp)
where
ps' tp = _plSpot tp
themod lsid tp = ModIDID
{_mdID = 0
,_mdExternalID1 = lsid
,_mdExternalID2 = fromJust $ _plMID tp
,_mdUpdate = \md w -> if (_triggers w IM.! _mdExternalID2 md) w
then w & lightSources . ix (_mdExternalID1 md) . lsIntensity .~ V3 0 0.5 0
else w & lightSources . ix (_mdExternalID1 md) . lsIntensity .~ V3 0.5 0 0
}
thels = defaultLS {_lsIntensity = V3 0.5 0 0, _lsPos = V3 0 0 78, _lsRad = 75}
putLitButOnPosExtTrig :: Color
-> (RoomPos -> Maybe (PlacementSpot,RoomPos))
-> Placement
putLitButOnPosExtTrig col f
= psPtCont thePS (PutTrigger (const False))
$ \tp -> Just $ plSpot .~ _plSpot tp $ mntLSOn aShape (Just col) ls 0 (V3 0 (-40) 40)
@@ -80,4 +103,4 @@ putLitButOnPosExtTrig col f
oneff tid = triggers . ix tid .~ const True
changeLight lsid = lightSources . ix lsid . lsIntensity .~ V3 0 0.5 0
ls = defaultLS { _lsRad = 75 , _lsIntensity = V3 0.5 0 0 }
thePS = PSLnk f (const id) Nothing
thePS = PSPos f (const id) Nothing