Continue ai refactor

This commit is contained in:
2021-05-06 14:07:51 +02:00
parent 75c36e2c95
commit 436043b169
12 changed files with 94 additions and 35 deletions
+11 -11
View File
@@ -37,45 +37,45 @@ wasdWithAiming w speed aimSpeed i cr
-- = over crPos (+.+ (speed *.* mov))
= over crPos (+.+ (speed *.* unitVectorAtAngle mouseDir))
. set crDir mouseDir
$ set (crState . stance . carriage) (Boosting mov)
$ set (crStance . carriage) (Boosting mov)
cr
| any (\it -> it ^? itIdentity == Just JetPack) (_crInv cr) && isMoving && isAiming
= set crDir mouseDir
$ set (crState . stance . carriage) Floating
$ set (crStance . carriage) Floating
cr
| any (\it -> it ^? itIdentity == Just JetPack) (_crInv cr) && isMoving
= over crPos (+.+ (speed *.* mov))
. over crDir (flip fromMaybe dir)
$ set (crState . stance . carriage) (Boosting mov)
$ set (crStance . carriage) (Boosting mov)
cr
| any (\it -> it ^? itIdentity == Just JetPack) (_crInv cr) && isAiming
= set (crState . stance . carriage) Floating
= set (crStance . carriage) Floating
$ set crDir mouseDir
cr
| any (\it -> it ^? itIdentity == Just JetPack) $ _crInv cr
= set (crState . stance . carriage) Floating
= set (crStance . carriage) Floating
cr
| isAiming
= stepForward aimSpeed
$ over crPos (+.+ (aimSpeed *.* mov))
$ set crDir mouseDir
$ set (crState . stance . carriage) (Walking 0 0)
$ set (crStance . carriage) (Walking 0 0)
cr
| isMoving
= stepForward speed
$ over crPos (+.+ (speed *.* mov))
$ over crDir (`fromMaybe` dir)
$ set (crState . stance . carriage) (Walking 0 0)
$ set (crStance . carriage) (Walking 0 0)
cr
| otherwise
= over crDir (`fromMaybe` dir)
$ set (crState . stance . carriage) Standing
$ set (crStance . carriage) Standing
cr
where
(mov',dir') = wasdComp (view keys w) w
(mov,dir) = (rotateV (_cameraRot w) mov',fmap (_cameraRot w +) dir')
isMoving = mov' /= (0,0)
isAiming = _posture (_stance $ _crState cr) == Aiming
isAiming = _posture (_crStance cr) == Aiming
mouseDir = case w ^? creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
. itAttachment of
Just (Just ItScope{_scopePos = p}) -> normalizeAngle $ argV
@@ -100,9 +100,9 @@ wasdComp ks w = f $ foldr ( (+.+) . wasdM w ) (0,0) ks
mouseActionsCr :: S.Set SDL.MouseButton -> Creature -> Creature
mouseActionsCr keys cr
| rbPressed
= set ( crState . stance . posture) Aiming cr
= set ( crStance . posture) Aiming cr
| otherwise
= set ( crState . stance . posture) AtEase cr
= set ( crStance . posture) AtEase cr
where lbPressed = SDL.ButtonLeft `S.member` keys
rbPressed = SDL.ButtonRight `S.member` keys