43 lines
1.3 KiB
Haskell
43 lines
1.3 KiB
Haskell
module Dodge.Placement.Instance.Sensor
|
|
( lightSensor
|
|
, damageSensor
|
|
) where
|
|
import Color
|
|
import Dodge.LightSource
|
|
import Dodge.Data
|
|
import Dodge.LevelGen.Data
|
|
import Dodge.Default
|
|
import Dodge.Placement.TopDecoration
|
|
import Geometry
|
|
import ShapePicture
|
|
import Shape
|
|
|
|
import qualified Data.Map.Strict as M
|
|
import Control.Lens
|
|
|
|
damageSensor
|
|
:: DamageType -- Left gets sensed, Right does damage
|
|
-> Float
|
|
-> Maybe Int
|
|
-> PlacementSpot -> Placement
|
|
damageSensor dt wdth mtrid ps = pContID ps (PutLS $ lsPosCol (V3 0 0 30) 0.1)
|
|
$ \lsid -> Just $ spNoID ps $ PutUsingGenParams
|
|
$ \gw -> (,) gw $ PutMachine (reverse $ square wdth) $ defaultMachine
|
|
& mcColor .~ yellow
|
|
& mcMounts . at ObTrigger .~ mtrid
|
|
& mcDraw .~ sensorSPic wdth (_sensorCoding (_genParams gw) M.! dt)
|
|
& mcSensor .~ SensorToggleAmount False 0
|
|
& mcLSs .~ [lsid]
|
|
|
|
lightSensor :: Float -- -> (Machine -> World -> World)
|
|
-> Maybe Int
|
|
-> PlacementSpot -> Placement
|
|
lightSensor = damageSensor LASERING
|
|
|
|
sensorSPic :: Float -> (PaletteColor,DecorationShape) -> Machine -> SPic
|
|
sensorSPic wdth (pc,ds) mc = noPic
|
|
$ colorSH (_mcColor mc) (upperPrismPoly 25 (square wdth))
|
|
<> decorationToShape ds wdth wdth 25 col col
|
|
where
|
|
col = paletteToColor pc
|