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
+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