Remove internal ammo
This commit is contained in:
+9
-10
@@ -1,8 +1,7 @@
|
||||
module Dodge.Reloading (
|
||||
crCancelReloading,
|
||||
crUpdateLoadSource,
|
||||
crReload,
|
||||
stepReloading,
|
||||
tryStartLoading,
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
@@ -18,7 +17,7 @@ crCancelReloading cr =
|
||||
updateProgress = fromMaybe id $ do
|
||||
InInventory (SelItem i _) <- cr ^? crManipulation . manObject
|
||||
return $
|
||||
crInv . ix i . itUse . heldConsumption . laSource . _InternalSource . iaProgress
|
||||
crInv . ix (i + 1) . itUse . attachParams . ammoAttachParams . iaProgress
|
||||
%~ const Nothing
|
||||
|
||||
stepReloading :: Creature -> Creature
|
||||
@@ -28,29 +27,29 @@ stepReloading cr = case cr ^? crManipulation . manObject . inInventory of
|
||||
cr & crManipulation . manObject . inInventory . iselAction . actionProgress -~ 1
|
||||
| otherwise ->
|
||||
cr
|
||||
& crInv . ix i . itUse . heldConsumption . laSource . _InternalSource %~ doLoadAction la
|
||||
& crInv . ix i . itUse . heldConsumption . laSource . _InternalSource %~ rotateActionProgress
|
||||
& crInv . ix (i + 1) . itUse . attachParams . ammoAttachParams %~ doLoadAction la
|
||||
& crInv . ix (i + 1) . itUse . attachParams . ammoAttachParams %~ rotateActionProgress
|
||||
& tryNextLoadAction
|
||||
_ -> cr
|
||||
|
||||
tryNextLoadAction :: Creature -> Creature
|
||||
tryNextLoadAction cr = case cr ^? crManipulation . manObject . inInventory of
|
||||
Just (SelItem i _) -> case cr ^? crInv . ix i . itUse . heldConsumption . laSource . _InternalSource . iaProgress . _Just . ix 0 of
|
||||
Just (SelItem i _) -> case cr ^? crInv . ix i . itUse . attachParams . ammoAttachParams . iaProgress . _Just . ix 0 of
|
||||
Nothing -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
|
||||
Just la ->
|
||||
cr & crManipulation . manObject . inInventory . iselAction . actionProgress .~ _actionTime la
|
||||
& crManipulation . manObject . inInventory . iselAction . reloadAction .~ la
|
||||
_ -> cr
|
||||
|
||||
crUpdateLoadSource :: Creature -> Creature
|
||||
crUpdateLoadSource cr = case cr ^? crManipulation . manObject . inInventory . iselAction of
|
||||
crReload :: Creature -> Creature
|
||||
crReload cr = case cr ^? crManipulation . manObject . inInventory . iselAction of
|
||||
Just NoInvSelAction -> cr & tryStartLoading
|
||||
_ -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
|
||||
|
||||
tryStartLoading :: Creature -> Creature
|
||||
tryStartLoading cr = fromMaybe cr $ do
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
ia <- cr ^? crInv . ix i . itUse . heldConsumption . laSource . _InternalSource
|
||||
ia <- cr ^? crInv . ix (i + 1) . itUse . attachParams . ammoAttachParams
|
||||
return $ startLoading ia cr
|
||||
|
||||
-- case as of
|
||||
@@ -67,7 +66,7 @@ startLoading ic cr = case ic ^? iaProgress . _Just . ix 0 of
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
return $
|
||||
cr & startLoadingStep la
|
||||
& crInv . ix i . itUse . heldConsumption . laSource . _InternalSource . iaProgress ?~ (la : las)
|
||||
& crInv . ix i . itUse . attachParams . ammoAttachParams . iaProgress ?~ (la : las)
|
||||
|
||||
startLoadingStep :: LoadAction -> Creature -> Creature
|
||||
startLoadingStep la cr = cr & crManipulation . manObject . inInventory . iselAction .~ ReloadAction (_actionTime la) la
|
||||
|
||||
Reference in New Issue
Block a user