module Dodge.LevelGen.Switch ( makeSwitch, makeButton, makeSwitchSPic, drawSwitchWire, ) where import Dodge.Data.Button import Dodge.Data.WorldEffect import Dodge.Default import Geometry import Picture import Shape import ShapePicture import Control.Lens makeButton :: Color -> -- | Effect when pressed WdWd -> Button makeButton col eff = defaultButton { -- { _btEvent = ButtonPress BtInactive ButtonDoNothing click1S eff col _btEvent = ButtonPress False eff col -- , _btState = BtOff } -- TODO remove duplication drawSwitchWire :: Color -> Color -> Button -> SPic drawSwitchWire col1 col2 bt | bt ^? btEvent . btOn == Just False = flick $ pi / 4 | otherwise = flick (negate (pi / 4)) where flick a = noPic ( mconcat [ colorSH col1 . translateSHz 10 . upperBox Small Typical 10 $ rectNSWE (-2) (-5) (-10) 10 , colorSH col2 . translateSH (V3 0 (-2) 15) . rotateSH a . upperBox Small Typical 2 $ rectNSWE 10 0 (-2) 2 ] ) makeSwitchSPic :: Color -> Color -> -- | Switch on effect WdWd -> -- | Switch off effect WdWd -> Button makeSwitchSPic c1 c2 effOn effOff = defaultButton & btEvent .~ ButtonSwitch effOn effOff c1 c2 False makeSwitch :: Color -> Color -> -- | Switch on effect WdWd -> -- | Switch off effect WdWd -> Button makeSwitch col1 col2 = makeSwitchSPic col1 col2