Stop equip after combining
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
module Dodge.Creature.Impulse.UseItem (
|
||||
useItem,
|
||||
doTopInvLeftClick,
|
||||
useItemRightClick,
|
||||
useItemLeftClick,
|
||||
itemEffect,
|
||||
tryUseL,
|
||||
useItemHotkey,
|
||||
) where
|
||||
|
||||
import Dodge.Hotkey
|
||||
@@ -22,8 +22,8 @@ import Dodge.Reloading
|
||||
import qualified IntMapHelp as IM
|
||||
import qualified SDL
|
||||
|
||||
useItem :: Creature -> World -> World
|
||||
useItem cr' w = fromMaybe (f w) $ do
|
||||
useItemRightClick :: Creature -> World -> World
|
||||
useItemRightClick cr' w = fromMaybe (f w) $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix (_crID cr')
|
||||
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
it <- cr ^? crInv . ix itRef
|
||||
@@ -113,25 +113,19 @@ toggleEquipmentAt rbops invid cr w = case rbops ^? opAllocateEquipment of
|
||||
onequip itm' = useE ((_eeOnEquip . _equipEffect . _itUse) itm') itm'
|
||||
onremove itm' = useE ((_eeOnRemove . _equipEffect . _itUse) itm') itm'
|
||||
|
||||
doTopInvLeftClick :: Creature -> World -> World
|
||||
doTopInvLeftClick cr w = fromMaybe w $ do
|
||||
useItemLeftClick :: Creature -> World -> World
|
||||
useItemLeftClick cr w = fromMaybe w $ do
|
||||
guard . not $ _crInvLock cr
|
||||
invid <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
ituse <- cr ^? crInv . ix invid . itUse
|
||||
case ituse of
|
||||
ConsumeUse{} -> return $ useItem cr w
|
||||
EquipUse{} -> return $ useItem cr w
|
||||
LeftUse{} -> return $ equipAndUse (_leftUseOnEquip ituse) invid cr w
|
||||
ConsumeUse{} -> return $ useItemRightClick cr w
|
||||
EquipUse{} -> return $ useItemRightClick cr w
|
||||
LeftUse{} -> return $ useItemRightClick cr w
|
||||
_ -> Nothing
|
||||
|
||||
equipAndUse :: Bool -> Int -> Creature -> World -> World
|
||||
equipAndUse useonequip invid cr w = case cr ^? crInvEquipped . ix invid of
|
||||
Nothing | useonequip -> tryUseL (_crID cr) invid $ useItem cr w
|
||||
| otherwise -> useItem cr w
|
||||
_ -> tryUseL (_crID cr) invid w
|
||||
|
||||
tryUseL :: Int -> Int -> World -> World
|
||||
tryUseL crid invid w = fromMaybe w $ do
|
||||
useItemHotkey :: Int -> Int -> World -> World
|
||||
useItemHotkey crid invid w = fromMaybe w $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix crid
|
||||
itm <- cr ^? crInv . ix invid
|
||||
luse <- itm ^? itUse . leftUse
|
||||
|
||||
Reference in New Issue
Block a user