Move configuration from world to universe
This commit is contained in:
+16
-16
@@ -28,8 +28,8 @@ import qualified SDL
|
||||
--import qualified Control.Foldl as L
|
||||
{- 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 = rotateCamera . autoZoomCamera . moveCamera . updateScopeZoom
|
||||
updateCamera :: Configuration -> World -> World
|
||||
updateCamera cfig = rotateCamera cfig . autoZoomCamera cfig . 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
|
||||
@@ -99,9 +99,9 @@ zoomOutLongGun w
|
||||
wp = _crInv (_creatures w IM.! 0) IM.! _crInvSel (_creatures w IM.! 0)
|
||||
Just currentZoom = wp ^? itAttachment . scopeZoom
|
||||
|
||||
ifConfigWallRotate :: World -> World
|
||||
ifConfigWallRotate w
|
||||
| _rotate_to_wall (_config w) && not (SDL.ButtonRight `S.member` _mouseButtons w)
|
||||
ifConfigWallRotate :: Configuration -> World -> World
|
||||
ifConfigWallRotate cfig w
|
||||
| _rotate_to_wall cfig && not (SDL.ButtonRight `S.member` _mouseButtons w)
|
||||
= rotateToOverlappingWall w
|
||||
| otherwise = w
|
||||
|
||||
@@ -128,12 +128,12 @@ rotateCameraBy x w = w
|
||||
& creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
|
||||
. itAttachment . scopePos %~ rotateV x
|
||||
|
||||
rotateCamera :: World -> World
|
||||
rotateCamera w
|
||||
rotateCamera :: Configuration -> World -> World
|
||||
rotateCamera cfig w
|
||||
| keyl && keyr = w
|
||||
| keyl = rotateCameraBy 0.025 w
|
||||
| keyr = rotateCameraBy (-0.025) w
|
||||
| otherwise = ifConfigWallRotate w
|
||||
| otherwise = ifConfigWallRotate cfig w
|
||||
where
|
||||
keyl = SDL.ScancodeQ `S.member` _keys w
|
||||
keyr = SDL.ScancodeE `S.member` _keys w
|
||||
@@ -152,8 +152,8 @@ zoomNoItem
|
||||
-> Float
|
||||
zoomNoItem = min 20 . max 0.2
|
||||
{- Automatically sets the zoom of the camera according to the surrounding walls. -}
|
||||
autoZoomCamera :: World -> World
|
||||
autoZoomCamera w
|
||||
autoZoomCamera :: Configuration -> World -> World
|
||||
autoZoomCamera cfig w
|
||||
-- | zoomInKey (_keyConfig w) `S.member` _keys w
|
||||
-- = zoomCamBy 0.01 w
|
||||
-- | zoomOutKey (_keyConfig w) `S.member` _keys w
|
||||
@@ -161,7 +161,7 @@ autoZoomCamera w
|
||||
= w & cameraZoom %~ changeZoom
|
||||
where
|
||||
camPos = _cameraViewFrom w
|
||||
wallZoom = farWallDist camPos w
|
||||
wallZoom = farWallDist camPos cfig w
|
||||
idealZoom
|
||||
| SDL.ButtonRight `S.member` _mouseButtons w
|
||||
= theScopeZoom * maybe zoomNoItem zoomFromItem (yourItem w ^? itUse . useAim . aimZoom) wallZoom
|
||||
@@ -176,16 +176,16 @@ autoZoomCamera w
|
||||
zoomOutSpeed = 15
|
||||
theScopeZoom = fromMaybe 1 $ yourItem w ^? itAttachment . scopeZoom
|
||||
|
||||
farWallDist :: Point2 -> World -> Float
|
||||
farWallDist p w = (winFac /) . min maxViewDistance $ ssfold (> maxViewDistance) findMax 1 vps
|
||||
farWallDist :: Point2 -> Configuration -> World -> Float
|
||||
farWallDist p cfig w = (winFac /) . min maxViewDistance $ ssfold (> maxViewDistance) findMax 1 vps
|
||||
where
|
||||
findMax curMax pout = max curMax $ dist p $ collidePointUpToIndirectMinDist p pout curMax wos
|
||||
hw = halfWidth w
|
||||
hh = halfHeight w
|
||||
hw = halfWidth cfig
|
||||
hh = halfHeight cfig
|
||||
winFac = min hw hh
|
||||
vps = concatMap _grViewpoints grs ++ extendedViewPoints p grs
|
||||
grs = filter (pointInOrOnPolygon p . _grBound) (_gameRooms w)
|
||||
wos = wallsOnScreen w
|
||||
wos = wallsOnScreen cfig w
|
||||
|
||||
extendedViewPoints :: Point2 -> [GameRoom] -> [Point2]
|
||||
extendedViewPoints p grs = map extend
|
||||
|
||||
Reference in New Issue
Block a user