Cleanup
This commit is contained in:
@@ -124,7 +124,7 @@ doStrategyActions cr = case cr ^? crActionPlan . crStrategy of
|
||||
|
||||
reloadOverride :: Creature -> Creature
|
||||
reloadOverride cr
|
||||
| cr ^? crInv . ix (_crInvSel cr) . itConsumption . ammoLoaded == Just 0
|
||||
| cr ^? crInv . ix (_crInvSel cr) . itConsumption . laLoaded == Just 0
|
||||
&& cr ^. crStance . posture == Aiming
|
||||
= cr & crActionPlan . crStrategy .~ StrategyActions Reload reloadActions
|
||||
| otherwise = cr
|
||||
|
||||
@@ -234,15 +234,15 @@ 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 _reloadType am of
|
||||
PassiveReload stype |Just' (_reloadTime am) == _reloadState am
|
||||
Just am@LoadableAmmo{} -> case _laReloadType am of
|
||||
PassiveReload stype | Just' (_laReloadTime am) == _laReloadState am
|
||||
-> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w
|
||||
PassiveReload _ -> w
|
||||
ActiveClear | _reloadState am == Just' 0 -> stopSoundFrom (CrReloadSound cid) w
|
||||
ActiveClear | _reloadState am == Nothing' -> w
|
||||
ActiveClear | _laReloadState am == Just' 0 -> stopSoundFrom (CrReloadSound cid) w
|
||||
ActiveClear | _laReloadState am == Nothing' -> w
|
||||
ActiveClear -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
|
||||
ActivePartial{} | _reloadState am == Just' 0 -> stopSoundFrom (CrReloadSound cid) w
|
||||
ActivePartial{} | _reloadState am == Nothing' -> w
|
||||
ActivePartial{} | _laReloadState am == Just' 0 -> stopSoundFrom (CrReloadSound cid) w
|
||||
ActivePartial{} | _laReloadState am == Nothing' -> w
|
||||
ActivePartial{} -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
|
||||
Just ChargeableAmmo {} -> w
|
||||
Just NoConsumption {} -> w
|
||||
|
||||
@@ -24,7 +24,7 @@ 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 . reloadState . _Just' of
|
||||
crIsReloading cr = case cr ^? crInv . ix (_crInvSel cr) . itConsumption . laReloadState . _Just' of
|
||||
Just t -> t > 0
|
||||
_ -> False
|
||||
|
||||
@@ -54,7 +54,7 @@ crStratConMatches :: Strategy -> Creature -> Bool
|
||||
crStratConMatches strat cr = eqConstr strat (_crStrategy $ _crActionPlan cr)
|
||||
|
||||
crAwayFromPost :: Creature -> Bool
|
||||
crAwayFromPost cr = case find sentinelGoal $ _crGoal $ _crActionPlan cr of
|
||||
crAwayFromPost cr = case find sentinelGoal . _crGoal $ _crActionPlan cr of
|
||||
Just (SentinelAt p _) -> dist p (_crPos cr) > 15
|
||||
_ -> False
|
||||
where
|
||||
@@ -62,7 +62,7 @@ crAwayFromPost cr = case find sentinelGoal $ _crGoal $ _crActionPlan cr of
|
||||
sentinelGoal _ = False
|
||||
|
||||
crHasAmmo :: Creature -> Bool
|
||||
crHasAmmo cr = maybe False (> 0) $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . ammoLoaded
|
||||
crHasAmmo cr = maybe False (> 0) $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . laLoaded
|
||||
|
||||
crCanShoot :: Creature -> Bool
|
||||
crCanShoot p = crIsAiming p && crHasAmmo p
|
||||
|
||||
@@ -76,5 +76,5 @@ mouseActionsCr pkeys cr
|
||||
| rbPressed = cr & crStance . posture .~ Aiming
|
||||
| otherwise = cr & crStance . posture .~ AtEase
|
||||
where
|
||||
reloading = isJust $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . reloadState . _Just'
|
||||
reloading = isJust $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . laReloadState . _Just'
|
||||
rbPressed = SDL.ButtonRight `S.member` pkeys
|
||||
|
||||
Reference in New Issue
Block a user