Unify key press and mouse button press timings

Both now use Ints for presses.
Still no release timer for keyboard events.
This commit is contained in:
2025-07-28 23:16:05 +01:00
parent ea35753744
commit 81f88c32e9
15 changed files with 52 additions and 58 deletions
+8 -8
View File
@@ -43,14 +43,14 @@ import RandomHelp
import qualified SDL
import Sound.Data
gadgetEffect :: PressType -> LocationDT OItem -> Creature -> World -> World
gadgetEffect :: Int -> LocationDT OItem -> Creature -> World -> World
gadgetEffect pt loc
| UseHeld{} <- loc ^. locDT . dtValue . _1 . itUse = heldEffect pt loc
| PulseBallSF <- loc ^. locDT . dtValue . _2 = heldEffect pt loc
-- hammerCheck (\a b c -> creatureShootPulseBall a b cmuz c) pt loc
| DROPPER x <- loc ^. locDT . dtValue . _1 . itType
, Just i <- loc ^? locDT . dtValue . _1 . itUse . uInt
, pt == InitialPress =
, pt == 0 =
dropInventoryPath i x loc
| CLICKER x <- loc ^. locDT . dtValue . _1 . itType
, Just i <- loc ^? locDT . dtValue . _1 . itUse . uInt =
@@ -58,12 +58,12 @@ gadgetEffect pt loc
| otherwise = const id
heldEffect :: PressType -> LocationDT OItem -> Creature -> World -> World
heldEffect :: Int -> LocationDT OItem -> Creature -> World -> World
heldEffect = hammerCheck heldEffectMuzzles
hammerCheck ::
(LocationDT OItem -> Creature -> World -> World) ->
PressType ->
Int ->
LocationDT OItem ->
Creature ->
World ->
@@ -96,11 +96,11 @@ hammerCheck f pt loc cr w = case itemTriggerType loc of
WarmUpCoolDown{} -> w & setwarming
BurstTrigger is t
| w ^. cWorld . lWorld . lClock - t > timelastused
, pt == InitialPress ->
, pt == 0 ->
w & f loc cr & cWorld . lWorld . delayedEvents .++~ map g is
VolleyGunTrigger i t
| w ^. cWorld . lWorld . lClock - t > timelastused
, pt == InitialPress ->
, pt == 0 ->
let (is, gen) = getVolleyBurst i (w ^. randGen)
in w & f loc cr
& cWorld . lWorld . delayedEvents .++~ map g is
@@ -108,7 +108,7 @@ hammerCheck f pt loc cr w = case itemTriggerType loc of
HammerTrigger t
| w ^. cWorld . lWorld . lClock - t > timelastused
, isNothing $ find ((== MakeAutoSF) . (^. dtValue . _2)) (loc ^. locDT . dtRight)
, pt == InitialPress ->
, pt == 0 ->
f loc cr w
AutoTrigger t
| w ^. cWorld . lWorld . lClock - t > timelastused -> f loc cr w
@@ -1460,7 +1460,7 @@ warmupSound = \case
_ -> crankSlowS
useInventoryPath ::
PressType ->
Int ->
Int ->
InventoryPathing ->
LocationDT OItem ->