Continue inventory tweak
This commit is contained in:
+14
-14
@@ -14,17 +14,17 @@ crCancelReloading :: Creature -> Creature
|
||||
crCancelReloading cr =
|
||||
cr
|
||||
& updateProgress
|
||||
& crManipulation . isel . iselAction .~ NoInvSelAction
|
||||
& crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
|
||||
where
|
||||
updateProgress = case crSel cr of
|
||||
SelItem i _ -> crInv . ix i . itUse . heldConsumption . laProgress %~ const Nothing
|
||||
InInventory (SelItem i _) -> crInv . ix i . itUse . heldConsumption . laProgress %~ const Nothing
|
||||
_ -> id
|
||||
|
||||
stepReloading :: Creature -> Creature
|
||||
stepReloading cr = case cr ^?! crManipulation . isel of
|
||||
SelItem i (ReloadAction x la)
|
||||
stepReloading cr = case cr ^? crManipulation . manObject . inInventory of
|
||||
Just (SelItem i (ReloadAction x la))
|
||||
| x > 0 ->
|
||||
cr & crManipulation . isel . iselAction . actionProgress -~ 1
|
||||
cr & crManipulation . manObject . inInventory . iselAction . actionProgress -~ 1
|
||||
| otherwise ->
|
||||
cr
|
||||
& crInv . ix i . itUse . heldConsumption %~ doLoadAction la
|
||||
@@ -33,22 +33,22 @@ stepReloading cr = case cr ^?! crManipulation . isel of
|
||||
_ -> cr
|
||||
|
||||
tryNextLoadAction :: Creature -> Creature
|
||||
tryNextLoadAction cr = case cr ^? crManipulation . isel of
|
||||
tryNextLoadAction cr = case cr ^? crManipulation . manObject . inInventory of
|
||||
Just (SelItem i _) -> case cr ^? crInv . ix i . itUse . heldConsumption . laProgress . _Just . ix 0 of
|
||||
Nothing -> cr & crManipulation . isel . iselAction .~ NoInvSelAction
|
||||
Nothing -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
|
||||
Just la ->
|
||||
cr & crManipulation . isel . iselAction . actionProgress .~ _actionTime la
|
||||
& crManipulation . isel . iselAction . reloadAction .~ la
|
||||
cr & crManipulation . manObject . inInventory . iselAction . actionProgress .~ _actionTime la
|
||||
& crManipulation . manObject . inInventory . iselAction . reloadAction .~ la
|
||||
_ -> cr
|
||||
|
||||
crToggleReloading :: Creature -> Creature
|
||||
crToggleReloading cr = case cr ^? crManipulation . isel . iselAction of
|
||||
Just ReloadAction{} -> cr & crManipulation . isel . iselAction .~ NoInvSelAction
|
||||
crToggleReloading cr = case cr ^? crManipulation . manObject . inInventory . iselAction of
|
||||
Just ReloadAction{} -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
|
||||
_ -> cr & tryStartLoading
|
||||
|
||||
tryStartLoading :: Creature -> Creature
|
||||
tryStartLoading cr = fromMaybe cr $ do
|
||||
i <- cr ^? crManipulation . isel . ispItem
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
hc <- cr ^? crInv . ix i . itUse . heldConsumption
|
||||
return $ startLoading hc cr
|
||||
|
||||
@@ -60,12 +60,12 @@ startLoading ic cr = case ic ^? laProgress . _Just . ix 0 of
|
||||
Just [] -> error "item has empty load cycle"
|
||||
Just _ | _laLoaded ic >= _laMax ic -> cr
|
||||
Just (la : las) -> fromMaybe (error "item loading error") $ do
|
||||
i <- cr ^? crManipulation . isel . ispItem
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
return $ cr & startLoadingStep la
|
||||
& crInv . ix i . itUse . heldConsumption . laProgress ?~ (la : las)
|
||||
|
||||
startLoadingStep :: LoadAction -> Creature -> Creature
|
||||
startLoadingStep la cr = cr & crManipulation . isel . iselAction .~ ReloadAction (_actionTime la) la
|
||||
startLoadingStep la cr = cr & crManipulation . manObject . inInventory . iselAction .~ ReloadAction (_actionTime la) la
|
||||
|
||||
rotateActionProgress :: HeldConsumption -> HeldConsumption
|
||||
rotateActionProgress ic = case ic ^? laProgress . _Just of
|
||||
|
||||
Reference in New Issue
Block a user