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
+1 -12
View File
@@ -7,7 +7,7 @@ module Dodge.Creature.Action
, setMinInvSize
, dropUnselected
, dropExcept
, startReloadingWeapon
-- , startReloadingWeapon
, blinkAction
, sizeSelf
, crAutoReload
@@ -144,17 +144,6 @@ performAction cr w ac = case ac of
(imps , _) -> (imps, Just $ DoReplicatePartial sac (t-1) sac)
NoAction -> ([],Nothing)
startReloadingWeapon :: Creature -> World -> Maybe World
startReloadingWeapon cr w = case it of
Weapon {_itConsumption = LoadableAmmo {_ammoMax=maxA,_ammoLoaded=lA ,_reloadState=rS,_reloadTime=rT}}
| lA < maxA && rS == Nothing' ->
Just -- $ set ( itRef . itConsumption . ammoLoaded) maxA
$ set ( itRef . itConsumption . reloadState) (Just' rT) w
_ -> Nothing
where
cid = _crID cr
it = _crInv cr IM.! _crInvSel cr
itRef = creatures . ix cid . crInv . ix (_crInvSel cr)
{- | Start reloading if clip is empty. -}
crAutoReload :: Creature -> Creature
crAutoReload cr = case cr ^? ptrItConsumption' . ammoLoaded of