Remove left click/hotkey item data types
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
module Dodge.Creature.Impulse.UseItem (
|
||||
useRootItem,
|
||||
useItemLeftClick,
|
||||
useItemHotkey,
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import Data.Maybe
|
||||
import Dodge.Cuse
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.Data.DoubleTree
|
||||
import Dodge.Data.World
|
||||
@@ -17,8 +14,6 @@ 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
|
||||
@@ -97,41 +92,3 @@ toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
||||
itRef = cr ^?! crManipulation . manObject . imSelectedItem -- unsafe!! TODO change?
|
||||
onequip itm' = doItmCrWdWd ((_eeOnEquip . _uequipEffect . _itUse) itm') itm'
|
||||
onremove itm' = doItmCrWdWd ((_eeOnRemove . _uequipEffect . _itUse) itm') itm'
|
||||
|
||||
-- need to make sure that the root item is not erroneously selected in the
|
||||
-- following
|
||||
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 eff -> return $ useC eff itm cr w
|
||||
UseEquip{} -> return $ doequipmentchange invid
|
||||
UseHotkey{} -> return $ doequipmentchange invid
|
||||
UseNothing{} -> return w
|
||||
UseAttach{} -> do
|
||||
return $ selectUse itm cr w
|
||||
_ -> Nothing
|
||||
where
|
||||
doequipmentchange invid = fromMaybe w $ do
|
||||
guard (_crHammerPosition cr == HammerUp)
|
||||
return $ toggleEquipmentAt invid cr w
|
||||
|
||||
-- & f
|
||||
-- where
|
||||
-- f = cWorld . lWorld . creatures . ix (_crID cr') . crHammerPosition .~ HammerDown
|
||||
|
||||
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
|
||||
return $
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix crid . crInv . ix invid . itUse . leftHammer .~ HammerDown
|
||||
& useL luse itm cr
|
||||
|
||||
-- TODO determine itmShouldBeUsed with reference to config options
|
||||
|
||||
@@ -417,22 +417,23 @@ setRBCreatureTargeting cr w ituse
|
||||
Just $ hasLOS cpos (_crPos cr) w
|
||||
|
||||
itemUpdate :: Item -> Item
|
||||
itemUpdate = updateAutoRecharge . (itUse %~ useUpdate)
|
||||
--itemUpdate = updateAutoRecharge . (itUse %~ useUpdate)
|
||||
itemUpdate = itUse %~ useUpdate
|
||||
|
||||
useUpdate :: ItemUse -> ItemUse
|
||||
useUpdate =
|
||||
(heldHammer %~ moveHammerUp)
|
||||
. (leftHammer %~ moveHammerUp)
|
||||
. (leftDelay . rateTime %~ decreaseToZero)
|
||||
-- . (leftHammer %~ moveHammerUp)
|
||||
-- . (leftDelay . rateTime %~ decreaseToZero)
|
||||
. (heldDelay . warmTime %~ decreaseToZero)
|
||||
. (heldDelay . rateTime %~ decreaseToZero)
|
||||
|
||||
updateAutoRecharge :: Item -> Item
|
||||
updateAutoRecharge it = case it ^? itUse . leftConsumption of
|
||||
Just (AutoRecharging l m t p)
|
||||
| l < m && p <= 0 -> it & itUse . leftConsumption .~ AutoRecharging (l + 1) m t t
|
||||
| l < m -> it & itUse . leftConsumption . arProgress -~ 1
|
||||
_ -> it
|
||||
--updateAutoRecharge :: Item -> Item
|
||||
--updateAutoRecharge it = case it ^? itUse . leftConsumption of
|
||||
-- Just (AutoRecharging l m t p)
|
||||
-- | l < m && p <= 0 -> it & itUse . leftConsumption .~ AutoRecharging (l + 1) m t t
|
||||
-- | l < m -> it & itUse . leftConsumption . arProgress -~ 1
|
||||
-- _ -> it
|
||||
|
||||
updateMovement :: Creature -> Creature
|
||||
updateMovement cr
|
||||
|
||||
@@ -2,6 +2,10 @@ module Dodge.Creature.YourControl (
|
||||
yourControl,
|
||||
) where
|
||||
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.HeldUse
|
||||
import Dodge.Data.DoubleTree
|
||||
import Dodge.Item.Grammar
|
||||
import Control.Monad
|
||||
import Data.Foldable
|
||||
import qualified Data.Map.Strict as M
|
||||
@@ -39,14 +43,19 @@ yourControl _ w
|
||||
|
||||
handleHotkeys :: World -> World
|
||||
handleHotkeys w
|
||||
| SDL.ButtonRight `M.member` _mouseButtons (_input w) = foldl' tryAssignHotkey w allHotkeys
|
||||
-- | SDL.ButtonRight `M.member` _mouseButtons (_input w)
|
||||
| SDL.ScancodeLShift `M.member` _pressedKeys (_input w)
|
||||
|| SDL.ScancodeRShift `M.member` _pressedKeys (_input w)
|
||||
= foldl' tryAssignHotkey w allHotkeys
|
||||
| otherwise = foldl' useHotKey w (M.intersection thehotkeys (w ^. input . pressedKeys))
|
||||
where
|
||||
--thehotkeys = M.mapKeys hotkeyToScancode $ w ^?! cWorld . lWorld . creatures . ix 0 . crHotkeys
|
||||
thehotkeys = M.mapKeys hotkeyToScancode $ w ^. cWorld . lWorld . hotkeys
|
||||
|
||||
useHotKey :: World -> Int -> World
|
||||
useHotKey w invid = useItemHotkey 0 invid w
|
||||
useHotKey w invid = fromMaybe w $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
itmloc <- allInvLocs (cr ^. crInv) ^? ix invid . _2 . locLDT
|
||||
return $ heldEffectNoHammerCheck (bimap (^. iatType) (^. _1) itmloc) cr w
|
||||
|
||||
allHotkeys :: [SDL.Scancode]
|
||||
allHotkeys = map hotkeyToScancode [minBound .. maxBound]
|
||||
|
||||
Reference in New Issue
Block a user