Reloading slows movement

This commit is contained in:
2021-12-05 00:36:31 +00:00
parent cbf344e73e
commit 1bb1a06101
9 changed files with 155 additions and 24 deletions
+4 -1
View File
@@ -38,9 +38,12 @@ crMvAbsolute p' cr = advanceStepCounter (magV p) cr
equipFactor
| _posture (_crStance cr) == Aiming
= product $ map equipAimSpeed $ IM.elems $ _crInv cr
| _posture (_crStance cr) == Reloading
= product $ map equipAimSpeed $ IM.elems $ _crInv cr
| otherwise = product $ map equipSpeed $ IM.elems $ _crInv cr
aimingFactor
| _posture (_crStance cr) == Aiming = fromMaybe 1 $ it ^? itUse . useAim . aimSpeed
| _posture (_crStance cr) == Aiming || _posture (_crStance cr) == Reloading
= fromMaybe 1 $ it ^? itUse . useAim . aimSpeed
| otherwise = 1
it = _crInv cr IM.! _crInvSel cr
+1 -1
View File
@@ -28,7 +28,7 @@ data FootForward
| WasRightForward
deriving
(Eq,Ord,Show)
data Posture = Aiming | AtEase
data Posture = Aiming | Reloading | AtEase
deriving
(Eq,Ord,Show)
+6 -3
View File
@@ -12,6 +12,7 @@ import qualified SDL
import qualified Data.Set as S
import qualified Data.IntMap.Strict as IM
import Data.Monoid
import Data.Maybe
{- | The AI equivalent for your control. -}
yourControl
:: Creature
@@ -62,8 +63,10 @@ wasdDir w = foldr ((+.+) . wasdM) (V2 0 0) $ _keys w
{- | Set posture according to mouse presses. -}
mouseActionsCr :: S.Set SDL.MouseButton -> Creature -> Creature
mouseActionsCr pkeys
| rbPressed = crStance . posture .~ Aiming
| otherwise = crStance . posture .~ AtEase
mouseActionsCr pkeys cr
| reloading = cr & crStance . posture .~ Reloading
| rbPressed = cr & crStance . posture .~ Aiming
| otherwise = cr & crStance . posture .~ AtEase
where
reloading = isJust $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . reloadState . _Just'
rbPressed = SDL.ButtonRight `S.member` pkeys