Remove reduntant left click item use code
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
module Dodge.Creature.Impulse.UseItem (
|
||||
useRootItem,
|
||||
useItemLeftClick,
|
||||
itemUseEffect,
|
||||
useItemHotkey,
|
||||
) where
|
||||
|
||||
@@ -51,26 +50,6 @@ useRootItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMaybe w
|
||||
-- UseScope{} -> w
|
||||
-- UseBulletMod{} -> w
|
||||
|
||||
itemUseEffect :: Creature -> LabelDoubleTree ComposeLinkType Item -> World -> World
|
||||
itemUseEffect cr itmtree w = case itmtree ^. ldtValue . itUse of
|
||||
UseHeld{} ->
|
||||
heldEffect itmtree cr w
|
||||
& pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||
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 = itmtree ^. ldtValue
|
||||
doequipmentchange = fromMaybe w $ do
|
||||
guard (_crHammerPosition cr == HammerUp)
|
||||
invid <- itm ^? itLocation . ilInvID
|
||||
return $ toggleEquipmentAt invid cr w
|
||||
|
||||
toggleEquipmentAt :: Int -> Creature -> World -> World
|
||||
toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
||||
DoNotMoveEquipment -> w
|
||||
@@ -120,23 +99,22 @@ useItemLeftClick :: Creature -> World -> World
|
||||
useItemLeftClick cr w = fromMaybe w $ do
|
||||
guard . not $ _crInvLock cr
|
||||
invid <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
itm <- cr ^? crInv . ix invid
|
||||
ituse <- cr ^? crInv . ix invid . itUse
|
||||
case ituse of
|
||||
UseHeld{} -> return w
|
||||
UseConsume{} -> return $ useItemLeftClick' cr w
|
||||
UseEquip{} -> return $ useItemLeftClick' cr w
|
||||
UseHotkey{} -> return $ useItemLeftClick' cr w
|
||||
UseConsume eff -> return $ useC eff itm cr w
|
||||
UseEquip{} -> return $ doequipmentchange invid
|
||||
UseHotkey{} -> return $ doequipmentchange invid
|
||||
UseAmmoMag{} -> return w
|
||||
UseAttach{} -> do
|
||||
itmtree <- invTrees (_crInv cr) ^? ix invid
|
||||
return $ selectUse itmtree cr w
|
||||
_ -> Nothing
|
||||
|
||||
useItemLeftClick' :: Creature -> World -> World
|
||||
useItemLeftClick' cr' w = fromMaybe w $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix (_crID cr')
|
||||
itRef <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
it <- invTrees (_crInv cr) ^? ix itRef
|
||||
return $
|
||||
itemUseEffect cr it w
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
where
|
||||
doequipmentchange invid = fromMaybe w $ do
|
||||
guard (_crHammerPosition cr == HammerUp)
|
||||
return $ toggleEquipmentAt invid cr w
|
||||
|
||||
-- & f
|
||||
-- where
|
||||
|
||||
@@ -138,6 +138,4 @@ shoulderSH = translateSHz 20
|
||||
|
||||
drawEquipment :: Creature -> SPic
|
||||
{-# INLINE drawEquipment #-}
|
||||
drawEquipment cr = foldMap
|
||||
(itemEquipPict cr)
|
||||
(invLDT $ _crInv cr)
|
||||
drawEquipment cr = foldMap (itemEquipPict cr) (invLDT $ _crInv cr)
|
||||
|
||||
@@ -253,10 +253,9 @@ chainLinkOrientation ::
|
||||
ItemLink ->
|
||||
ComposedItem ->
|
||||
(Point3, Q.Quaternion Float)
|
||||
chainLinkOrientation mo (par, _, _) (ILink lt f) (child, _, _) =
|
||||
chainLinkOrientation (p,q) (par, _, _) (ILink lt f) (child, _, _) =
|
||||
(p + Q.rotate q p1, q * q1)
|
||||
where
|
||||
(p, q) = mo
|
||||
(p1, q1) = f par lt child
|
||||
|
||||
updateItemWithOrientation ::
|
||||
|
||||
Reference in New Issue
Block a user