Make reloading based upon creature stance

This commit is contained in:
2022-06-20 00:53:47 +01:00
parent 8d457033a2
commit 2f4b381484
11 changed files with 91 additions and 77 deletions
+3 -3
View File
@@ -13,7 +13,7 @@ import Control.Lens
import qualified SDL
import qualified Data.Set as S
--import qualified Data.IntMap.Strict as IM
import Data.Maybe
--import Data.Maybe
{- | The AI equivalent for your control. -}
yourControl :: Creature -> World -> World
yourControl cr w
@@ -72,9 +72,9 @@ wasdDir = foldr ((+.+) . wasdM) (V2 0 0) . _keys
{- | Set posture according to mouse presses. -}
mouseActionsCr :: S.Set SDL.MouseButton -> Creature -> Creature
mouseActionsCr pkeys cr
| reloading = cr & crStance . posture .~ Reloading
| _posture (_crStance cr) == Reloading = cr
| rbPressed = cr & crStance . posture .~ Aiming
| otherwise = cr & crStance . posture .~ AtEase
where
reloading = isJust $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . laReloadState . _Just'
-- reloading = isJust $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . laReloadState . _Just'
rbPressed = SDL.ButtonRight `S.member` pkeys