Hlinting
This commit is contained in:
+28
-26
@@ -7,7 +7,6 @@ module Dodge.Update.Camera
|
||||
( updateCamera
|
||||
)
|
||||
where
|
||||
|
||||
import Dodge.Data
|
||||
import Dodge.Base
|
||||
import Dodge.Config.KeyConfig
|
||||
@@ -18,17 +17,22 @@ import Control.Monad
|
||||
import Data.Maybe
|
||||
import qualified Data.Set as S
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import qualified SDL as SDL
|
||||
import qualified SDL
|
||||
|
||||
{-
|
||||
Update the screen camera rotation and position, including any in rold scope/remote camera modifiers;
|
||||
update where your avatar's view is from.
|
||||
-}
|
||||
updateCamera :: World -> World
|
||||
updateCamera = rotCam . moveCamera . updateScopeZoom
|
||||
|
||||
{- Updte the center of the screen camera center and where your avatar's view is from in world. -}
|
||||
moveCamera :: World -> World
|
||||
moveCamera w = w & cameraCenter .~ idealPos
|
||||
& cameraViewFrom .~ sightFrom
|
||||
where
|
||||
aimRangeFactor | _cameraZoom w == 0 = 0
|
||||
| otherwise = (fromMaybe 0 $ yourItem w ^? itAimingRange) / _cameraZoom w
|
||||
| otherwise = fromMaybe 0 (yourItem w ^? itAimingRange) / _cameraZoom w
|
||||
aimingMult | SDL.ButtonRight `S.member` _mouseButtons w = 1
|
||||
| otherwise = 0
|
||||
ypos = _crPos $ you w
|
||||
@@ -72,28 +76,27 @@ updateScopeZoom w
|
||||
zoomSpeed = 39/40
|
||||
|
||||
zoomInLongGun :: World -> World
|
||||
zoomInLongGun w | currentZoom < 8 = over (wpPointer . itAttachment . _Just . scopePos)
|
||||
(\p -> p +.+ (4-(4*zoomSpeed)) / currentZoom *.* mousep)
|
||||
$ over (wpPointer . itAttachment . _Just . scopeZoom) (\z -> z / zoomSpeed)
|
||||
w
|
||||
| otherwise = w
|
||||
where wpPointer = creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
||||
wp = _crInv (_creatures w IM.! 0) IM.! (_crInvSel (_creatures w IM.! 0))
|
||||
Just currentZoom = wp ^? itAttachment . _Just . scopeZoom
|
||||
mousep = rotateV (_cameraRot w) $ _mousePos w
|
||||
zoomInLongGun w
|
||||
| currentZoom < 8 = over (wpPointer . itAttachment . _Just . scopePos)
|
||||
(\p -> p +.+ (4-(4*zoomSpeed)) / currentZoom *.* mousep)
|
||||
$ over (wpPointer . itAttachment . _Just . scopeZoom) (/ zoomSpeed)
|
||||
w
|
||||
| otherwise = w
|
||||
where
|
||||
wpPointer = creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
||||
wp = _crInv (_creatures w IM.! 0) IM.! _crInvSel (_creatures w IM.! 0)
|
||||
Just currentZoom = wp ^? itAttachment . _Just . scopeZoom
|
||||
mousep = rotateV (_cameraRot w) $ _mousePos w
|
||||
|
||||
zoomOutLongGun :: World -> World
|
||||
zoomOutLongGun w | currentZoom > 0.5 = over (wpPointer . itAttachment . _Just . scopePos)
|
||||
-- (\p -> p -.- 2/(2 * currentZoom) *.* _mousePos w)
|
||||
-- (\p -> p -.- 2*zoomSpeed/currentZoom *.* p)
|
||||
(\p -> p)
|
||||
$ over (wpPointer . itAttachment . _Just . scopeZoom) (\z -> z * zoomSpeed)
|
||||
w
|
||||
| otherwise = w
|
||||
where wpPointer = creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
||||
wp = _crInv (_creatures w IM.! 0) IM.! (_crInvSel (_creatures w IM.! 0))
|
||||
Just currentZoom = wp ^? itAttachment . _Just . scopeZoom
|
||||
currentCursorDisplacement = fromJust $ _itAttachment wp
|
||||
zoomOutLongGun w
|
||||
| currentZoom > 0.5 = over (wpPointer . itAttachment . _Just . scopeZoom) (* zoomSpeed) w
|
||||
| otherwise = w
|
||||
where
|
||||
wpPointer = creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
||||
wp = _crInv (_creatures w IM.! 0) IM.! _crInvSel (_creatures w IM.! 0)
|
||||
Just currentZoom = wp ^? itAttachment . _Just . scopeZoom
|
||||
currentCursorDisplacement = fromJust $ _itAttachment wp
|
||||
|
||||
rotCam = rotateCameraL . rotateCameraR . zoomCamIn . zoomCamOut . autoZoomCam
|
||||
|
||||
@@ -130,11 +133,10 @@ autoZoomCam w = over cameraZoom changeZoom w
|
||||
wallZoom = farWallDist camPos w
|
||||
idealZoom | SDL.ButtonRight `S.member` _mouseButtons w
|
||||
= scZoom *
|
||||
(
|
||||
min (fromMaybe 20 $ yourItem w ^? itZoom . itAimZoomMax)
|
||||
$ max (fromMaybe 0.2 $ yourItem w ^? itZoom . itAimZoomMin)
|
||||
( max (fromMaybe 0.2 $ yourItem w ^? itZoom . itAimZoomMin)
|
||||
(wallZoom * fromMaybe 1 (yourItem w ^? itZoom . itAimZoomFac))
|
||||
)
|
||||
)
|
||||
| otherwise
|
||||
= min (fromMaybe 20 $ yourItem w ^? itZoom . itZoomMax)
|
||||
$ max (fromMaybe 0.2 (yourItem w ^? itZoom . itZoomMin))
|
||||
|
||||
Reference in New Issue
Block a user