Distinguish between selected item and root-selected item
This commit is contained in:
@@ -88,7 +88,7 @@ tryAssignHotkey w sc = fromMaybe w $ do
|
||||
pt <- w ^? input . pressedKeys . ix sc
|
||||
guard (pt == InitialPress)
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
itid <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
itid <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
|
||||
return $ w & cWorld . lWorld . creatures . ix 0 %~ assignHotkey itid (scancodeToHotkey sc)
|
||||
|
||||
{- | Turn key presses into creature movement.
|
||||
@@ -152,6 +152,7 @@ wasdAim inp cam cr
|
||||
theTurn cr' = creatureTurnTowardDir (_crMvAim cr') 0.2 cr'
|
||||
mouseDir = argV $ mouseWorldPos inp cam - (cr ^. crPos)
|
||||
|
||||
-- aim with the root item
|
||||
wasdTwist :: Creature -> Creature
|
||||
wasdTwist cr
|
||||
| _posture (_crStance cr) == Aiming = addAnyTwist cr
|
||||
@@ -163,7 +164,7 @@ wasdTwist cr
|
||||
& crDir +~ _crTwist cr'
|
||||
& crTwist .~ 0
|
||||
addAnyTwist = fromMaybe id $ do
|
||||
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
itRef <- cr ^? crManipulation . manObject . inInventory . imRootItem
|
||||
astance <- cr ^? crInv . ix itRef . itUse . heldAim . aimStance
|
||||
case (astance, cr ^. crTwist) of
|
||||
(TwoHandUnder, 0) ->
|
||||
@@ -189,19 +190,18 @@ aimTurn :: Float -> Creature -> Creature
|
||||
aimTurn a cr = creatureTurnTowardDir a (x * 0.2) cr
|
||||
where
|
||||
x = fromMaybe 1 $ do
|
||||
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
itRef <- cr ^? crManipulation . manObject . inInventory . imRootItem
|
||||
cr ^? crInv . ix itRef . itUse . heldAim . aimTurnSpeed
|
||||
|
||||
-- | Set posture according to mouse presses.
|
||||
mouseActionsCr :: M.Map SDL.MouseButton Int -> Creature -> Creature
|
||||
mouseActionsCr pkeys cr
|
||||
| SDL.ButtonRight `M.member` pkeys && noaction =
|
||||
cr & crStance . posture .~ Aiming
|
||||
| SDL.ButtonRight `M.member` pkeys = cr & crStance . posture .~ Aiming
|
||||
| otherwise = cr & crStance . posture .~ AtEase
|
||||
where
|
||||
noaction = fromMaybe True $ do
|
||||
theaction <- cr ^? crManipulation . manObject . inInventory . iselAction
|
||||
return $ theaction == NoInvSelAction
|
||||
-- where
|
||||
-- noaction = fromMaybe True $ do
|
||||
-- theaction <- cr ^? crManipulation . manObject . inInventory . iselAction
|
||||
-- return $ theaction == NoInvSelAction
|
||||
|
||||
pressedMBEffectsTopInventory :: M.Map SDL.MouseButton Int -> World -> World
|
||||
pressedMBEffectsTopInventory pkeys w
|
||||
|
||||
Reference in New Issue
Block a user