Partial implementation of more sensible muzzle position determination

This commit is contained in:
2024-11-28 21:15:22 +00:00
parent 0d5e578f07
commit 3763ff2c8a
6 changed files with 188 additions and 133 deletions
+22 -29
View File
@@ -23,38 +23,31 @@ import Dodge.SelectUse
import qualified IntMapHelp as IM
useRootItem :: Int -> World -> World
useRootItem crid w = fromMaybe w $ do
useRootItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMaybe w $ do
cr <- w ^? cWorld . lWorld . creatures . ix crid
itRef <- cr ^? crManipulation . manObject . imRootSelectedItem
it <- invRootTrees (_crInv cr) ^? ix itRef
return $
itemUseEffect' cr it w
& worldEventFlags . at InventoryChange ?~ ()
itmtree <- invRootTrees (_crInv cr) ^? ix itRef
let itm = itmtree ^. ldtValue . cItem
case itmtree ^. ldtValue . cItemFunction of
WeaponPlatformSF ->
return $
heldEffect (bimap _iatType _cItem itmtree) cr w
& pointerToItem itm . itUse . heldHammer .~ HammerDown
EquipmentPlatformSF -> do
guard (_crHammerPosition cr == HammerUp)
invid <- itm ^? itLocation . ilInvID
return $ toggleEquipmentAt invid cr w
_ -> Nothing
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
EquipmentPlatformSF -> doequipmentchange
_ -> w
where
-- 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
itm :: Item
itm = itmtree ^. ldtValue . cItem
doequipmentchange = fromMaybe w $ do
guard (_crHammerPosition cr == HammerUp)
invid <- itm ^? itLocation . ilInvID
return $ toggleEquipmentAt invid cr w
-- where
-- 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
itemUseEffect :: Creature -> LabelDoubleTree ComposeLinkType Item -> World -> World
itemUseEffect cr itmtree w = case itmtree ^. ldtValue . itUse of