Start work on crafting/combinations
This commit is contained in:
@@ -3,6 +3,7 @@ import Dodge.Data
|
||||
import Dodge.Base
|
||||
--import qualified Data.IntMap.Strict as IM
|
||||
|
||||
import Data.Maybe
|
||||
import Control.Lens
|
||||
|
||||
startReloadingWeapon :: Creature -> World -> Maybe World
|
||||
@@ -34,3 +35,16 @@ stepReloading cr = case cr ^? crInv . ix isel . itConsumption . reloadState . _J
|
||||
& reloadState .~ Nothing'
|
||||
_ -> itcon & ammoLoaded .~ _ammoMax itcon
|
||||
& reloadState .~ Nothing'
|
||||
|
||||
{- | Start reloading if clip is empty. -}
|
||||
crAutoReload :: Creature -> Creature
|
||||
crAutoReload cr = case cr ^? ptrItConsumption' . ammoLoaded of
|
||||
Just 0 | _posture (_crStance cr) /= Aiming
|
||||
-> cr & ptrItConsumption . reloadState .~ strictify reloadT
|
||||
& ptrItConsumption . ammoLoaded %~ (`fromMaybe` maxA)
|
||||
_ -> cr
|
||||
where
|
||||
ptrItConsumption = crInv . ix (_crInvSel cr) . itConsumption
|
||||
ptrItConsumption' = crInv . ix (_crInvSel cr) . itConsumption
|
||||
reloadT = cr ^? ptrItConsumption' . reloadTime
|
||||
maxA = cr ^? ptrItConsumption' . ammoMax
|
||||
|
||||
Reference in New Issue
Block a user