Fix aiming with scope

This commit is contained in:
2023-12-26 21:45:59 +00:00
parent 3b4bef944d
commit 26c55ee7f5
14 changed files with 85 additions and 114 deletions
+4 -6
View File
@@ -5,7 +5,6 @@ module Dodge.Update.Camera (
updateCamera,
) where
import Dodge.HeldScroll
import Bound
import Control.Applicative
import Control.Monad
@@ -127,12 +126,11 @@ moveZoomCamera cfig theinput cr campos =
zoomInSpeed = 25
zoomOutSpeed = 15
-- note that your _crInvLock does not apply to this TODO check that this is what
-- is wanted
updateScopeZoom :: World -> World
updateScopeZoom w = fromMaybe w $ do
i <- w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . inInventory . ispItem
itm <- _crInv (you w) IM.!? i
atparams <- you w ^? crInv . ix (i - 1) . itUse . attachParams . scrollAttachParams
guard (canHeldScrollAttach itm atparams)
i <- yourScopeInvID w
return $ updateScopeZoom' i w
updateScopeZoom' :: Int -> World -> World
@@ -141,7 +139,7 @@ updateScopeZoom' i w
w & wppointer %~ doScopeZoom (w ^. input . smoothScrollAmount) mp
| otherwise = w & wppointer %~ resetscope
where
wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix (i - 1) . itUse . attachParams . scrollAttachParams
wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix i . itUse . attachParams . scrollAttachParams
resetscope (ZoomScrollParams _ _ defz) = ZoomScrollParams (V2 0 0) defz defz
resetscope otherAtt = otherAtt
mp = rotateV (w ^. wCam . camRot) $ _mousePos (_input w)