This commit is contained in:
2023-12-24 14:20:30 +00:00
parent 494db47945
commit 3b4bef944d
3 changed files with 8 additions and 21 deletions
-1
View File
@@ -4,7 +4,6 @@ module Dodge.Item.Weapon.Remote (
import Control.Lens import Control.Lens
import Dodge.Data.World import Dodge.Data.World
import Dodge.Default
import Geometry import Geometry
setRemoteScope :: Int -> Point2 -> World -> World setRemoteScope :: Int -> Point2 -> World -> World
-1
View File
@@ -60,7 +60,6 @@ module Dodge.Item.Weapon.TriggerType (
repeatTransformed, repeatTransformed,
) where ) where
import Dodge.Item.Location
import Dodge.Creature.HandPos import Dodge.Creature.HandPos
import Data.Foldable import Data.Foldable
import Data.Maybe import Data.Maybe
+8 -19
View File
@@ -59,9 +59,7 @@ translateFloatingCamera theinput cam = fromMaybe cam $ do
& camViewFrom +~ thetran & camViewFrom +~ thetran
translateFloatingCameraKeys :: Input -> Camera -> Camera translateFloatingCameraKeys :: Input -> Camera -> Camera
translateFloatingCameraKeys theinput = translateFloatingCameraKeys theinput = (camCenter -~ thetran) . (camViewFrom -~ thetran)
(camCenter -~ thetran)
. (camViewFrom -~ thetran)
where where
thetran = 10 *.* wasdDir theinput thetran = 10 *.* wasdDir theinput
@@ -89,40 +87,31 @@ moveZoomCamera cfig theinput cr campos =
& camDefaultZoom .~ newDefaultZoom & camDefaultZoom .~ newDefaultZoom
& camItemZoom .~ newItemZoom & camItemZoom .~ newItemZoom
where where
cpos = _crPos cr newvf = _crPos cr +.+ fromMaybe (V2 0 0) vfoffset
mitm = do
i <- cr ^? crManipulation . manObject . inInventory . ispItem
cr ^? crInv . ix i
newvf = cpos +.+ fromMaybe (V2 0 0) vfoffset
vfoffset = do vfoffset = do
guard (SDL.ButtonRight `M.member` _mouseButtons theinput) guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
mitm ^? _Just . itScope . remotePos i <- cr ^? crManipulation . manObject . inInventory . ispItem
(cr ^? crInv . ix i . itScope . remotePos)
mscopeoffset = do mscopeoffset = do
guard (SDL.ButtonRight `M.member` _mouseButtons theinput) guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
i <- cr ^? crManipulation . manObject . inInventory . ispItem i <- cr ^? crManipulation . manObject . inInventory . ispItem
(cr ^? crInv . ix (i - 1) . itUse . attachParams . scrollAttachParams . opticPos) (cr ^? crInv . ix (i - 1) . itUse . attachParams . scrollAttachParams . opticPos)
<|> (mitm ^? _Just . itScope . remotePos) <|> (cr ^? crInv . ix i . itScope . remotePos)
newcen = cpos +.+ fromMaybe (V2 0 0) mscopeoffset +.+ offset newcen = _crPos cr +.+ 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
newzoom = fromMaybe (newDefaultZoom * newItemZoom) $ do newzoom = fromMaybe (newDefaultZoom * newItemZoom) $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem i <- cr ^? crManipulation . manObject . inInventory . ispItem
(cr ^? crInv . ix (i - 1) . itUse . attachParams . scrollAttachParams . opticZoom) (cr ^? crInv . ix (i - 1) . itUse . attachParams . scrollAttachParams . opticZoom)
-- case mitm ^? _Just . itScope of
---- Just zs@ZoomScope{} -> _scopeZoom zs
-- _ -> newDefaultZoom * newItemZoom
idealDefaultZoom = clipZoom wallZoom idealDefaultZoom = clipZoom wallZoom
-- newDefaultZoom = case mitm ^? _Just . itScope of
---- Just zs@ZoomScope{} -> _scopeZoom zs
-- _ -> changeZoom (campos ^. camDefaultZoom) idealDefaultZoom
newDefaultZoom = fromMaybe (changeZoom (campos ^. camDefaultZoom) idealDefaultZoom) $ do newDefaultZoom = fromMaybe (changeZoom (campos ^. camDefaultZoom) idealDefaultZoom) $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem i <- cr ^? crManipulation . manObject . inInventory . ispItem
(cr ^? crInv . ix (i - 1) . itUse . attachParams . scrollAttachParams . opticZoom) (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) i <- cr ^? crManipulation . manObject . inInventory . ispItem
zoomFromItem <$> (cr ^? crInv . ix i . itUse . heldAim . aimZoom)
newItemZoom = changeZoom (campos ^. camItemZoom) idealItemZoom newItemZoom = changeZoom (campos ^. camItemZoom) idealItemZoom
changeZoom curZoom idealZoom changeZoom curZoom idealZoom
| curZoom > idealZoom + 0.01 = ((zoomOutSpeed -1) * curZoom + idealZoom) / zoomOutSpeed | curZoom > idealZoom + 0.01 = ((zoomOutSpeed -1) * curZoom + idealZoom) / zoomOutSpeed