Clear ammo when reloading clip based weaons

This commit is contained in:
2021-12-01 18:37:16 +00:00
parent 016a1faf80
commit 84ccff5344
7 changed files with 18 additions and 39 deletions
+7 -19
View File
@@ -4,6 +4,7 @@ module Dodge.Creature.State
) where
import Dodge.Data
import Dodge.Hammer
import Dodge.Reloading
import Dodge.Base
import Dodge.Creature.State.WalkCycle
--import Dodge.Creature.Test
@@ -150,12 +151,12 @@ weaponReloadSounds cr w = case cr ^? crInv . ix (_crInvSel cr) . itConsumption o
PassiveReload stype |Just' (_reloadTime am) == _reloadState am
-> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w
PassiveReload _ -> 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
ActiveClear | _reloadState am == Just' 0 -> stopSoundFrom (CrReloadSound cid) w
ActiveClear | _reloadState 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{} -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
Just ChargeableAmmo {} -> w
Just ItemItselfConsumable {} -> w
Nothing -> w
@@ -189,19 +190,6 @@ isFrictionless cr = case cr ^? crStance . carriage of
Just Floating -> True
_ -> False
stepReloading :: Creature -> Creature
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
doload itcon = itcon & ammoLoaded %~ (min (_ammoMax itcon) . (+ amount))
where
amount = case _reloadType itcon of
PartialActive x -> x
_ -> _ammoMax itcon