Allow for partial reloading
This commit is contained in:
@@ -45,7 +45,8 @@ stateUpdate :: CRUpdate -> CRUpdate
|
||||
stateUpdate u cr w = case u (updateMovement cr) w of
|
||||
(f, maybeCr) ->
|
||||
( Endo $ invSideEff (fromMaybe cr maybeCr) . movementSideEff cr . deathEff . appEndo f
|
||||
, fmap (stepReloading . doDamage . crAutoReload) $ crOrCorpse =<< maybeCr
|
||||
--, fmap (stepReloading . doDamage . crAutoReload) $ crOrCorpse =<< maybeCr
|
||||
, fmap (stepReloading . doDamage) $ crOrCorpse =<< maybeCr
|
||||
)
|
||||
where
|
||||
crOrCorpse cr'
|
||||
@@ -145,13 +146,16 @@ invSideEff cr w = weaponReloadSounds cr $ IM.foldrWithKey f w (_crInv cr)
|
||||
|
||||
weaponReloadSounds :: Creature -> World -> World
|
||||
weaponReloadSounds cr w = case cr ^? crInv . ix (_crInvSel cr) . itConsumption of
|
||||
Just am@LoadableAmmo{} -> case _wpReloadType am of
|
||||
PassiveReload stype |_wpReloadTime am ==_wpReloadState am
|
||||
Just am@LoadableAmmo{} -> case _reloadType am of
|
||||
PassiveReload stype |Just' (_reloadTime am) == _reloadState am
|
||||
-> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w
|
||||
PassiveReload _ -> w
|
||||
ActiveReload | _wpReloadState am == 1 -> stopSoundFrom (CrReloadSound cid) w
|
||||
ActiveReload | _wpReloadState am == 0 -> w
|
||||
ActiveReload | _reloadState am == Just' 0 -> stopSoundFrom (CrReloadSound cid) w
|
||||
ActiveReload | _reloadState am == Nothing' -> w
|
||||
ActiveReload -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
|
||||
PartialActive{} | _reloadState am == Just' 0 -> stopSoundFrom (CrReloadSound cid) w
|
||||
PartialActive{} | _reloadState am == Nothing' -> w
|
||||
PartialActive{} -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
|
||||
Just ChargeableAmmo {} -> w
|
||||
Just ItemItselfConsumable {} -> w
|
||||
Nothing -> w
|
||||
@@ -186,8 +190,18 @@ isFrictionless cr = case cr ^? crStance . carriage of
|
||||
_ -> False
|
||||
|
||||
stepReloading :: Creature -> Creature
|
||||
stepReloading cr = over (crInv . ix iSel . itConsumption . wpReloadState) decreaseToZero cr
|
||||
stepReloading cr = case cr ^? crInv . ix isel . itConsumption . reloadState . _Just' of
|
||||
Just 0 -> cr & crInv . ix isel . itConsumption . reloadState .~ Nothing'
|
||||
& crInv . ix isel . itConsumption %~ doload
|
||||
Just _ -> cr & crInv . ix isel . itConsumption . reloadState . _Just' %~ decreaseToZero
|
||||
Nothing -> cr
|
||||
where
|
||||
iSel = _crInvSel cr
|
||||
isel = _crInvSel cr
|
||||
doload itcon = itcon & ammoLoaded %~ (min (_ammoMax itcon) . (+ amount))
|
||||
where
|
||||
amount = case _reloadType itcon of
|
||||
PartialActive x -> x
|
||||
_ -> _ammoMax itcon
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user