Files
loop/src/Dodge/Item/Weapon/Remote.hs
T
2022-07-20 15:01:01 +01:00

29 lines
1009 B
Haskell

module Dodge.Item.Weapon.Remote
( pointToItem
, setRemoteScope
, setRemoteBombScope
) where
import Dodge.Data
import Dodge.Default
import Geometry
import Dodge.Item.Location
import qualified Data.IntMap.Strict as IM
import Control.Lens
setRemoteBombScope :: Int -> Prop -> World -> World
setRemoteBombScope itid pj w' = case _itemPositions w' IM.! itid of
InInv cid invid
-> w' & creatures . ix cid . crInv . ix invid . itScope
. scopePos .~ (_prPos pj -.- _crPos (_creatures w' IM.! cid))
& creatures . ix cid . crInv . ix invid . itUse . useAim . aimZoom
.~ (defaultItZoom {_itZoomMax = 0.5, _itZoomMin = 0.5})
_ -> w'
setRemoteScope :: Int -> Point2 -> World -> World
setRemoteScope itid pos w' = case w' ^? itemPositions . ix itid of
Just (InInv cid' invid )
-> w' & creatures . ix cid' . crInv . ix invid . itScope
. scopePos .~ (pos -.- _crPos (_creatures w' IM.! cid'))
_ -> w'