Empty Update/UsingInput
This commit is contained in:
@@ -2,6 +2,8 @@ module Dodge.Creature.YourControl (
|
||||
yourControl,
|
||||
) where
|
||||
|
||||
import Dodge.Base.You
|
||||
import Dodge.Creature.Impulse.UseItem
|
||||
import Data.Foldable
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
@@ -26,8 +28,9 @@ yourControl cr w
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix (_crID cr)
|
||||
%~ (wasdWithAiming w (_mvSpeed $ _crMvType cr) . mouseActionsCr (_mouseButtons (_input w)))
|
||||
& updateUsingInput
|
||||
& pressedMBEffectsNoInventory pkeys
|
||||
where
|
||||
pkeys = w ^. input . mouseButtons
|
||||
intopinv = fromMaybe False $ do
|
||||
subinv <- w ^? hud . hudElement . subInventory
|
||||
Just $ case subinv of
|
||||
@@ -113,3 +116,18 @@ mouseActionsCr pkeys cr
|
||||
noaction = fromMaybe True $ do
|
||||
theaction <- cr ^? crManipulation . manObject . inInventory . iselAction
|
||||
return $ theaction == NoInvSelAction
|
||||
|
||||
pressedMBEffectsNoInventory :: M.Map SDL.MouseButton Bool -> World -> World
|
||||
pressedMBEffectsNoInventory pkeys w
|
||||
| isDown SDL.ButtonLeft && isDown SDL.ButtonRight && inTopInv = useItem (you w) w
|
||||
| isDown SDL.ButtonLeft && inTopInv = useLeftItem 0 w
|
||||
| isDown SDL.ButtonMiddle =
|
||||
w & cWorld . camPos . camRot -~ rotation
|
||||
& input . clickMousePos .~ _mousePos (_input w)
|
||||
| otherwise = w
|
||||
where
|
||||
inTopInv = case w ^. hud . hudElement of
|
||||
DisplayInventory {_subInventory = NoSubInventory} -> True
|
||||
_ -> False
|
||||
isDown but = but `M.member` pkeys
|
||||
rotation = angleBetween (_mousePos (_input w)) (_clickMousePos (_input w))
|
||||
|
||||
Reference in New Issue
Block a user