Make examine inventory controlled by item, perhaps still buggy

This commit is contained in:
2025-01-01 21:14:38 +00:00
parent 86aba6d115
commit 5b978d9f1c
25 changed files with 523 additions and 502 deletions
+24 -17
View File
@@ -4,8 +4,8 @@ module Dodge.Creature.Impulse.UseItem (
useItem,
) where
import Dodge.ToggleExamine
import Control.Lens
import Control.Monad
import Data.Maybe
import Dodge.Data.ComposedItem
import Dodge.Data.DoubleTree
@@ -15,6 +15,7 @@ import Dodge.Euse
import Dodge.HeldUse
import Dodge.Inventory
import Dodge.Item.Grammar
import Dodge.Item.Location
import qualified IntMapHelp as IM
useItem :: Int -> PressType -> World -> Maybe World
@@ -30,27 +31,33 @@ useItemLoc ::
PressType ->
World ->
Maybe World
useItemLoc cr loc pt w = case loc ^. locLDT . ldtValue . _2 of
HeldPlatformSF -> do
guard $ fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsRoot
guard $ cr ^. crStance . posture == Aiming
useItemLoc cr loc pt w
| HeldPlatformSF <- sf
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsRoot
, cr ^. crStance . posture == Aiming =
return $ heldEffect pt (bimap _iatType (^. _1) ldt) cr w
GadgetPlatformSF ->
return $
heldEffect pt (bimap _iatType (^. _1) ldt) cr w
UnderBarrelPlatformSF -> do
guard $ fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached
guard $ cr ^. crStance . posture == Aiming
| GadgetPlatformSF <- sf =
return $ heldEffect pt (bimap _iatType (^. _1) ldt) cr w
RemoteDetonatorSF -> do
guard $ pt == InitialPress
| UnderBarrelPlatformSF <- sf
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached
, cr ^. crStance . posture == Aiming =
return $ heldEffect pt (bimap _iatType (^. _1) ldt) cr w
| RemoteDetonatorSF <- sf
, pt == InitialPress =
return $ activateDetonator ldt w
_ | isJust $ itm ^? itUse . uequipEffect -> do
guard $ pt == InitialPress
invid' <- itm ^? itLocation . ilInvID
| ITEMSCANNER <- itm ^. itType
, pt == InitialPress =
return $ toggleExamineInv w
| Just b <- itm ^? itUse . useToggle
, pt == InitialPress =
return $ w & pointerToItem itm . itUse . useToggle .~ not b
| isJust $ itm ^? itUse . uequipEffect
, pt == InitialPress
, Just invid' <- itm ^? itLocation . ilInvID =
return $ toggleEquipmentAt invid' cr w
_ -> Nothing
| otherwise = Nothing
where
sf = loc ^. locLDT . ldtValue . _2
ldt = loc ^. locLDT
itm = ldt ^. ldtValue . _1