Make reloading based upon creature stance
This commit is contained in:
@@ -232,14 +232,14 @@ doItemTargeting invid cr w = case cr ^? crInv . ix invid . itTargeting of
|
||||
weaponReloadSounds :: Creature -> World -> World
|
||||
weaponReloadSounds cr w = case cr ^? crInv . ix (_crInvSel cr) . itConsumption of
|
||||
Just am@LoadableAmmo{} -> case _laReloadType am of
|
||||
PassiveReload stype | Just' (_laReloadTime am) == _laReloadState am
|
||||
PassiveReload stype | Just (_laReloadTime am) == am ^? laTransfer . transferTime
|
||||
-> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w
|
||||
PassiveReload _ -> w
|
||||
ActiveClear | _laReloadState am == Just' 0 -> stopSoundFrom (CrReloadSound cid) w
|
||||
ActiveClear | _laReloadState am == Nothing' -> w
|
||||
ActiveClear | am ^? laTransfer . transferTime == Just 0 -> stopSoundFrom (CrReloadSound cid) w
|
||||
ActiveClear | _laTransfer am == NoTransfer -> w
|
||||
ActiveClear -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
|
||||
ActivePartial{} | _laReloadState am == Just' 0 -> stopSoundFrom (CrReloadSound cid) w
|
||||
ActivePartial{} | _laReloadState am == Nothing' -> w
|
||||
ActivePartial{} | am ^? laTransfer . transferTime == Just 0 -> stopSoundFrom (CrReloadSound cid) w
|
||||
ActivePartial{} | _laTransfer am == NoTransfer -> w
|
||||
ActivePartial{} -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
|
||||
Just ChargeableAmmo {} -> w
|
||||
Just NoConsumption {} -> w
|
||||
|
||||
@@ -24,8 +24,8 @@ onBoth :: (a -> b -> c) -> (d -> a) -> (d -> b) -> d -> c
|
||||
onBoth f g h x = f (g x) (h x)
|
||||
|
||||
crIsReloading :: Creature -> Bool
|
||||
crIsReloading cr = case cr ^? crInv . ix (_crInvSel cr) . itConsumption . laReloadState . _Just' of
|
||||
Just t -> t > 0
|
||||
crIsReloading cr = case cr ^? crStance . posture of
|
||||
Just Reloading -> True
|
||||
_ -> False
|
||||
|
||||
crCanSeeCr :: Creature -> (World, Creature) -> Bool
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user