Start removing heldDelay records
This commit is contained in:
+19
-11
@@ -111,23 +111,29 @@ 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 lastused)
|
||||
Just (FixedRate rate)
|
||||
| w ^. cWorld . lWorld . lClock - rate > lastused -> f item cr $ setUseRate w
|
||||
Just FixedRate{} -> w
|
||||
Just (WarmUpNoDelay wt wm ws)
|
||||
| wt < wm ->
|
||||
--Just (WarmUpNoDelay wt wm ws)
|
||||
Just (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
|
||||
Just (WarmUpNoDelay _ wm _) ->
|
||||
-- & 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 _) ->
|
||||
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 . 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
|
||||
where
|
||||
lastused = item ^. ldtValue . itTimeLastUsed
|
||||
cid = _crID cr
|
||||
setUseRate =
|
||||
cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . rateTimeLastUsed
|
||||
--cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . rateTimeLastUsed
|
||||
cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itTimeLastUsed
|
||||
.~ w ^. cWorld . lWorld . lClock
|
||||
-- the following is unsafe, but if ilInvID isn't correctly set we probably
|
||||
-- will have problems elsewhere also
|
||||
@@ -1165,17 +1171,19 @@ mcShootLaser _ mc =
|
||||
|
||||
mcShootAuto :: Item -> Machine -> World -> World
|
||||
mcShootAuto itm mc w
|
||||
| Just (FixedRate rate lastused) <- mc ^? mcType . mctTurret . tuWeapon . itUse . heldDelay
|
||||
| Just (FixedRate rate) <- mc ^? mcType . mctTurret . tuWeapon . itUse . heldDelay
|
||||
, w ^. cWorld . lWorld . lClock - rate > lastused =
|
||||
w
|
||||
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . mctTurret . tuWeapon
|
||||
. itUse
|
||||
. heldDelay
|
||||
. rateTimeLastUsed
|
||||
. itTimeLastUsed
|
||||
-- . itUse
|
||||
-- . heldDelay
|
||||
-- . rateTimeLastUsed
|
||||
.~ w ^. cWorld . lWorld . lClock
|
||||
& makeBullet defaultBullet itm pos dir
|
||||
| otherwise = w
|
||||
where
|
||||
lastused = itm ^. itTimeLastUsed
|
||||
pos = _mcPos mc +.+ 20 *.* unitVectorAtAngle dir
|
||||
dir = mc ^?! mcType . _McTurret . tuDir
|
||||
|
||||
|
||||
Reference in New Issue
Block a user