Implement remote screen for launcher projectiles

This commit is contained in:
2024-09-27 10:39:21 +01:00
parent fb6fcff61c
commit 5f9fb183a9
35 changed files with 238 additions and 170 deletions
+14 -10
View File
@@ -31,7 +31,7 @@ import qualified SDL
update where your avatar's view is from. -}
updateCamera :: Configuration -> World -> World
updateCamera cfig w = case w ^. wCam . camControl of
CamInGame -> updateInGameCamera cfig w
CamInGame {} -> updateInGameCamera cfig w
CamFloat -> updateFloatingCamera cfig w
updateFloatingCamera :: Configuration -> World -> World
@@ -72,16 +72,16 @@ updateInGameCamera :: Configuration -> World -> World
updateInGameCamera cfig w =
w
& updateBounds cfig
& wCam %~ moveZoomCamera cfig (w ^. input) (you w)
& wCam %~ moveZoomCamera cfig (w ^. input) (you w) w
& updateScopeZoom
& rotateCamera cfig
& over wCam (setViewDistance cfig) -- I think this should be updated after the zoom?
moveZoomCamera :: Configuration -> Input -> Creature -> Camera -> Camera
moveZoomCamera cfig theinput cr campos =
moveZoomCamera :: Configuration -> Input -> Creature -> World -> Camera -> Camera
moveZoomCamera cfig theinput cr w campos =
campos
& camCenter .~ _crPos cr +.+ offset
& camViewFrom .~ _crPos cr +.+ vfoffset
& camCenter .~ fromMaybe (_crPos cr +.+ offset ) mremotepos
& camViewFrom .~ fromMaybe (_crPos cr +.+ vfoffset) mremotepos
& camZoom .~ newzoom
& camDefaultZoom .~ newDefaultZoom
& camItemZoom .~ newItemZoom
@@ -89,22 +89,26 @@ moveZoomCamera cfig theinput cr campos =
vfoffset = fromMaybe 0 $ do
guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
i <- cr ^? crManipulation . manObject . imSelectedItem
(cr ^? crInv . ix i . itScope . remotePos)
cr ^? crInv . ix i . itScope . remotePos
mremotepos = do
i <- cr ^? crManipulation . manObject . imSelectedItem
j <- cr ^? crInv . ix i . itUse . atLinkedProjectile . _Just
w ^? cWorld . lWorld . projectiles . ix j . prjPos
docamrot = rotateV (campos ^. camRot)
offset = fromMaybe noscopeoffset $ do
guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
i <- cr ^? crManipulation . manObject . imSelectedItem
(fmap docamrot (cr ^? crInv . ix i . itScope . opticPos))
fmap docamrot (cr ^? crInv . ix i . itScope . opticPos)
<|> (cr ^? crInv . ix i . itScope . remotePos)
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 . itScope . 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 . itScope . opticZoom
idealItemZoom = fromMaybe 1 $ do
guard $ crIsAiming cr
i <- cr ^? crManipulation . manObject . imSelectedItem