module Dodge.Item.Weapon.Radar where
import Dodge.Data
--import Dodge.Picture.Layer
import Dodge.Default
import Dodge.Item.Draw
--import Dodge.Item.Equipment
import Dodge.Item.Equipment.Shape
import Dodge.Item.Weapon.TriggerType
import Dodge.Item.Weapon.ExtraEffect
import Dodge.Item.Weapon.UseEffect
--import Dodge.Item.Weapon.Remote
import Dodge.Default.Weapon
import Dodge.SoundLogic
--import Dodge.Item.Weapon.Grenade
import Geometry
import Picture
import Shape
--import ShapePicture

import Control.Lens

{- |
Sends out pulses that display walls.  -}
clickDetector :: Detector -> Item
clickDetector dt = defaultWeapon 
    { _itUse = ruseRate 20 (detectorEffect dt) upHammer
        [ ammoUseCheck
        ]
        & useAim . aimRange .~ 1
        & useAim . aimZoom .~ defaultItZoom {_itZoomFac = 1}
--    , _itZoom       = defaultItZoom { _itZoomMax = 1}
    , _itEquipPict = pictureWeaponAim $ \_ -> (,) emptySH $ color blue $ polygon $ rectNESW 5 5 (-5) (-5)
    }
    & itType . iyBase .~ CLICKDETECTOR dt

autoDetector :: Detector -> Item
autoDetector dt = defaultEquipment
    {_itEquipPict = shapeForWrist (colorSH (detectorColor dt) $ upperPrismPoly 3 $ rectWH 2 2)
--    , _itEffect = autoRadarEffect
    , _itID = Nothing
    } 
    & itUse . eqEq . eqSite .~ GoesOnWrist
    & itUse . eqEq . eqUse  .~ autoEffect (detectorEffect dt) 100 click1S
    & itUse . eqEq . eqParams .~ EquipCounter 0
    & itUse . eqEq . eqViewDist ?~ 350
    & itType . iyBase .~ AUTODETECTOR dt

detectorColor :: Detector -> Color
detectorColor dt = case dt of
    ITEMDETECTOR        -> blue
    CREATUREDETECTOR    -> green
    WALLDETECTOR        -> red

detectorEffect :: Detector -> Item -> Creature -> World -> World
detectorEffect dt = case dt of
    ITEMDETECTOR        -> const anItemFindPulse
    CREATUREDETECTOR    -> const aSonarPulse
    WALLDETECTOR        -> const aWallPulse
