Separate out concrete part of world
This commit is contained in:
@@ -18,12 +18,12 @@ yourControl :: Creature -> World -> World
|
||||
yourControl cr w
|
||||
| inTermFocus w = dimCreatureLight cr w & updateUsingInput
|
||||
| otherwise = dimCreatureLight cr w
|
||||
& creatures . ix (_crID cr) %~
|
||||
(wasdWithAiming w (_mvSpeed $ _crMvType cr) . mouseActionsCr (_mouseButtons w))
|
||||
& cWorld . creatures . ix (_crID cr) %~
|
||||
(wasdWithAiming w (_mvSpeed $ _crMvType cr) . mouseActionsCr (_mouseButtons (_cWorld w)))
|
||||
& updateUsingInput
|
||||
|
||||
dimCreatureLight :: Creature -> World -> World
|
||||
dimCreatureLight cr = tempLightSources .:~ tlsTimeRadColPos 1 300 0.1 (addZ 100 $ _crPos cr)
|
||||
dimCreatureLight cr = cWorld . tempLightSources .:~ tlsTimeRadColPos 1 300 0.1 (addZ 100 $ _crPos cr)
|
||||
|
||||
-- note the order of operation, setting the posture first--this prevents the twist fire bug
|
||||
|
||||
@@ -35,7 +35,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 (_cWorld w)
|
||||
= addAnyTwist $ set crDir (mouseDir + anytwist) $ theMovement cr
|
||||
| otherwise = theMovement $ theTurn $ removeTwist cr
|
||||
where
|
||||
@@ -52,12 +52,12 @@ wasdWithAiming w speed cr
|
||||
| otherwise = crMvAbsolute (speed *.* movAbs) . set crMvDir dir
|
||||
theTurn cr' = creatureTurnTowardDir (_crMvDir cr') 0.2 cr'
|
||||
movDir = wasdDir w
|
||||
dir = _cameraRot w + argV movDir
|
||||
movAbs = rotateV (_cameraRot w) $ normalizeV movDir
|
||||
dir = _cameraRot (_cWorld w) + argV movDir
|
||||
movAbs = rotateV (_cameraRot (_cWorld w)) $ normalizeV movDir
|
||||
isAiming = _posture (_crStance cr) == Aiming
|
||||
mouseDir = case cr ^? crInv . ix (crSel cr) . itScope . scopePos of
|
||||
Just _ -> argV $ mouseWorldPos w -.- _crPos cr
|
||||
_ -> argV (_mousePos w) + _cameraRot w
|
||||
_ -> argV (_mousePos (_cWorld w)) + _cameraRot (_cWorld w)
|
||||
|
||||
wasdM :: SDL.Scancode -> Point2
|
||||
wasdM scancode = case scancode of
|
||||
@@ -68,7 +68,7 @@ wasdM scancode = case scancode of
|
||||
_ -> V2 0 0
|
||||
|
||||
wasdDir :: World -> Point2
|
||||
wasdDir = foldr ((+.+) . wasdM) (V2 0 0) . _keys
|
||||
wasdDir = foldr ((+.+) . wasdM) (V2 0 0) . _keys . _cWorld
|
||||
|
||||
{- | Set posture according to mouse presses. -}
|
||||
mouseActionsCr :: M.Map SDL.MouseButton Bool -> Creature -> Creature
|
||||
|
||||
Reference in New Issue
Block a user