Partially working change to selected items
This commit is contained in:
@@ -51,10 +51,14 @@ wasdWithAiming w speed cr
|
||||
cr'
|
||||
& crDir +~ _crTwist cr'
|
||||
& crTwist .~ 0
|
||||
addAnyTwist = case (cr ^? crInv . ix (crSel cr) . itUse . heldAim . aimStance, cr^. crTwist) of
|
||||
(Just TwoHandTwist, 0) -> (crTwist .~ twistamount * pi)
|
||||
addAnyTwist = fromMaybe id $ do
|
||||
itRef <- cr ^? crInvSel . isel . ispItem
|
||||
astance <- cr ^? crInv . ix itRef . itUse . heldAim . aimStance
|
||||
let currenttwistamount = cr ^. crTwist
|
||||
case (astance,currenttwistamount) of
|
||||
( TwoHandTwist, 0) -> return $ (crTwist .~ twistamount * pi)
|
||||
. (crDir -~ twistamount * pi)
|
||||
_ -> id
|
||||
_ -> Nothing
|
||||
theMovement
|
||||
| movDir == V2 0 0 = id
|
||||
| otherwise = crMvAbsolute (speed *.* movAbs)
|
||||
@@ -66,14 +70,19 @@ wasdWithAiming w speed cr
|
||||
dir = fmap ((w ^. cWorld . camPos . camRot) +) (safeArgV movDir)
|
||||
movAbs = rotateV (w ^. cWorld . camPos . camRot) $ normalizeV movDir
|
||||
isAiming = _posture (_crStance cr) == Aiming
|
||||
mouseDir = case cr ^? crInv . ix (crSel cr) . itScope . scopePos of
|
||||
Just _ -> argV $ mouseWorldPos (w ^. input) (w ^. cWorld . camPos) -.- _crPos cr
|
||||
_ -> argV (_mousePos (_input w)) + (w ^. cWorld . camPos . camRot)
|
||||
mouseDir = fromMaybe
|
||||
(argV (_mousePos (_input w)) + (w ^. cWorld . camPos . camRot) )
|
||||
$ do
|
||||
itRef <- cr ^? crInvSel . isel . ispItem
|
||||
_ <- cr ^? crInv . ix itRef . itScope . scopePos
|
||||
return . argV $ mouseWorldPos (w ^. input) (w ^. cWorld . camPos) -.- _crPos cr
|
||||
|
||||
aimTurn :: Float -> Creature -> Creature
|
||||
aimTurn a cr = creatureTurnTowardDir a (x * 0.2) cr
|
||||
where
|
||||
x = fromMaybe 1 $ cr ^? crInv . ix (crSel cr) . itUse . heldAim . aimTurnSpeed
|
||||
x = fromMaybe 1 $ do
|
||||
itRef <- cr ^? crInvSel . isel . ispItem
|
||||
cr ^? crInv . ix itRef . itUse . heldAim . aimTurnSpeed
|
||||
|
||||
wasdM :: SDL.Scancode -> Point2
|
||||
wasdM scancode = case scancode of
|
||||
@@ -89,8 +98,11 @@ wasdDir = foldl' (flip $ (+.+) . wasdM) (V2 0 0) . M.keys . _pressedKeys . _inpu
|
||||
-- | Set posture according to mouse presses.
|
||||
mouseActionsCr :: M.Map SDL.MouseButton Bool -> Creature -> Creature
|
||||
mouseActionsCr pkeys cr
|
||||
| rbPressed && cr ^?! crInvSel . iselAction == NoInvSelAction =
|
||||
| rbPressed && noaction =
|
||||
cr & crStance . posture .~ Aiming
|
||||
| otherwise = cr & crStance . posture .~ AtEase
|
||||
where
|
||||
rbPressed = SDL.ButtonRight `M.member` pkeys
|
||||
noaction = fromMaybe True $ do
|
||||
theaction <- cr ^? crInvSel . isel . iselAction
|
||||
return $ theaction == NoInvSelAction
|
||||
|
||||
Reference in New Issue
Block a user