Refactor light sources
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
module Dodge.Placement.Instance.Button where
|
||||
import Dodge.Data
|
||||
import Dodge.LightSource
|
||||
import Color
|
||||
import Geometry
|
||||
import Geometry.Vector3D
|
||||
@@ -30,10 +31,10 @@ triggerSwitchSPicLight sdraw ps = psPtCont ps (PutTrigger (const False))
|
||||
$ pContID ps (PutButton (makeSwitchSPic sdraw (oneff lsid $ trigid tp) (offeff lsid $ trigid tp)))
|
||||
(const Nothing)
|
||||
where
|
||||
thels = defaultLS {_lsIntensity = V3 0.5 0 0, _lsPos = V3 0 0 78, _lsRad = 75}
|
||||
thels = lsColPosRad (V3 0.5 0 0) (V3 0 0 78) 75
|
||||
trigid tp = fromJust $ _plMID tp
|
||||
eff lsid tid b c = (triggers . ix tid .~ const b)
|
||||
. (lightSources . ix lsid . lsIntensity .~ c)
|
||||
. (lightSources . ix lsid . lsParam . lsCol .~ c)
|
||||
oneff lsid tid = eff lsid tid True (V3 0 0.5 0)
|
||||
offeff lsid tid = eff lsid tid False (V3 0.5 0 0)
|
||||
|
||||
@@ -54,8 +55,8 @@ putLitButtonID col p a subpl = mntLSOn aShape (Just col) ls p'' (addZ 40 p')
|
||||
where
|
||||
p' = p -.- 30 *.* vNormal (unitVectorAtAngle a)
|
||||
p'' = p +.+ 10 *.* vNormal (unitVectorAtAngle a)
|
||||
changeLight lsid = lightSources . ix lsid . lsIntensity .~ V3 0 0.5 0
|
||||
ls = defaultLS { _lsRad = 75 , _lsIntensity = V3 0.5 0 0 }
|
||||
changeLight lsid = lightSources . ix lsid . lsParam . lsCol .~ V3 0 0.5 0
|
||||
ls = lsRadCol 75 (V3 0.5 0 0)
|
||||
|
||||
putLitButOnPos :: Color
|
||||
-> (RoomPos -> Room -> Maybe (PlacementSpot,RoomPos))
|
||||
@@ -66,10 +67,11 @@ putLitButOnPos col f subpl
|
||||
in jps0 (PutButton (makeButton col (changeLight lsid)) {_btPos = V2 0 (-1), _btRot = pi})
|
||||
subpl <&> plSpot .~ _plSpot plmnt
|
||||
where
|
||||
changeLight lsid = lightSources . ix lsid . lsIntensity .~ V3 0 0.5 0
|
||||
ls = defaultLS { _lsRad = 75 , _lsIntensity = V3 0.5 0 0 }
|
||||
changeLight lsid = lightSources . ix lsid . lsParam . lsCol .~ V3 0 0.5 0
|
||||
ls = lsRadCol 75 (V3 0.5 0 0)
|
||||
thePS = PSPos f (const id) Nothing
|
||||
|
||||
|
||||
-- creates a lit external trigger, passes the trigger placement forward
|
||||
extTrigLitPos :: PlacementSpot -> (Placement -> Maybe Placement) -> Placement
|
||||
extTrigLitPos ps f = psPtCont ps (PutTrigger (const False))
|
||||
@@ -83,10 +85,10 @@ extTrigLitPos ps f = psPtCont ps (PutTrigger (const False))
|
||||
,_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
|
||||
then w & lightSources . ix (_mdExternalID1 md) . lsParam . lsCol .~ V3 0 0.5 0
|
||||
else w & lightSources . ix (_mdExternalID1 md) . lsParam . lsCol .~ V3 0.5 0 0
|
||||
}
|
||||
thels = defaultLS {_lsIntensity = V3 0.5 0 0, _lsPos = V3 0 0 78, _lsRad = 75}
|
||||
thels = lsColPosRad (V3 0.5 0 0) (V3 0 0 78) 75
|
||||
|
||||
putLitButOnPosExtTrig :: Color
|
||||
-> (RoomPos -> Room -> Maybe (PlacementSpot,RoomPos))
|
||||
@@ -101,6 +103,6 @@ putLitButOnPosExtTrig col f
|
||||
where
|
||||
trigid tp = fromJust $ _plMID tp
|
||||
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 }
|
||||
changeLight lsid = lightSources . ix lsid . lsParam . lsCol .~ V3 0 0.5 0
|
||||
ls = lsRadCol 75 (V3 0.5 0 0)
|
||||
thePS = PSPos f (const id) Nothing
|
||||
|
||||
Reference in New Issue
Block a user