Make lasGun have multiple functions when attached differently

This commit is contained in:
2024-10-06 11:19:19 +01:00
parent 3b54f00cc7
commit 9860a88c0c
11 changed files with 155 additions and 112 deletions
+24 -3
View File
@@ -26,11 +26,33 @@ useRootItem :: Int -> World -> World
useRootItem crid w = fromMaybe w $ do
cr <- w ^? cWorld . lWorld . creatures . ix crid
itRef <- cr ^? crManipulation . manObject . imRootItem
it <- invTrees (_crInv cr) ^? ix itRef
it <- invRootTrees (_crInv cr) ^? ix itRef
return $
itemUseEffect cr it w
itemUseEffect' cr it w
& worldEventFlags . at InventoryChange ?~ ()
itemUseEffect' :: Creature -> LabelDoubleTree ItemLink ComposedItem -> World -> World
itemUseEffect' cr itmtree w = case itmtree ^. ldtValue . cItemFunction of
WeaponPlatformSF -> heldEffect (bimap _iatType _cItem itmtree) cr w
& pointerToItem itm . itUse . heldHammer .~ HammerDown
_ -> w
-- UseHotkey{} -> doequipmentchange
-- UseEquip{} -> doequipmentchange
-- (UseConsume eff) -> useC eff (_ldtValue itmtree) cr w
-- UseCraft{} -> w
-- UseAttach{} -> selectUse itmtree cr w
-- UseAmmoMag{} -> w
-- UseScope{} -> w
-- UseBulletMod{} -> w
where
itm :: Item
itm = itmtree ^. ldtValue . cItem
-- doequipmentchange = fromMaybe w $ do
-- guard (_crHammerPosition cr == HammerUp)
-- invid <- itm ^? itLocation . ilInvID
-- return $ toggleEquipmentAt invid cr w
itemUseEffect :: Creature -> LabelDoubleTree ComposeLinkType Item -> World -> World
itemUseEffect cr itmtree w = case itmtree ^. ldtValue . itUse of
UseHeld{} -> heldEffect itmtree cr w
@@ -40,7 +62,6 @@ itemUseEffect cr itmtree w = case itmtree ^. ldtValue . itUse of
(UseConsume eff) -> useC eff (_ldtValue itmtree) cr w
UseCraft{} -> w
UseAttach{} -> selectUse itmtree cr w
-- UseTargeting {} -> w
UseAmmoMag{} -> w
UseScope{} -> w
UseBulletMod{} -> w