Work towards adding external ammo sources

This commit is contained in:
2023-05-17 11:01:52 +01:00
parent 63c71c852d
commit 7df81559d9
30 changed files with 246 additions and 196 deletions
+7 -2
View File
@@ -40,8 +40,13 @@ crIsReloading cr = case cr ^? crManipulation . manObject . inInventory . iselAct
crWeaponReady :: Creature -> Bool
crWeaponReady cr = fromMaybe False $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem
ic <- cr ^? crInv . ix i . itUse . heldConsumption
return (_laLoaded ic > 0 && _laPrimed ic)
asource <- cr ^? crInv . ix i . itUse . heldConsumption . laSource
case asource of
InternalSource ia -> return (_iaLoaded ia > 0 && _iaPrimed ia)
ExternalSource ea -> do
srcid <- ea ^? _Just
x <- cr ^? crInv . ix srcid . itUse . equipEffect . eeUse . euseAmmoAmount
return (x > 0)
crCanSeeCr :: Creature -> (World, Creature) -> Bool
crCanSeeCr tcr (w, cr) = hasLOS (_crPos cr) (_crPos tcr) w