Commit before changing ItemUse into single product type
This commit is contained in:
@@ -47,7 +47,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 -> (useRootItem $ _crID cr, cr)
|
||||
UseItem -> (useSelectedItem $ _crID cr, cr)
|
||||
SwitchToItem i -> crup $ cr & crManipulation . manObject .~ SelectedItem i i mempty
|
||||
Melee cid' ->
|
||||
( hitCr cid'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module Dodge.Creature.Impulse.UseItem (
|
||||
useRootItem,
|
||||
useSelectedItem,
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
@@ -16,11 +16,13 @@ import Dodge.Item.Grammar
|
||||
import Dodge.Item.Location
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
useRootItem :: Int -> World -> World
|
||||
useRootItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMaybe w $ do
|
||||
useSelectedItem :: Int -> World -> World
|
||||
useSelectedItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMaybe w $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix crid
|
||||
itRef <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
invid <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
itmtree <- invRootTrees (_crInv cr) ^? ix itRef
|
||||
itmloc <- allInvLocs (_crInv cr) ^? ix invid
|
||||
let itm = itmtree ^. ldtValue . _1
|
||||
case itmtree ^. ldtValue . _2 of
|
||||
HeldPlatformSF ->
|
||||
|
||||
@@ -173,18 +173,21 @@ mouseActionsCr pkeys
|
||||
|
||||
pressedMBEffectsTopInventory :: M.Map SDL.MouseButton Int -> World -> World
|
||||
pressedMBEffectsTopInventory pkeys w
|
||||
| isDown SDL.ButtonLeft && isDown SDL.ButtonRight && inTopInv = youhammerdown $ useRootItem 0 w
|
||||
-- | isDown SDL.ButtonLeft && inTopInv = youhammerdown $ useItemLeftClick (you w) w
|
||||
| isDown SDL.ButtonMiddle = w & wCam . camRot -~ rotation
|
||||
| Just ltime <- pkeys ^? ix SDL.ButtonLeft
|
||||
, Just rtime <- pkeys ^? ix SDL.ButtonRight
|
||||
, ltime <= rtime && inTopInv
|
||||
= youhammerdown $ useSelectedItem 0 w
|
||||
| Just _ <- pkeys ^? ix SDL.ButtonLeft
|
||||
, Just _ <- pkeys ^? ix SDL.ButtonRight
|
||||
= w & wCam . camRot -~ rotation
|
||||
| otherwise = w
|
||||
where
|
||||
youhammerdown = set (cWorld . lWorld . creatures . ix 0 . crHammerPosition) HammerDown
|
||||
inTopInv = case w ^. hud . hudElement of
|
||||
DisplayInventory{_subInventory = NoSubInventory{}} -> True
|
||||
_ -> False
|
||||
isDown but = but `M.member` pkeys
|
||||
rotation =
|
||||
maybe
|
||||
0
|
||||
(angleBetween $ w ^. input . mousePos)
|
||||
(w ^. input . heldPos . at SDL.ButtonMiddle)
|
||||
(w ^. input . heldPos . at SDL.ButtonRight)
|
||||
|
||||
Reference in New Issue
Block a user