Implement teleporting bullets

This commit is contained in:
2022-02-21 20:51:01 +00:00
parent 724ee21afc
commit f626fce105
23 changed files with 245 additions and 154 deletions
+5 -5
View File
@@ -1,7 +1,6 @@
module Dodge.Reloading where
import Dodge.Data
import Dodge.Base
import Dodge.Item.MaxAmmo
--import qualified Data.IntMap.Strict as IM
--import Data.Maybe
@@ -14,7 +13,7 @@ startReloadingWeapon cr = (creatures . ix (_crID cr) . crInv . ix (_crInvSel cr)
icTryStartReloading :: Item -> Maybe Item
icTryStartReloading it
| _ammoLoaded am < itMaxAmmo it && _reloadState am == Nothing'
| _ammoLoaded am < _ammoBaseMax (_itConsumption it) && _reloadState am == Nothing'
= Just $ it & itConsumption . reloadState .~ Just' (_reloadTime am)
& if _reloadType am == ActiveClear then itConsumption . ammoLoaded .~ 0 else id
| otherwise = Nothing
@@ -36,14 +35,15 @@ stepReloading cr = case cr ^? crInv . ix isel . itConsumption . reloadState . _J
isel = _crInvSel cr
doload it = case _reloadType itcon of
ActivePartial x
| x + _ammoLoaded itcon < itMaxAmmo it -> it & itConsumption . ammoLoaded %~ (+ x)
| x + _ammoLoaded itcon < itMaxAmmo -> it & itConsumption . ammoLoaded %~ (+ x)
& itConsumption . reloadState .~ Just' (_reloadTime itcon)
| otherwise -> it & itConsumption . ammoLoaded .~ itMaxAmmo it
| otherwise -> it & itConsumption . ammoLoaded .~ itMaxAmmo
& itConsumption . reloadState .~ Nothing'
_ -> it & itConsumption . ammoLoaded .~ itMaxAmmo it
_ -> it & itConsumption . ammoLoaded .~ itMaxAmmo
& itConsumption . reloadState .~ Nothing'
where
itcon = _itConsumption it
itMaxAmmo = _ammoBaseMax itcon
--{- | Start reloading if clip is empty. -}
--crAutoReload :: Creature -> Creature