Cleanup your aim posture

This commit is contained in:
2026-04-03 15:11:53 +01:00
parent de7f430c2a
commit 921f860e83
2 changed files with 51 additions and 53 deletions
+16 -16
View File
@@ -28,7 +28,11 @@ yourControl _ w
| inTextInputFocus w = w
| NoSubInventory <- w ^. hud . subInventory =
w
& cWorld . lWorld . creatures . ix 0 %~ wasdWithAiming w
& cWorld
. lWorld
. creatures
. ix 0
%~ wasdWithAiming w
& tryClickUse (w ^. input . mouseButtons)
& handleHotkeys
| otherwise = w & cWorld . lWorld . creatures . ix 0 %~ wasdWithAiming w
@@ -113,32 +117,28 @@ wasdWithAiming w cr = wasdAim inp w $ wasdMovement (w ^. cWorld . lWorld) inp ca
wasdAim :: Input -> World -> Creature -> Creature
wasdAim inp w cr
| SDL.ButtonRight `M.member` _mouseButtons inp
, AtEase <- cr ^. crStance . posture =
setAimPosture cr
, AtEase <- cr ^. crStance . posture = setposture Aiming (-twoHandTwistAmount)
-- cr
-- & crStance . posture .~ Aiming
-- & doAimTwist (cr ^? crManipulation . manObject . imAimStance) (-twoHandTwistAmount)
| SDL.ButtonRight `M.member` _mouseButtons inp =
aimTurn (w ^. cWorld . lWorld) mousedir cr
| Aiming{} <- cr ^. crStance . posture = removeAimPosture cr
| Aiming{} <- cr ^. crStance . posture = setposture AtEase twoHandTwistAmount
-- cr
-- & crStance . posture .~ AtEase
-- & doAimTwist (cr ^? crManipulation . manObject . imAimStance) twoHandTwistAmount
| otherwise = creatureTurnTowardDir (_crMvAim cr) 0.2 cr
where
setposture x r = cr
& crStance . posture .~ x
& doAimTwist (cr ^? crManipulation . manObject . imAimStance) r
mousedir = argV $ w ^. cWorld . lWorld . lAimPos - (cr ^. crPos . _xy)
setAimPosture :: Creature -> Creature
setAimPosture cr =
cr
& crStance . posture .~ Aiming
& doAimTwist (cr ^? crManipulation . manObject . imAimStance) (-twoHandTwistAmount)
doAimTwist :: Maybe AimStance -> Float -> Creature -> Creature
doAimTwist as x
| as == Just TwoHandTwist = crDir +~ x
| otherwise = id
removeAimPosture :: Creature -> Creature
removeAimPosture cr =
cr
& crStance . posture .~ AtEase
& doAimTwist (cr ^? crManipulation . manObject . imAimStance) twoHandTwistAmount
twoHandTwistAmount :: Float
twoHandTwistAmount = 1.6 * pi