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