Remove _crTwist
This commit is contained in:
@@ -33,13 +33,15 @@ useItemLoc ::
|
||||
useItemLoc cr loc pt w
|
||||
| HeldPlatformSF <- sf
|
||||
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsRoot
|
||||
, cr ^. crStance . posture == Aiming =
|
||||
-- , cr ^. crStance . posture == Aiming =
|
||||
, Aiming {} <- cr ^. crStance . posture =
|
||||
return $ heldEffect pt (bimap _iatType (^. _1) ldt) cr w
|
||||
| GadgetPlatformSF <- sf =
|
||||
return $ gadgetEffect pt loc cr w
|
||||
| UnderBarrelPlatformSF <- sf
|
||||
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached
|
||||
, cr ^. crStance . posture == Aiming =
|
||||
-- , cr ^. crStance . posture == Aiming =
|
||||
, Aiming {} <- cr ^. crStance . posture =
|
||||
return $ heldEffect pt (bimap _iatType (^. _1) ldt) cr w
|
||||
| RemoteDetonatorSF <- sf
|
||||
, pt == InitialPress =
|
||||
|
||||
@@ -29,7 +29,8 @@ crCurrentEquipment = IM.filter (isJust . (^? itLocation . ilEquipSite . _Just))
|
||||
strFromHeldItem :: Creature -> Int
|
||||
strFromHeldItem cr
|
||||
--x--- | _posture (_crStance cr) == Aiming || crIsReloading cr = negate $ fromMaybe 0 $ do
|
||||
| _posture (_crStance cr) == Aiming = negate $ fromMaybe 0 $ do
|
||||
-- | _posture (_crStance cr) == Aiming = negate $ fromMaybe 0 $ do
|
||||
| Aiming {} <- _posture (_crStance cr) = negate $ fromMaybe 0 $ do
|
||||
i <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
cr ^? crInv . ix i . itUse . heldAim . aimWeight
|
||||
| otherwise = 0
|
||||
|
||||
@@ -54,7 +54,9 @@ crCanSeeCr tcr (w, cr) = hasLOS (_crPos cr) (_crPos tcr) w
|
||||
-- return $ hasLOS (_crPos cr) (_crPos tcr) w
|
||||
|
||||
crIsAiming :: Creature -> Bool
|
||||
crIsAiming cr = _posture (_crStance cr) == Aiming
|
||||
crIsAiming cr = case _posture (_crStance cr) of
|
||||
Aiming {} -> True
|
||||
_ -> False
|
||||
|
||||
crHasTarget :: Creature -> Bool
|
||||
crHasTarget cr = isJust $ cr ^? crIntention . targetCr . _Just
|
||||
|
||||
@@ -13,7 +13,7 @@ import Geometry
|
||||
|
||||
holsterWeapon, drawWeapon :: Action
|
||||
holsterWeapon = DoImpulses [ChangePosture AtEase, MakeSound whiteNoiseFadeOutS]
|
||||
drawWeapon = DoImpulses [ChangePosture Aiming, MakeSound whiteNoiseFadeInS]
|
||||
drawWeapon = DoImpulses [ChangePosture (Aiming 0), MakeSound whiteNoiseFadeInS]
|
||||
|
||||
shootTillEmpty :: Action
|
||||
--shootTillEmpty = (crCanShoot `DoActionWhile` DoImpulses [UseItem])
|
||||
|
||||
@@ -28,7 +28,8 @@ yourControl _ w
|
||||
, f x =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix 0
|
||||
%~ (wasdWithAiming w . setCrPosture pkeys)
|
||||
-- %~ (wasdWithAiming w . setCrPosture pkeys)
|
||||
%~ wasdWithAiming w
|
||||
& tryClickUse pkeys
|
||||
& handleHotkeys
|
||||
| otherwise =
|
||||
@@ -115,7 +116,8 @@ wasdWithAiming ::
|
||||
World ->
|
||||
Creature ->
|
||||
Creature
|
||||
wasdWithAiming w cr = wasdAim inp cam . wasdTwist $ wasdMovement inp cam speed cr
|
||||
--wasdWithAiming w cr = wasdAim inp cam . wasdTwist $ wasdMovement inp cam speed cr
|
||||
wasdWithAiming w cr = wasdAim inp cam $ wasdMovement inp cam speed cr
|
||||
where
|
||||
speed = _mvSpeed $ _crMvType cr
|
||||
inp = w ^. input
|
||||
@@ -123,29 +125,59 @@ wasdWithAiming w cr = wasdAim inp cam . wasdTwist $ wasdMovement inp cam speed c
|
||||
|
||||
wasdAim :: Input -> Camera -> Creature -> Creature
|
||||
wasdAim inp cam cr
|
||||
| Just 0 <- inp ^? mouseButtons . ix SDL.ButtonRight
|
||||
= setAimPosture cr
|
||||
| Just 0 <- inp ^? mouseButtonsReleased . ix SDL.ButtonRight
|
||||
= removeAimPosture cr
|
||||
| SDL.ButtonRight `M.member` _mouseButtons inp = aimTurn mouseDir cr
|
||||
| otherwise = creatureTurnTowardDir (_crMvAim cr) 0.2 cr
|
||||
where
|
||||
mouseDir = argV $ mouseWorldPos inp cam - (cr ^. crPos)
|
||||
|
||||
-- aim with the root item
|
||||
wasdTwist :: Creature -> Creature
|
||||
wasdTwist cr
|
||||
| _posture (_crStance cr) == Aiming = fromMaybe cr $ do
|
||||
itRef <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
astance <- cr ^? crInv . ix itRef . itUse . heldAim . aimStance
|
||||
case (astance, cr ^. crTwist) of
|
||||
(TwoHandUnder, 0) ->
|
||||
return $ cr & crTwist .~ twistamount * pi & crDir -~ twistamount * pi
|
||||
(TwoHandOver, 0) ->
|
||||
return $ cr & crTwist .~ twistamount * pi & crDir -~ twistamount * pi
|
||||
_ -> Nothing
|
||||
| otherwise =
|
||||
cr
|
||||
& crDir +~ _crTwist cr
|
||||
& crTwist .~ 0 --remove twistk
|
||||
---- aim with the root item
|
||||
---- when initiating aim with a two handed weapon, change the creature direction
|
||||
---- to be closer to where the two handed weapon was pointing
|
||||
--wasdTwist :: Creature -> Creature
|
||||
--wasdTwist cr
|
||||
---- | _posture (_crStance cr) == Aiming
|
||||
-- | Aiming {} <- cr ^. crStance . posture = fromMaybe cr $ do
|
||||
-- itRef <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
-- astance <- cr ^? crInv . ix itRef . itUse . heldAim . aimStance
|
||||
-- case (astance, cr ^. crTwist) of
|
||||
-- (TwoHandUnder, 0) ->
|
||||
-- return $ cr & crTwist .~ twistamount * pi & crDir -~ twistamount * pi
|
||||
-- (TwoHandOver, 0) ->
|
||||
-- return $ cr & crTwist .~ twistamount * pi & crDir -~ twistamount * pi
|
||||
-- _ -> Nothing
|
||||
-- | otherwise =
|
||||
-- cr
|
||||
-- & crDir +~ _crTwist cr
|
||||
-- & crTwist .~ 0 --remove twistk
|
||||
-- where
|
||||
-- twistamount = 1.6
|
||||
|
||||
setAimPosture :: Creature -> Creature
|
||||
setAimPosture cr = fromMaybe cr $ do
|
||||
itRef <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
astance <- cr ^? crInv . ix itRef . itUse . heldAim . aimStance
|
||||
case astance of
|
||||
TwoHandUnder ->
|
||||
return $ cr & crStance . posture .~ Aiming (twistamount * pi)
|
||||
& crDir -~ (twistamount * pi)
|
||||
TwoHandOver ->
|
||||
return $ cr & crStance . posture .~ Aiming (twistamount * pi)
|
||||
& crDir -~ (twistamount * pi)
|
||||
_ -> return $ cr & crStance . posture .~ Aiming 0
|
||||
where
|
||||
twistamount :: Float
|
||||
twistamount = 1.6
|
||||
|
||||
removeAimPosture :: Creature -> Creature
|
||||
removeAimPosture cr = fromMaybe cr $ do
|
||||
x <- cr ^? crStance . posture . aimTwist
|
||||
return $ cr
|
||||
& crDir +~ x
|
||||
& crStance . posture .~ AtEase
|
||||
|
||||
wasdMovement :: Input -> Camera -> Float -> Creature -> Creature
|
||||
wasdMovement inp cam speed = theMovement . setMvAim
|
||||
@@ -171,7 +203,7 @@ aimTurn a cr = creatureTurnTowardDir a (x * 0.2) cr
|
||||
-}
|
||||
setCrPosture :: M.Map SDL.MouseButton Int -> Creature -> Creature
|
||||
setCrPosture pkeys
|
||||
| SDL.ButtonRight `M.member` pkeys = crStance . posture .~ Aiming
|
||||
| SDL.ButtonRight `M.member` pkeys = crStance . posture .~ Aiming 0
|
||||
| otherwise = crStance . posture .~ AtEase
|
||||
|
||||
tryClickUse :: M.Map SDL.MouseButton Int -> World -> World
|
||||
|
||||
Reference in New Issue
Block a user