This commit is contained in:
2024-09-27 21:55:17 +01:00
parent dd6cbc0bfb
commit 6c3d0d5def
21 changed files with 232 additions and 333 deletions
+6 -11
View File
@@ -6,7 +6,7 @@ module Dodge.Update.Camera (
) where
import Bound
import Control.Applicative
--import Control.Applicative
import Control.Monad
import Data.Foldable
import qualified Data.Map.Strict as M
@@ -81,15 +81,11 @@ moveZoomCamera :: Configuration -> Input -> Creature -> World -> Camera -> Camer
moveZoomCamera cfig theinput cr w campos =
campos
& camCenter .~ fromMaybe (_crPos cr +.+ offset ) mremotepos
& camViewFrom .~ fromMaybe (_crPos cr +.+ vfoffset) mremotepos
& camViewFrom .~ fromMaybe (_crPos cr) mremotepos
& camZoom .~ newzoom
& camDefaultZoom .~ newDefaultZoom
& camItemZoom .~ newItemZoom
where
vfoffset = fromMaybe 0 $ do
guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
i <- cr ^? crManipulation . manObject . imSelectedItem
cr ^? crInv . ix i . itScope . remotePos
mremotepos = do
i <- cr ^? crManipulation . manObject . imSelectedItem
j <- cr ^? crInv . ix i . itUse . atLinkedProjectile . _Just
@@ -98,17 +94,16 @@ moveZoomCamera cfig theinput cr w campos =
offset = fromMaybe noscopeoffset $ do
guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
i <- cr ^? crManipulation . manObject . imSelectedItem
fmap docamrot (cr ^? crInv . ix i . itScope . opticPos)
<|> (cr ^? crInv . ix i . itScope . remotePos)
fmap docamrot (cr ^? crInv . ix i . itUse . scopeScope . opticPos)
noscopeoffset = docamrot $
((newzoom - newDefaultZoom) / (newDefaultZoom * newzoom)) *.* _mousePos theinput
newzoom = fromMaybe (newDefaultZoom * newItemZoom) $ do
i <- cr ^? crManipulation . manObject . imSelectedItem
cr ^? crInv . ix i . itScope . opticZoom
cr ^? crInv . ix i . itUse . scopeScope . opticZoom
idealDefaultZoom = clipZoom wallZoom
newDefaultZoom = fromMaybe (changeZoom (campos ^. camDefaultZoom) idealDefaultZoom) $ do
i <- cr ^? crManipulation . manObject . imSelectedItem
cr ^? crInv . ix i . itScope . opticZoom
cr ^? crInv . ix i . itUse . scopeScope . opticZoom
idealItemZoom = fromMaybe 1 $ do
guard $ crIsAiming cr
i <- cr ^? crManipulation . manObject . imSelectedItem
@@ -141,7 +136,7 @@ updateScopeZoom' i w
w & wppointer %~ doScopeZoom (w ^. input . smoothScrollAmount) (w ^. input . mousePos)
| otherwise = w & wppointer %~ resetscope
where
wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix i . itScope
wppointer = cWorld . lWorld . creatures . ix 0 . crInv . ix i . itUse . scopeScope
resetscope (OpticScope _ _ defz) = OpticScope (V2 0 0) defz defz
resetscope otherAtt = otherAtt