Add clicker items that use other items with a one frame delay

This commit is contained in:
2025-01-03 14:50:09 +00:00
parent 386d6f47b0
commit 3b452b9002
10 changed files with 41 additions and 0 deletions
+22
View File
@@ -48,6 +48,9 @@ gadgetEffect pt loc
| DROPPER x <- loc ^. locLDT . ldtValue . _1 . itType
, Just i <- loc ^? locLDT . ldtValue . _1 . itUse . uInt
, pt == InitialPress = dropInventoryPath i x loc
| CLICKER x <- loc ^. locLDT . ldtValue . _1 . itType
, Just i <- loc ^? locLDT . ldtValue . _1 . itUse . uInt
= useInventoryPath pt i x loc
| otherwise = const id
heldEffect ::
@@ -793,6 +796,25 @@ dropInventoryPath i ip loc cr w = case ip of
guard $ (i + j) `IM.member` (cr ^. crInv)
return $ dropItem cr (i + j) w
useInventoryPath :: PressType ->
Int -> InventoryPathing -> LocationLDT ItemLink ComposedItem
-> Creature
-> World -> World
useInventoryPath pt i ip loc cr w = case ip of
ABSOLUTE -> fromMaybe w $ do
guard $ i `IM.member` (cr ^. crInv)
return $ w & cWorld . lWorld . delayedEvents .:~ (1,UseInvItem i pt)
RELCURS -> fromMaybe w $ do
j <- cr ^? crManipulation . manObject . imSelectedItem
guard $ (i + j) `IM.member` (cr ^. crInv)
return $ w
& cWorld . lWorld . delayedEvents .:~ (1,UseInvItem (i+j) pt)
RELITEM -> fromMaybe w $ do
j <- loc ^? locLDT . ldtValue . _1 . itLocation . ilInvID
guard $ (i + j) `IM.member` (cr ^. crInv)
return $ w
& cWorld . lWorld . delayedEvents .:~ (1,UseInvItem (i+j) pt)
--useRewindGun _ _ w = case w ^. cwTime . rewindWorlds of
-- [w'] -> w & cwTime . maybeWorld .~ Just' w'
-- (w' : ws) -> w