Move UseDelay out of records
This commit is contained in:
+10
-9
@@ -10,6 +10,7 @@ module Dodge.HeldUse (
|
||||
heldEffectMuzzles,
|
||||
) where
|
||||
|
||||
import Dodge.Item.UseDelay
|
||||
import Dodge.Base
|
||||
import Color
|
||||
import Control.Applicative
|
||||
@@ -110,24 +111,24 @@ hammerCheck f pt it cr
|
||||
|
||||
-- | Applies a world effect after an item use cooldown check.
|
||||
useTimeCheck :: ChainEffect
|
||||
useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
|
||||
Just (FixedRate rate)
|
||||
useTimeCheck f item cr w = case useDelay $ item ^. ldtValue of
|
||||
FixedRate rate
|
||||
| w ^. cWorld . lWorld . lClock - rate > lastused -> f item cr $ setUseRate w
|
||||
Just FixedRate{} -> w
|
||||
FixedRate{} -> w
|
||||
--Just (WarmUpNoDelay wt wm ws)
|
||||
Just (WarmUpNoDelay wm ws)
|
||||
WarmUpNoDelay wm ws
|
||||
-- | wt < wm ->
|
||||
| _wTime (_itParams $ _ldtValue item) < wm ->
|
||||
w
|
||||
& soundContinue (CrWeaponSound cid 0) (_crPos cr) ws (Just 2)
|
||||
-- & cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . warmTime +~ 2
|
||||
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime +~ 2
|
||||
Just (WarmUpNoDelay wm _) ->
|
||||
WarmUpNoDelay wm _ ->
|
||||
f item cr w
|
||||
-- & cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . warmTime .~ (wm + 1)
|
||||
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime .~ (wm + 1)
|
||||
Just NoDelay -> f item cr w
|
||||
Nothing -> w
|
||||
NoDelay -> f item cr w
|
||||
--Nothing -> w
|
||||
where
|
||||
lastused = item ^. ldtValue . itTimeLastUsed
|
||||
cid = _crID cr
|
||||
@@ -625,7 +626,7 @@ loadMuzzle ::
|
||||
Muzzle ->
|
||||
(LabelDoubleTree ComposeLinkType Item, Maybe (Muzzle, Int, LabelDoubleTree ComposeLinkType Item))
|
||||
loadMuzzle t@(LDT _ l _) mz = fromMaybe (t, Nothing) $ do
|
||||
guard $ mz ^? mzFrame == t ^? ldtValue . itUse . heldFrame
|
||||
-- guard $ mz ^? mzFrame == t ^? ldtValue . itUse . heldFrame
|
||||
let as = _mzAmmoSlot mz
|
||||
amamount = _mzAmmoPerShot mz
|
||||
(i, (_, mag)) <- findWithIx (isAmmoIntLink as . fst) l
|
||||
@@ -1171,7 +1172,7 @@ mcShootLaser _ mc =
|
||||
|
||||
mcShootAuto :: Item -> Machine -> World -> World
|
||||
mcShootAuto itm mc w
|
||||
| Just (FixedRate rate) <- mc ^? mcType . mctTurret . tuWeapon . itUse . heldDelay
|
||||
| Just (FixedRate rate) <- useDelay <$> mc ^? mcType . mctTurret . tuWeapon -- . itUse . heldDelay
|
||||
, w ^. cWorld . lWorld . lClock - rate > lastused =
|
||||
w
|
||||
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . mctTurret . tuWeapon
|
||||
|
||||
Reference in New Issue
Block a user