Separate out input datatype
This commit is contained in:
@@ -22,7 +22,7 @@ yourControl cr w
|
||||
| otherwise =
|
||||
dimCreatureLight cr w
|
||||
& cWorld . lWorld . creatures . ix (_crID cr)
|
||||
%~ (wasdWithAiming w (_mvSpeed $ _crMvType cr) . mouseActionsCr (_mouseButtons w))
|
||||
%~ (wasdWithAiming w (_mvSpeed $ _crMvType cr) . mouseActionsCr (_mouseButtons (_input w)))
|
||||
& updateUsingInput
|
||||
|
||||
dimCreatureLight :: Creature -> World -> World
|
||||
@@ -39,7 +39,7 @@ wasdWithAiming ::
|
||||
Creature
|
||||
wasdWithAiming w speed cr
|
||||
| isAiming = addAnyTwist $ set crDir mouseDir $ theMovement cr
|
||||
| crIsReloading cr && SDL.ButtonRight `M.member` _mouseButtons w =
|
||||
| crIsReloading cr && SDL.ButtonRight `M.member` _mouseButtons (_input w) =
|
||||
addAnyTwist $ set crDir (mouseDir + anytwist) $ theMovement cr
|
||||
| otherwise = theMovement $ theTurn $ removeTwist cr
|
||||
where
|
||||
@@ -62,7 +62,7 @@ wasdWithAiming w speed cr
|
||||
isAiming = _posture (_crStance cr) == Aiming
|
||||
mouseDir = case cr ^? crInv . ix (crSel cr) . itScope . scopePos of
|
||||
Just _ -> argV $ mouseWorldPos w -.- _crPos cr
|
||||
_ -> argV (_mousePos w) + (w ^. cWorld . lWorld . camPos . camRot)
|
||||
_ -> argV (_mousePos (_input w)) + (w ^. cWorld . lWorld . camPos . camRot)
|
||||
|
||||
wasdM :: SDL.Scancode -> Point2
|
||||
wasdM scancode = case scancode of
|
||||
@@ -73,7 +73,7 @@ wasdM scancode = case scancode of
|
||||
_ -> V2 0 0
|
||||
|
||||
wasdDir :: World -> Point2
|
||||
wasdDir = foldl' (flip $ (+.+) . wasdM) (V2 0 0) . _keys
|
||||
wasdDir = foldl' (flip $ (+.+) . wasdM) (V2 0 0) . _keys . _input
|
||||
|
||||
-- | Set posture according to mouse presses.
|
||||
mouseActionsCr :: M.Map SDL.MouseButton Bool -> Creature -> Creature
|
||||
|
||||
Reference in New Issue
Block a user