Remove _crTwist
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -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
|
||||
|
||||
@@ -38,7 +38,7 @@ data Creature = Creature
|
||||
, _crOldDir :: Float
|
||||
, _crMvDir :: Float
|
||||
, _crMvAim :: Float
|
||||
, _crTwist :: Float
|
||||
-- , _crTwist :: Float
|
||||
, _crType :: CreatureType
|
||||
, _crID :: Int
|
||||
, _crRad :: Float
|
||||
|
||||
@@ -36,7 +36,7 @@ data FootForward
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
data Posture
|
||||
= Aiming
|
||||
= Aiming {_aimTwist :: Float}
|
||||
| AtEase
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ defaultCreature =
|
||||
, _crOldDir = 0
|
||||
, _crMvDir = 0
|
||||
, _crMvAim = 0
|
||||
, _crTwist = 0
|
||||
-- , _crTwist = 0
|
||||
, _crID = 1
|
||||
, _crType = defaultCreatureSkin
|
||||
, _crRad = 10
|
||||
|
||||
@@ -30,7 +30,7 @@ heldItemOrient2D itm cr p a = (V2 x y, argV . Q.qToV2 $ q )
|
||||
|
||||
heldItemRelativeOrient :: Item -> Creature -> (Point3, Q.Quaternion Float) -> (Point3, Q.Quaternion Float)
|
||||
heldItemRelativeOrient itm cr (p,q)
|
||||
| _posture (_crStance cr) == Aiming =
|
||||
| Aiming {} <- _posture (_crStance cr) =
|
||||
(p + aimingWeaponZeroPos cr itm `v2z` shoulderHeight, Q.qID * q)
|
||||
| isTwoHandFlat =
|
||||
( V3 (_crRad cr) 0 handD
|
||||
|
||||
@@ -57,7 +57,7 @@ fpsText x = color col . text $ "ms/frame " ++ show x
|
||||
drawMenuOrHUD :: Configuration -> Universe -> Picture
|
||||
drawMenuOrHUD cfig u = case u ^. uvScreenLayers of
|
||||
[] -> drawHUD (u ^. uvConfig) (u ^. uvWorld)
|
||||
(lay : _) -> drawMenuScreen cfig (u ^? uvWorld . input . mouseContext . mcoMenuClick) lay
|
||||
(x : _) -> drawMenuScreen cfig (u ^? uvWorld . input . mouseContext . mcoMenuClick) x
|
||||
|
||||
drawConcurrentMessage :: Universe -> Picture
|
||||
drawConcurrentMessage u =
|
||||
@@ -239,12 +239,13 @@ drawGapPlus x =
|
||||
aimDelaySweep :: World -> Picture
|
||||
aimDelaySweep w = fold $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
aimstatus <- cr ^? crStance . posture
|
||||
guard (aimstatus == Aiming)
|
||||
return $ drawSweep cr w
|
||||
-- aimstatus <- cr ^? crStance . posture
|
||||
-- guard (aimstatus == Aiming)
|
||||
Aiming {} <- cr ^? crStance . posture
|
||||
return $ drawAimSweep cr w
|
||||
|
||||
drawSweep :: Creature -> World -> Picture
|
||||
drawSweep cr w = fromMaybe mempty $ do
|
||||
drawAimSweep :: Creature -> World -> Picture
|
||||
drawAimSweep cr w = fold $ do
|
||||
a <- safeArgV (mwp -.- p)
|
||||
let a'
|
||||
| a - cdir > pi = cdir + 2 * pi
|
||||
|
||||
@@ -87,7 +87,6 @@ extraPics cfig u =
|
||||
<> foldMap drawTractorBeam (_tractorBeams lw)
|
||||
<> foldMap drawLinearShockwave (_linearShockwaves lw)
|
||||
<> foldMap drawShockwave (_shockwaves lw)
|
||||
-- <> foldMap drawLaser (_lasersToDraw lw)
|
||||
<> foldMap drawTeslaArc (_teslaArcs lw)
|
||||
<> foldMap drawRadarSweep (_radarSweeps lw)
|
||||
<> foldMap drawFlame (_flames lw)
|
||||
|
||||
@@ -26,8 +26,9 @@ import qualified IntMapHelp as IM
|
||||
import qualified Data.Map.Strict as M
|
||||
|
||||
testStringInit :: Universe -> [String]
|
||||
testStringInit u = prettyShort
|
||||
$ u ^.. uvWorld . cWorld . lWorld . teslaArcs . ix 0 . taArcSteps . each . asObject
|
||||
testStringInit u = []
|
||||
-- foldMap prettyShort $ u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crTwist
|
||||
-- prettyShort $ u ^.. uvWorld . cWorld . lWorld . teslaArcs . ix 0 . taArcSteps . each . asObject
|
||||
--testStringInit u = foldMap prettyShort $ u ^. uvWorld . cWorld . lWorld . projectiles
|
||||
-- (map (show . _ebPos) $ u ^. uvWorld . cWorld . lWorld . energyBalls)
|
||||
-- <>
|
||||
|
||||
Reference in New Issue
Block a user