Record aim position in LWorld
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
module Dodge.Base.Coordinate (
|
module Dodge.Base.Coordinate (
|
||||||
mouseWorldPos,
|
|
||||||
cartePosToScreen,
|
cartePosToScreen,
|
||||||
worldPosToScreen,
|
worldPosToScreen,
|
||||||
screenToWorldPos,
|
screenToWorldPos,
|
||||||
|
mouseWorldPos',
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
@@ -45,11 +45,12 @@ cartePosToScreen thehud = doRotate . doZoom . doTranslate
|
|||||||
--crToMousePosOffset cr w = (mouseWorldPos w -.- _crPos cr, 0)
|
--crToMousePosOffset cr w = (mouseWorldPos w -.- _crPos cr, 0)
|
||||||
|
|
||||||
-- | The mouse position in world coordinates.
|
-- | The mouse position in world coordinates.
|
||||||
mouseWorldPos :: Input -> Camera -> Point2
|
mouseWorldPos' :: Input -> Camera -> Point2
|
||||||
mouseWorldPos inp cam =
|
mouseWorldPos' inp cam =
|
||||||
(cam ^. camCenter)
|
(cam ^. camCenter)
|
||||||
+.+ (1 / (cam ^. camZoom)) *.* rotateV (cam ^. camRot) (_mousePos inp)
|
+.+ (1 / (cam ^. camZoom)) *.* rotateV (cam ^. camRot) (_mousePos inp)
|
||||||
|
|
||||||
|
|
||||||
screenToWorldPos :: Camera -> Point2 -> Point2
|
screenToWorldPos :: Camera -> Point2 -> Point2
|
||||||
screenToWorldPos cam p =
|
screenToWorldPos cam p =
|
||||||
(cam ^. camCenter)
|
(cam ^. camCenter)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ blinkActionMousePos cr w =
|
|||||||
& inverseShockwaveAt cpos 40 2 2
|
& inverseShockwaveAt cpos 40 2 2
|
||||||
where
|
where
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
p1 = mouseWorldPos (w ^. input) (w ^. wCam)
|
p1 = w ^. cWorld . lWorld . lAimPos
|
||||||
cpos = _crPos cr
|
cpos = _crPos cr
|
||||||
--p2 = bouncePoint (const True) 1 cpos p1 w
|
--p2 = bouncePoint (const True) 1 cpos p1 w
|
||||||
p2 = pushIntoMaybe $ collideCircWalls cpos p1 r (wlsNearSeg cpos p1 w)
|
p2 = pushIntoMaybe $ collideCircWalls cpos p1 r (wlsNearSeg cpos p1 w)
|
||||||
@@ -73,7 +73,7 @@ unsafeBlinkAction cr w
|
|||||||
wl <- snd $ collidePointWallsFilter (const True) mwp cpos w
|
wl <- snd $ collidePointWallsFilter (const True) mwp cpos w
|
||||||
return (isLHS mwp `uncurry` _wlLine wl)
|
return (isLHS mwp `uncurry` _wlLine wl)
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
mwp = mouseWorldPos (w ^. input) (w ^. wCam)
|
mwp = w ^. cWorld . lWorld . lAimPos
|
||||||
cpos = _crPos cr
|
cpos = _crPos cr
|
||||||
|
|
||||||
blinkShockwave ::
|
blinkShockwave ::
|
||||||
@@ -99,7 +99,7 @@ blinkActionFail cr w =
|
|||||||
distR = 120
|
distR = 120
|
||||||
distortionBulge = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9
|
distortionBulge = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
p1 = mouseWorldPos (w ^. input) (w ^. wCam)
|
p1 = w ^. cWorld . lWorld . lAimPos
|
||||||
cpos = _crPos cr
|
cpos = _crPos cr
|
||||||
p2 = bouncePoint (const True) 1 cpos p1 w
|
p2 = bouncePoint (const True) 1 cpos p1 w
|
||||||
r = 1.5 * _crRad cr
|
r = 1.5 * _crRad cr
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ updateItemTargeting tt cr itm w = case tt of
|
|||||||
TargetRBPress
|
TargetRBPress
|
||||||
| rbpressed ->
|
| rbpressed ->
|
||||||
w
|
w
|
||||||
& pointittarg . itTgPos %~ maybe (Just $ mouseWorldPos (w ^. input) (w ^. wCam)) Just
|
& pointittarg . itTgPos %~ maybe (Just $ w ^. cWorld . lWorld . lAimPos) Just
|
||||||
& pointittarg . itTgActive .~ True
|
& pointittarg . itTgActive .~ True
|
||||||
TargetRBPress ->
|
TargetRBPress ->
|
||||||
w
|
w
|
||||||
@@ -395,7 +395,7 @@ updateItemTargeting tt cr itm w = case tt of
|
|||||||
w
|
w
|
||||||
& pointittarg
|
& pointittarg
|
||||||
.~ ItTargeting
|
.~ ItTargeting
|
||||||
(Just (mouseWorldPos (w ^. input) (w ^. wCam)))
|
(Just (w ^. cWorld . lWorld . lAimPos))
|
||||||
Nothing
|
Nothing
|
||||||
True
|
True
|
||||||
where
|
where
|
||||||
@@ -417,7 +417,7 @@ setRBCreatureTargeting cr w ituse
|
|||||||
. filter (canseepos . _crPos)
|
. filter (canseepos . _crPos)
|
||||||
$ crsNearCirc mwp 40 w
|
$ crsNearCirc mwp 40 w
|
||||||
canseepos p = hasLOS (_crPos cr) p w
|
canseepos p = hasLOS (_crPos cr) p w
|
||||||
mwp = mouseWorldPos (w ^. input) (w ^. wCam)
|
mwp = w ^. cWorld . lWorld . lAimPos
|
||||||
updatePos t' = t' & itTgPos .~ posFromMaybeID (_itTgID t')
|
updatePos t' = t' & itTgPos .~ posFromMaybeID (_itTgID t')
|
||||||
posFromMaybeID Nothing = Nothing
|
posFromMaybeID Nothing = Nothing
|
||||||
posFromMaybeID (Just i) = w ^? cWorld . lWorld . creatures . ix i . crPos
|
posFromMaybeID (Just i) = w ^? cWorld . lWorld . creatures . ix i . crPos
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ module Dodge.Creature.YourControl (
|
|||||||
import Control.Monad
|
import Control.Monad
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Dodge.Base.Coordinate
|
|
||||||
import Dodge.Creature.Impulse.Movement
|
import Dodge.Creature.Impulse.Movement
|
||||||
import Dodge.Creature.Impulse.UseItem
|
import Dodge.Creature.Impulse.UseItem
|
||||||
import Dodge.Data.World
|
import Dodge.Data.World
|
||||||
@@ -112,14 +111,14 @@ scancodeToHotkey x = case x of
|
|||||||
within wasdMovement should probably be done first
|
within wasdMovement should probably be done first
|
||||||
-}
|
-}
|
||||||
wasdWithAiming :: World -> Creature -> Creature
|
wasdWithAiming :: World -> Creature -> Creature
|
||||||
wasdWithAiming w cr = wasdAim inp cam $ wasdMovement inp cam speed cr
|
wasdWithAiming w cr = wasdAim inp w $ wasdMovement inp cam speed cr
|
||||||
where
|
where
|
||||||
speed = _mvSpeed $ _crMvType cr
|
speed = _mvSpeed $ _crMvType cr
|
||||||
inp = w ^. input
|
inp = w ^. input
|
||||||
cam = w ^. wCam
|
cam = w ^. wCam
|
||||||
|
|
||||||
wasdAim :: Input -> Camera -> Creature -> Creature
|
wasdAim :: Input -> World -> Creature -> Creature
|
||||||
wasdAim inp cam cr
|
wasdAim inp w cr
|
||||||
| Just 0 <- inp ^? mouseButtons . ix SDL.ButtonRight
|
| Just 0 <- inp ^? mouseButtons . ix SDL.ButtonRight
|
||||||
, Nothing <- inp ^? mouseButtons . ix SDL.ButtonLeft
|
, Nothing <- inp ^? mouseButtons . ix SDL.ButtonLeft
|
||||||
= setAimPosture cr
|
= setAimPosture cr
|
||||||
@@ -127,7 +126,7 @@ wasdAim inp cam cr
|
|||||||
| Aiming <- cr ^. crStance . posture = removeAimPosture cr
|
| Aiming <- cr ^. crStance . posture = removeAimPosture cr
|
||||||
| otherwise = creatureTurnTowardDir (_crMvAim cr) 0.2 cr
|
| otherwise = creatureTurnTowardDir (_crMvAim cr) 0.2 cr
|
||||||
where
|
where
|
||||||
mousedir = argV $ mouseWorldPos inp cam - (cr ^. crPos)
|
mousedir = argV $ w ^. cWorld . lWorld . lAimPos - (cr ^. crPos)
|
||||||
|
|
||||||
setAimPosture :: Creature -> Creature
|
setAimPosture :: Creature -> Creature
|
||||||
setAimPosture = (crStance . posture .~ Aiming) . doAimTwist (- twoHandTwistAmount)
|
setAimPosture = (crStance . posture .~ Aiming) . doAimTwist (- twoHandTwistAmount)
|
||||||
|
|||||||
+1
-1
@@ -120,4 +120,4 @@ closestCreatureID u =
|
|||||||
. crsHitRadial mwp 100
|
. crsHitRadial mwp 100
|
||||||
$ _uvWorld u
|
$ _uvWorld u
|
||||||
where
|
where
|
||||||
mwp = mouseWorldPos (u ^. uvWorld . input) (u ^. uvWorld . wCam)
|
mwp = mouseWorldPos' (u ^. uvWorld . input) (u ^. uvWorld . wCam)
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ drawWallsNearYou w = concat $ do
|
|||||||
|
|
||||||
drawWallsNearCursor :: World -> Picture
|
drawWallsNearCursor :: World -> Picture
|
||||||
drawWallsNearCursor w =
|
drawWallsNearCursor w =
|
||||||
foldMap f $ wlsNearPoint (mouseWorldPos (_input w) (_wCam w)) w
|
foldMap f $ wlsNearPoint (mouseWorldPos' (_input w) (_wCam w)) w
|
||||||
where
|
where
|
||||||
f wl =
|
f wl =
|
||||||
setLayer DebugLayer (color rose $ thickLine 3 [a, b])
|
setLayer DebugLayer (color rose $ thickLine 3 [a, b])
|
||||||
@@ -280,7 +280,7 @@ drawZoneNearPointCursor :: World -> Picture
|
|||||||
drawZoneNearPointCursor w =
|
drawZoneNearPointCursor w =
|
||||||
foldMap (drawZoneCol orange 50) ps
|
foldMap (drawZoneCol orange 50) ps
|
||||||
where
|
where
|
||||||
mwp = mouseWorldPos (w ^. input) (w ^. wCam)
|
mwp = mouseWorldPos' (w ^. input) (w ^. wCam)
|
||||||
ps = [zoneOfPoint 50 mwp]
|
ps = [zoneOfPoint 50 mwp]
|
||||||
|
|
||||||
drawDDATest :: World -> Picture
|
drawDDATest :: World -> Picture
|
||||||
@@ -289,7 +289,7 @@ drawDDATest w =
|
|||||||
<> setLayer DebugLayer (color yellow (line [cvf, mwp]))
|
<> setLayer DebugLayer (color yellow (line [cvf, mwp]))
|
||||||
where
|
where
|
||||||
cvf = w ^. wCam . camViewFrom
|
cvf = w ^. wCam . camViewFrom
|
||||||
mwp = mouseWorldPos (w ^. input) (w ^. wCam)
|
mwp = mouseWorldPos' (w ^. input) (w ^. wCam)
|
||||||
ps = zoneOfSeg 50 cvf mwp
|
ps = zoneOfSeg 50 cvf mwp
|
||||||
|
|
||||||
drawWallSearchRays :: World -> Picture
|
drawWallSearchRays :: World -> Picture
|
||||||
@@ -354,7 +354,7 @@ drawMousePosition w =
|
|||||||
. text
|
. text
|
||||||
$ shortPoint2 mwp
|
$ shortPoint2 mwp
|
||||||
where
|
where
|
||||||
mwp = mouseWorldPos (w ^. input) (w ^. wCam)
|
mwp = mouseWorldPos' (w ^. input) (w ^. wCam)
|
||||||
|
|
||||||
drawCoord :: Point2 -> World -> Picture
|
drawCoord :: Point2 -> World -> Picture
|
||||||
drawCoord p w =
|
drawCoord p w =
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ module Dodge.Render.Picture (
|
|||||||
fixedCoordPictures,
|
fixedCoordPictures,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Dodge.Base.Coordinate
|
import Dodge.Base.Coordinate
|
||||||
@@ -17,7 +16,8 @@ import Picture
|
|||||||
|
|
||||||
fixedCoordPictures :: Universe -> Picture
|
fixedCoordPictures :: Universe -> Picture
|
||||||
fixedCoordPictures u =
|
fixedCoordPictures u =
|
||||||
drawMenuOrHUD cfig u
|
aimDelaySweep u
|
||||||
|
<> drawMenuOrHUD cfig u
|
||||||
<> drawConcurrentMessage u
|
<> drawConcurrentMessage u
|
||||||
<> ttl (translate hw 0 $ drawList (map text (_uvTestString u u)))
|
<> ttl (translate hw 0 $ drawList (map text (_uvTestString u u)))
|
||||||
<> ttl
|
<> ttl
|
||||||
@@ -28,7 +28,6 @@ fixedCoordPictures u =
|
|||||||
(u ^. uvWorld . cWorld . lWorld . lTestString)
|
(u ^. uvWorld . cWorld . lWorld . lTestString)
|
||||||
)
|
)
|
||||||
<> displayFrameTicks u
|
<> displayFrameTicks u
|
||||||
<> aimDelaySweep u
|
|
||||||
<> drawMouseCursor u
|
<> drawMouseCursor u
|
||||||
<> ( toTopLeft cfig . translate (1.3 * halfWidth cfig) 0
|
<> ( toTopLeft cfig . translate (1.3 * halfWidth cfig) 0
|
||||||
. drawList
|
. drawList
|
||||||
@@ -119,7 +118,7 @@ mouseCursorType u = case u ^. uvWorld . input . mouseContext of
|
|||||||
a = fromMaybe 0 $ do
|
a = fromMaybe 0 $ do
|
||||||
cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos
|
cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos
|
||||||
return . toClosestMultiple (pi / 32) $
|
return . toClosestMultiple (pi / 32) $
|
||||||
argV (mouseWorldPos (w ^. input) (w ^. wCam) -.- cpos)
|
argV (w ^. cWorld . lWorld . lAimPos -.- cpos)
|
||||||
- w ^. wCam . camRot
|
- w ^. wCam . camRot
|
||||||
|
|
||||||
drawEmptySet :: Float -> Picture
|
drawEmptySet :: Float -> Picture
|
||||||
@@ -195,7 +194,7 @@ drawDrag x =
|
|||||||
|
|
||||||
drawVerticalDoubleArrow :: Float -> Picture
|
drawVerticalDoubleArrow :: Float -> Picture
|
||||||
drawVerticalDoubleArrow x =
|
drawVerticalDoubleArrow x =
|
||||||
line [V2 0 z, V2 0 (- z)]
|
line [V2 0 z, V2 0 (- z)]
|
||||||
<> line [V2 (- w) (z - w), V2 0 z, V2 w (z - w)]
|
<> line [V2 (- w) (z - w), V2 0 z, V2 w (z - w)]
|
||||||
<> line [V2 (- w) (w - z), V2 0 (- z), V2 w (w - z)]
|
<> line [V2 (- w) (w - z), V2 0 (- z), V2 w (w - z)]
|
||||||
where
|
where
|
||||||
@@ -265,7 +264,6 @@ drawGapPlus x =
|
|||||||
aimDelaySweep :: Universe -> Picture
|
aimDelaySweep :: Universe -> Picture
|
||||||
aimDelaySweep u = fold $ do
|
aimDelaySweep u = fold $ do
|
||||||
let w = u ^. uvWorld
|
let w = u ^. uvWorld
|
||||||
guard $ null $ u ^. uvScreenLayers
|
|
||||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||||
Aiming{} <- cr ^? crStance . posture
|
Aiming{} <- cr ^? crStance . posture
|
||||||
return $ drawAimSweep cr w
|
return $ drawAimSweep cr w
|
||||||
@@ -281,5 +279,4 @@ drawAimSweep cr w = fold $ do
|
|||||||
rot = campos ^. camRot
|
rot = campos ^. camRot
|
||||||
p = _crPos cr
|
p = _crPos cr
|
||||||
campos = w ^. wCam
|
campos = w ^. wCam
|
||||||
theinput = w ^. input
|
mwp = w ^. cWorld . lWorld . lAimPos
|
||||||
mwp = mouseWorldPos theinput campos
|
|
||||||
|
|||||||
+1
-1
@@ -303,7 +303,7 @@ functionalUpdate u =
|
|||||||
|
|
||||||
updateAimPos :: Universe -> Universe
|
updateAimPos :: Universe -> Universe
|
||||||
updateAimPos u = u & uvWorld . cWorld . lWorld . lAimPos
|
updateAimPos u = u & uvWorld . cWorld . lWorld . lAimPos
|
||||||
.~ mouseWorldPos (u ^. uvWorld . input) (u ^. uvWorld . wCam)
|
.~ mouseWorldPos' (u ^. uvWorld . input) (u ^. uvWorld . wCam)
|
||||||
|
|
||||||
updateMagnets :: LWorld -> LWorld
|
updateMagnets :: LWorld -> LWorld
|
||||||
updateMagnets lw =
|
updateMagnets lw =
|
||||||
|
|||||||
@@ -73,4 +73,4 @@ makeFlamerSmokeAt p w = makeCloudAt (CloudColor 4 300 (greyN x)) 6 200 40 p w
|
|||||||
spawnSmokeAtCursor :: World -> World
|
spawnSmokeAtCursor :: World -> World
|
||||||
spawnSmokeAtCursor w = shellTrailCloud 400 100 (V3 x y 20) w
|
spawnSmokeAtCursor w = shellTrailCloud 400 100 (V3 x y 20) w
|
||||||
where
|
where
|
||||||
V2 x y = mouseWorldPos (w ^. input) (w ^. wCam)
|
V2 x y = mouseWorldPos' (w ^. input) (w ^. wCam)
|
||||||
|
|||||||
Reference in New Issue
Block a user