Stop equip after combining
This commit is contained in:
@@ -46,7 +46,7 @@ followImpulse cr w imp = case imp of
|
||||
TurnToward p a -> crup $ creatureTurnToward p a cr
|
||||
TurnTo p -> crup $ creatureTurnTo p cr
|
||||
ChangePosture post -> crup $ cr & crStance . posture .~ post
|
||||
UseItem -> (useItem cr, cr)
|
||||
UseItem -> (useItemRightClick cr, cr)
|
||||
SwitchToItem i -> crup $ cr & crManipulation . manObject .~ InInventory (SelItem i NoInvSelAction)
|
||||
Melee cid' ->
|
||||
( hitCr cid'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -48,7 +48,7 @@ handleHotkeys w
|
||||
hotkeys = M.mapKeys hotkeyToScancode $ w ^?! cWorld . lWorld . creatures . ix 0 . crHotkeys
|
||||
|
||||
useHotKey :: World -> Int -> World
|
||||
useHotKey w invid = tryUseL 0 invid w
|
||||
useHotKey w invid = useItemHotkey 0 invid w
|
||||
|
||||
allHotkeys :: [SDL.Scancode]
|
||||
allHotkeys = map hotkeyToScancode [minBound .. maxBound]
|
||||
@@ -161,8 +161,8 @@ mouseActionsCr pkeys cr
|
||||
|
||||
pressedMBEffectsTopInventory :: M.Map SDL.MouseButton Int -> World -> World
|
||||
pressedMBEffectsTopInventory pkeys w
|
||||
| isDown SDL.ButtonLeft && isDown SDL.ButtonRight && inTopInv = useItem (you w) w
|
||||
| isDown SDL.ButtonLeft && inTopInv = doTopInvLeftClick (you w) w
|
||||
| isDown SDL.ButtonLeft && isDown SDL.ButtonRight && inTopInv = useItemRightClick (you w) w
|
||||
| isDown SDL.ButtonLeft && inTopInv = useItemLeftClick (you w) w
|
||||
| isDown SDL.ButtonMiddle =
|
||||
w & wCam . camRot -~ rotation
|
||||
| otherwise = w
|
||||
|
||||
Reference in New Issue
Block a user