Partially working attachable scope
This commit is contained in:
@@ -5,6 +5,7 @@ module Dodge.Update.Camera (
|
|||||||
updateCamera,
|
updateCamera,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Dodge.HeldScroll
|
||||||
import Bound
|
import Bound
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
@@ -76,7 +77,7 @@ updateInGameCamera cfig w =
|
|||||||
& updateBounds cfig
|
& updateBounds cfig
|
||||||
& over wCam (setViewDistance cfig)
|
& over wCam (setViewDistance cfig)
|
||||||
& wCam %~ moveZoomCamera cfig (w ^. input) (you w)
|
& wCam %~ moveZoomCamera cfig (w ^. input) (you w)
|
||||||
-- & updateScopeZoom
|
& updateScopeZoom
|
||||||
& rotateCamera cfig
|
& rotateCamera cfig
|
||||||
|
|
||||||
moveZoomCamera :: Configuration -> Input -> Creature -> Camera -> Camera
|
moveZoomCamera :: Configuration -> Input -> Creature -> Camera -> Camera
|
||||||
@@ -102,6 +103,7 @@ moveZoomCamera cfig theinput cr campos =
|
|||||||
(cr ^? crInv . ix (i - 1) . itUse . attachParams . scrollAttachParams . opticPos)
|
(cr ^? crInv . ix (i - 1) . itUse . attachParams . scrollAttachParams . opticPos)
|
||||||
<|> (mitm ^? _Just . itScope . remotePos)
|
<|> (mitm ^? _Just . itScope . remotePos)
|
||||||
newcen = cpos +.+ fromMaybe (V2 0 0) mscopeoffset +.+ offset
|
newcen = cpos +.+ fromMaybe (V2 0 0) mscopeoffset +.+ offset
|
||||||
|
-- newcen = cpos +.+ fromMaybe offset mscopeoffset -- +.+ offset
|
||||||
offset =
|
offset =
|
||||||
rotateV (campos ^. camRot) $
|
rotateV (campos ^. camRot) $
|
||||||
((newzoom - newDefaultZoom) / (newDefaultZoom * newzoom)) *.* _mousePos theinput
|
((newzoom - newDefaultZoom) / (newDefaultZoom * newzoom)) *.* _mousePos theinput
|
||||||
@@ -112,9 +114,12 @@ moveZoomCamera cfig theinput cr campos =
|
|||||||
---- Just zs@ZoomScope{} -> _scopeZoom zs
|
---- Just zs@ZoomScope{} -> _scopeZoom zs
|
||||||
-- _ -> newDefaultZoom * newItemZoom
|
-- _ -> newDefaultZoom * newItemZoom
|
||||||
idealDefaultZoom = clipZoom wallZoom
|
idealDefaultZoom = clipZoom wallZoom
|
||||||
newDefaultZoom = case mitm ^? _Just . itScope of
|
-- newDefaultZoom = case mitm ^? _Just . itScope of
|
||||||
-- Just zs@ZoomScope{} -> _scopeZoom zs
|
---- Just zs@ZoomScope{} -> _scopeZoom zs
|
||||||
_ -> changeZoom (campos ^. camDefaultZoom) idealDefaultZoom
|
-- _ -> changeZoom (campos ^. camDefaultZoom) idealDefaultZoom
|
||||||
|
newDefaultZoom = fromMaybe (changeZoom (campos ^. camDefaultZoom) idealDefaultZoom) $ do
|
||||||
|
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
|
(cr ^? crInv . ix (i - 1) . itUse . attachParams . scrollAttachParams . opticZoom)
|
||||||
idealItemZoom = fromMaybe 1 $ do
|
idealItemZoom = fromMaybe 1 $ do
|
||||||
guard $ crIsAiming cr
|
guard $ crIsAiming cr
|
||||||
zoomFromItem <$> (mitm ^? _Just . itUse . heldAim . aimZoom)
|
zoomFromItem <$> (mitm ^? _Just . itUse . heldAim . aimZoom)
|
||||||
@@ -136,6 +141,9 @@ moveZoomCamera cfig theinput cr campos =
|
|||||||
updateScopeZoom :: World -> World
|
updateScopeZoom :: World -> World
|
||||||
updateScopeZoom w = fromMaybe w $ do
|
updateScopeZoom w = fromMaybe w $ do
|
||||||
i <- w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . inInventory . ispItem
|
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)
|
||||||
return $ updateScopeZoom' i w
|
return $ updateScopeZoom' i w
|
||||||
|
|
||||||
updateScopeZoom' :: Int -> World -> World
|
updateScopeZoom' :: Int -> World -> World
|
||||||
|
|||||||
Reference in New Issue
Block a user