Implement randomised markings on sensors

This commit is contained in:
2022-03-13 19:59:46 +00:00
parent 06a501ff88
commit 1b6f11709c
16 changed files with 169 additions and 95 deletions
+12 -8
View File
@@ -7,10 +7,12 @@ 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
import Data.Either
@@ -19,14 +21,13 @@ damageSensor
-> Float
-> (Machine -> World -> World)
-> PlacementSpot -> Placement
damageSensor damF wdth upf ps = pContID ps (PutLS theLS)
$ \lsid -> Just $ spNoID ps $ PutMachine yellow (reverse $ square wdth) defaultMachine
{ _mcDraw = sensorSPic wdth
, _mcUpdate = \mc -> upf mc . sensorUpdate damF mc
damageSensor dt wdth upf ps = pContID ps (PutLS $ lsPosCol (V3 0 0 30) 0.1)
$ \lsid -> Just $ spNoID ps $ PutUsingGenParams
$ \gw -> (,) gw $ PutMachine yellow (reverse $ square wdth) defaultMachine
{ _mcDraw = sensorSPic wdth $ _sensorCoding (_gParams gw) M.! dt
, _mcUpdate = \mc -> upf mc . sensorUpdate dt mc
, _mcLSs = [lsid]
}
where
theLS = lsPosCol (V3 0 0 30) 0.1
lightSensor :: Float -> (Machine -> World -> World) -> PlacementSpot -> Placement
lightSensor = damageSensor Lasering
@@ -51,6 +52,9 @@ damageUsing dt dm
| _dmType dm == dt = Left $ _dmAmount dm
| otherwise = Right 0
sensorSPic :: Float -> Machine -> SPic
sensorSPic wdth _ = ( colorSH yellow $ upperPrismPoly 25 (square wdth)
sensorSPic :: Float -> (PaletteColor,DecorationShape) -> Machine -> SPic
sensorSPic wdth (pc,ds) _ = ( (colorSH yellow $ upperPrismPoly 25 (square wdth))
<> decorationToShape ds wdth wdth 25 col col
, mempty )
where
col = paletteToColor pc