This commit is contained in:
2022-07-27 12:49:23 +01:00
parent 6554d219dc
commit 8d17ce66e9
106 changed files with 2911 additions and 2678 deletions
+8 -8
View File
@@ -13,7 +13,7 @@ import Control.Lens
crCancelReloading :: Creature -> Creature
crCancelReloading cr = cr
& crInv . ix (crSel cr) . itConsumption . laProgress %~ const Nothing
& crInv . ix (crSel cr) . itUse . heldConsumption . laProgress %~ const Nothing
& crInvSel . iselAction .~ NoInvSelAction
stepReloading :: Creature -> Creature
@@ -24,13 +24,13 @@ stepReloading cr = case cr ^?! crInvSel . iselAction of
& crInvSel . iselAction . actionHammer . hammerPosition %~ moveHammerUp
| otherwise -> cr
& crInvSel . iselAction . actionHammer . hammerPosition %~ moveHammerUp
& crInv . ix (crSel cr) . itConsumption %~ doLoadAction la
& crInv . ix (crSel cr) . itConsumption %~ rotateActionProgress
& crInv . ix (crSel cr) . itUse . heldConsumption %~ doLoadAction la
& crInv . ix (crSel cr) . itUse . heldConsumption %~ rotateActionProgress
& tryNextLoadAction
_ -> cr
tryNextLoadAction :: Creature -> Creature
tryNextLoadAction cr = case cr ^? crInv . ix (crSel cr) . itConsumption . laProgress . _Just . ix 0 of
tryNextLoadAction cr = case cr ^? crInv . ix (crSel cr) . itUse . heldConsumption . laProgress . _Just . ix 0 of
Nothing -> cr & crInvSel . iselAction .~ NoInvSelAction
Just la -> cr & crInvSel . iselAction . actionProgress .~ _actionTime la
& crInvSel . iselAction . reloadAction .~ la
@@ -52,22 +52,22 @@ tryStartLoading cr = case ic ^? laProgress . _Just . ix 0 of
Just [] -> error ("item has empty load cycle" ++ show (cr ^?! crInv . ix (crSel cr) . itType))
Just _ | _laLoaded ic >= _laMax ic -> cr
Just (la:las) -> cr & startLoadAction la
& crInv . ix (crSel cr) . itConsumption . laProgress ?~ (la:las)
& crInv . ix (crSel cr) . itUse . heldConsumption . laProgress ?~ (la:las)
where
ic = cr ^?! crInv . ix (crSel cr) . itConsumption
ic = cr ^?! crInv . ix (crSel cr) . itUse . heldConsumption
startLoadAction :: LoadAction -> Creature -> Creature
startLoadAction la cr = cr & crInvSel . iselAction .~ ReloadAction (_actionTime la) la NoHammer
rotateActionProgress :: ItemConsumption -> ItemConsumption
rotateActionProgress :: HeldConsumption -> HeldConsumption
rotateActionProgress ic = case ic ^? laProgress . _Just of
Just (_:la:las) -> ic & laProgress . _Just .~ (la:las)
_ | _laLoaded ic < _laMax ic -> ic & laProgress ?~ _laCycle ic
_ -> ic & laProgress .~ Nothing
doLoadAction :: LoadAction -> ItemConsumption -> ItemConsumption
doLoadAction :: LoadAction -> HeldConsumption -> HeldConsumption
doLoadAction la ic = case la of
LoadEject {} -> ic & laLoaded .~ 0 & laPrimed .~ False
LoadInsert {} -> ic & laLoaded .~ _laMax ic