Fix equipment equipping/moving with right click
This commit is contained in:
@@ -5,63 +5,67 @@ module Dodge.Creature.Impulse.UseItem (
|
||||
useItemHotkey,
|
||||
) where
|
||||
|
||||
import Dodge.Luse
|
||||
import Dodge.SelectUse
|
||||
import Dodge.Item.Grammar
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.Data.DoubleTree
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import Data.Maybe
|
||||
import Dodge.Cuse
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.Data.DoubleTree
|
||||
import Dodge.Data.World
|
||||
import Dodge.Euse
|
||||
import Dodge.HeldUse
|
||||
import Dodge.Hotkey
|
||||
import Dodge.Inventory
|
||||
import Dodge.Item.Grammar
|
||||
import Dodge.Item.Location
|
||||
import Dodge.Luse
|
||||
import Dodge.SelectUse
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
useRootItem :: Int -> World -> World
|
||||
useRootItem crid w = fromMaybe w $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix crid
|
||||
itRef <- cr ^? crManipulation . manObject . imRootItem
|
||||
it <- invRootTrees (_crInv cr) ^? ix itRef
|
||||
return $
|
||||
itemUseEffect' cr it w
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix crid
|
||||
itRef <- cr ^? crManipulation . manObject . imRootItem
|
||||
it <- invRootTrees (_crInv cr) ^? ix itRef
|
||||
return $
|
||||
itemUseEffect' cr it w
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
|
||||
itemUseEffect' :: Creature -> LabelDoubleTree ItemLink ComposedItem -> World -> World
|
||||
itemUseEffect' cr itmtree w = case itmtree ^. ldtValue . cItemFunction of
|
||||
WeaponPlatformSF -> heldEffect (bimap _iatType _cItem itmtree) cr w
|
||||
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
|
||||
-- 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
|
||||
-- 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
|
||||
|
||||
doequipmentchange = fromMaybe w $ do
|
||||
guard (_crHammerPosition cr == HammerUp)
|
||||
invid <- itm ^? itLocation . ilInvID
|
||||
return $ toggleEquipmentAt invid cr w
|
||||
|
||||
itemUseEffect :: Creature -> LabelDoubleTree ComposeLinkType Item -> World -> World
|
||||
itemUseEffect cr itmtree w = case itmtree ^. ldtValue . itUse of
|
||||
UseHeld{} -> heldEffect itmtree cr w
|
||||
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
|
||||
UseAttach{} -> selectUse itmtree cr w
|
||||
UseAmmoMag{} -> w
|
||||
UseScope{} -> w
|
||||
UseBulletMod{} -> w
|
||||
@@ -138,6 +142,7 @@ useItemLeftClick' cr' w = fromMaybe w $ do
|
||||
return $
|
||||
itemUseEffect cr it w
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
|
||||
-- & f
|
||||
-- where
|
||||
-- f = cWorld . lWorld . creatures . ix (_crID cr') . crHammerPosition .~ HammerDown
|
||||
|
||||
Reference in New Issue
Block a user