Files
loop/src/Dodge/Item/Weapon/Remote.hs
T
2022-12-29 12:54:34 +00:00

30 lines
1.1 KiB
Haskell

module Dodge.Item.Weapon.Remote (
setRemoteScope,
setRemoteBombScope,
) where
import Control.Lens
import Dodge.Data.World
import Dodge.Default
import Geometry
setRemoteBombScope :: Int -> Prop -> World -> World
setRemoteBombScope itid pj w = case w ^?! cWorld . lWorld . itemLocations . ix itid of
InInv cid invid ->
w
& cWorld . lWorld . creatures . ix cid . crInv . ix invid . itScope
. scopePos
.~ (_prPos pj -.- (w ^?! cWorld . lWorld . creatures . ix cid . crPos))
& cWorld . lWorld . creatures . ix cid . crInv . ix invid . itUse . heldAim . aimZoom
.~ (defaultItZoom{_izMax = 0.5, _izMin = 0.5})
_ -> w
setRemoteScope :: Int -> Point2 -> World -> World
setRemoteScope itid pos w = case w ^? cWorld . lWorld . itemLocations . ix itid of
Just (InInv cid' invid) ->
w
& cWorld . lWorld . creatures . ix cid' . crInv . ix invid . itScope
. scopePos
.~ (pos -.- (w ^?! cWorld . lWorld . creatures . ix cid' . crPos))
_ -> w