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)
+1 -5
View File
@@ -26,13 +26,9 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
-- functions that modify the inventory should be centralised so that
-- this lock can be sensibly applied, perhaps
| w ^?! cWorld . lWorld . creatures . ix 0 . crInvLock -> w
-- | rbDown -> case (yourItem w ^? _Just . itUse . heldScroll, _rbOptions w) of
-- (_, EquipOptions{}) -> w & rbOptions . opSel %~ scrollRBOption yi rbscrollmax
-- (Nothing, _) -> closeObjScrollDir y w
-- (Just f, _) -> doHeldScroll f y (you w) w
| rbDown -> case (yourScrollAttachment w, _rbOptions w) of
(_,EquipOptions{}) -> w & rbOptions . opSel %~ scrollRBOption yi rbscrollmax
(Nothing, _) -> w -- closeObjScrollDir y w
(Nothing, _) -> w
(Just (invid,hs), _) -> doHeldScroll invid hs y w
| lbDown -> w & wCam . camZoom +~ y
| invKeyDown -> changeSwapSel yi w