Fix aim sweep

This commit is contained in:
2025-05-31 22:11:26 +01:00
parent 8b07fffa7c
commit c56e3e96ee
3 changed files with 15 additions and 7 deletions
+2 -2
View File
@@ -122,11 +122,11 @@ wasdAim inp cam 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
| SDL.ButtonRight `M.member` _mouseButtons inp = aimTurn mouseDir cr | SDL.ButtonRight `M.member` _mouseButtons inp = aimTurn mousedir 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 $ mouseWorldPos inp cam - (cr ^. crPos)
setAimPosture :: Creature -> Creature setAimPosture :: Creature -> Creature
setAimPosture = (crStance . posture .~ Aiming) . doAimTwist (- twoHandTwistAmount) setAimPosture = (crStance . posture .~ Aiming) . doAimTwist (- twoHandTwistAmount)
+2 -1
View File
@@ -278,7 +278,8 @@ drawAimSweep cr w = fold $ do
| otherwise = cdir | otherwise = cdir
return $ return $
uncurryV translate (worldPosToScreen campos p) $ uncurryV translate (worldPosToScreen campos p) $
arcFull (a - rot) 10 white (a' - rot) 1 white (5 + dist mwp p * campos ^. camZoom) white arcFull (a - rot) 10 white (a + diffAngles cdir a - rot) 1 white (5 + dist mwp p * campos ^. camZoom) white
--arcFull (a - rot) 10 white (a' - rot) 1 white (5 + dist mwp p * campos ^. camZoom) white
where where
cdir = _crDir cr cdir = _crDir cr
rot = campos ^. camRot rot = campos ^. camRot
+11 -4
View File
@@ -323,13 +323,20 @@ updateMouseContextGame cfig u = case u ^. uvWorld . input . mouseContext of
OverInvDragSelect{} -> u OverInvDragSelect{} -> u
_ -> _ ->
u & uvWorld . input . mouseContext u & uvWorld . input . mouseContext
.~ fromMaybe aimcontext (overinv <|> overcomb <|> overterm) -- .~ fromMaybe aimcontext (overinv <|> overcomb <|> overterm)
-- .~ fromMaybe aimcontext (overinv <|> overcomb <|> overterm <|> isrotatedrag)
.~ fromMaybe aimcontext (isrotatedrag <|> overinv <|> overcomb <|> overterm)
where where
w = u ^. uvWorld w = u ^. uvWorld
isrotatedrag = do
t1 <- w ^. input . mouseButtons . at ButtonLeft
t2 <- w ^. input . mouseButtons . at ButtonRight
guard $ t1 > t2
return MouseGameRotate
aimcontext aimcontext
| Just t1 <- w ^. input . mouseButtons . at ButtonLeft -- | Just t1 <- w ^. input . mouseButtons . at ButtonLeft
, Just t2 <- w ^. input . mouseButtons . at ButtonRight -- , Just t2 <- w ^. input . mouseButtons . at ButtonRight
, t1 > t2 = MouseGameRotate -- , t1 > t2 = MouseGameRotate
| ButtonRight `M.member` (w ^. input . mouseButtons) = MouseAiming | ButtonRight `M.member` (w ^. input . mouseButtons) = MouseAiming
| otherwise = MouseInGame | otherwise = MouseInGame
mpos = w ^. input . mousePos mpos = w ^. input . mousePos