Continue refactoring reloading

This commit is contained in:
2022-06-21 13:06:55 +01:00
parent 37eb69c661
commit 14a7189b44
12 changed files with 80 additions and 60 deletions
+4 -5
View File
@@ -31,14 +31,13 @@ itemDisplay it = Prelude.take (itSlotsTaken it) $
showConsumption :: ItemConsumption -> String
showConsumption ic = case ic of
am@LoadableAmmo{} -> showLoading (_laProgress ic) ++ show (_laLoaded am)
am@LoadableAmmo{} -> showLoading ic ++ show (_laLoaded am)
am@ChargeableAmmo{} -> show $ _wpCharge am
x@ItemItselfConsumable{} -> show (_icAmount x)
NoConsumption -> ""
showLoading :: LoadProgress -> String
showLoading lt = case lt ^? futureActions . ix 0 of
Just lap -> show (_actionTime (_actionType lap) - _actionProgress lap)
++ showLoadActionType (_actionType lap)
showLoading :: ItemConsumption -> String
showLoading ic = case ic ^? laProgress . _Just . ix 0 of
Just la -> showLoadActionType la
Nothing -> ""
showLoadActionType :: LoadAction -> String
showLoadActionType la = case la of
+1 -1
View File
@@ -154,7 +154,7 @@ smgAfterHamMods =
]
pistol :: Item
pistol = (bangStick 1)
pistol = bangStick 1
& itConsumption .~ ( defaultBulletLoadable
& laMax .~ 15
& laCycle .~ [Eject 5, Insert 5 Nothing, Prime 5] )
+5 -5
View File
@@ -173,15 +173,15 @@ rateIncAB exeffFirst exeffCont eff item cr w
itRef = _crInvSel cr
pointItem = creatures . ix cid . crInv . ix itRef
currentRate = _rateMax (_useDelay (_itUse item))
repeatFire = _laProgress (_itConsumption item) == FinishedLoading && _rateTime (_useDelay (_itUse item)) == 1
firstFire = _laProgress (_itConsumption item) == FinishedLoading && _rateTime (_useDelay (_itUse item)) == 0
repeatFire = crWeaponReady cr && _rateTime (_useDelay (_itUse item)) == 1
firstFire = crWeaponReady cr && _rateTime (_useDelay (_itUse item)) == 0
{- | Apply effect after a warm up. -}
-- note this is quite unsafe, requires the item to have the correct delay type
withWarmUp
:: SoundID -- ^ warm up sound id
-> ChainEffect
withWarmUp soundID f item cr w
| _laProgress (_itConsumption item) /= FinishedLoading = w
| crWeaponReady cr = w
| curWarmUp < maxWarmUp = w
& pointerToItem . itUse . useDelay . warmTime +~ 2
& soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2)
@@ -323,7 +323,7 @@ ammoUseCheck f item cr w
cid = _crID cr
itRef = _crInvSel cr
pointerToItem = creatures . ix cid . crInv . ix itRef
fireCondition = _laProgress (_itConsumption item) == FinishedLoading
fireCondition = crWeaponReady cr
&& _rateTime (_useDelay (_itUse item)) == 0
&& _laLoaded (_itConsumption item) > 0
-- reloadCondition = _laLoaded (_itConsumption item) == 0
@@ -359,7 +359,7 @@ shootL f item cr w
cid = _crID cr
invid = fromJust $ _itInvPos item
pointerToItem = creatures . ix cid . crInv . ix invid
fireCondition = _laProgress (_itConsumption item) == FinishedLoading
fireCondition = crWeaponReady cr
&& _rateTime (_useDelay (_itUse item)) == 0
&& _laLoaded (_itConsumption item) > 0
-- reloadCondition = _laLoaded (_itConsumption item) == 0