diff --git a/src/Dodge/Creature/Impulse/UseItem.hs b/src/Dodge/Creature/Impulse/UseItem.hs index 6ac97e8ee..4708f5faf 100644 --- a/src/Dodge/Creature/Impulse/UseItem.hs +++ b/src/Dodge/Creature/Impulse/UseItem.hs @@ -40,16 +40,6 @@ useRootItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMaybe w where fst3 (x,_,_) = x --- 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 - toggleEquipmentAt :: Int -> Creature -> World -> World toggleEquipmentAt invid cr w = case getEquipmentAllocation w of DoNotMoveEquipment -> w @@ -108,8 +98,7 @@ useItemLeftClick cr w = fromMaybe w $ do UseHotkey{} -> return $ doequipmentchange invid UseAmmoMag{} -> return w UseAttach{} -> do - itmtree <- invTrees (_crInv cr) ^? ix invid - return $ selectUse itmtree cr w + return $ selectUse itm cr w _ -> Nothing where doequipmentchange invid = fromMaybe w $ do diff --git a/src/Dodge/Item/Grammar.hs b/src/Dodge/Item/Grammar.hs index 920729adb..33a0306ed 100644 --- a/src/Dodge/Item/Grammar.hs +++ b/src/Dodge/Item/Grammar.hs @@ -1,6 +1,5 @@ module Dodge.Item.Grammar ( invLDT, - invTrees, invAdj, invRootMap, invRootTrees, @@ -9,7 +8,6 @@ module Dodge.Item.Grammar ( ) where import Control.Applicative -import Data.Bifunctor import qualified Data.IntMap.Strict as IM import Data.Maybe import Dodge.Data.ComposedItem @@ -205,19 +203,6 @@ invAdj = IM.unions . map g . invLDT (error ("invAdj item " ++ show (_itID itm) ++ " location: " ++ show (itm ^? itLocation))) $ itm ^? itLocation . ilInvID --- returns an intmap with trees for all items -invTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ComposeLinkType Item) -invTrees = fmap (first _iatType) . invTrees' - --- returns an intmap with trees for all items -invTrees' :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ItemLink Item) ---invTrees' = IM.unions . map (ldtToIM getindex . fmap (^. _1)) . map (fmap (\(x, y, _) -> (x, y))) . invLDT -invTrees' = IM.unions . map (ldtToIM getindex . fmap (^. _1)) . invLDT - where - getindex i = - fromMaybe (error "in invTrees try to get non-inventory item tree") $ - i ^? itLocation . ilInvID - -- returns an intmap with trees for (only!) root items, indexed by inventory position invRootTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ItemLink ComposedItem) invRootTrees = IM.fromDistinctAscList . reverse . map getid . invLDT diff --git a/src/Dodge/SelectUse.hs b/src/Dodge/SelectUse.hs index 275030ce8..e52ecc10d 100644 --- a/src/Dodge/SelectUse.hs +++ b/src/Dodge/SelectUse.hs @@ -4,17 +4,15 @@ import Control.Monad import qualified SDL import Control.Lens import Data.Maybe -import Dodge.Data.ComposedItem -import Dodge.Data.DoubleTree import Dodge.Data.World import Dodge.Payload -selectUse :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World -selectUse ittree _ w = fromMaybe w $ do +selectUse :: Item -> Creature -> World -> World +selectUse itm _ w = fromMaybe w $ do lbtime <- w ^? input . mouseButtons . ix SDL.ButtonLeft guard $ lbtime == 0 - itid <- ittree ^? ldtValue . itID - pjid <- ittree ^? ldtValue . itUse . uaParams . apLinkedProjectile . _Just + itid <- itm ^? itID + pjid <- itm ^? itUse . uaParams . apLinkedProjectile . _Just thepj <- w ^? cWorld . lWorld . projectiles . ix pjid return $ w