Remove _crTwist

This commit is contained in:
2025-05-30 10:23:37 +01:00
parent 3efa01bf09
commit 0bcf263db7
14 changed files with 304 additions and 259 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+4 -2
View File
@@ -33,13 +33,15 @@ useItemLoc ::
useItemLoc cr loc pt w useItemLoc cr loc pt w
| HeldPlatformSF <- sf | HeldPlatformSF <- sf
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsRoot , 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 return $ heldEffect pt (bimap _iatType (^. _1) ldt) cr w
| GadgetPlatformSF <- sf = | GadgetPlatformSF <- sf =
return $ gadgetEffect pt loc cr w return $ gadgetEffect pt loc cr w
| UnderBarrelPlatformSF <- sf | UnderBarrelPlatformSF <- sf
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached , 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 return $ heldEffect pt (bimap _iatType (^. _1) ldt) cr w
| RemoteDetonatorSF <- sf | RemoteDetonatorSF <- sf
, pt == InitialPress = , pt == InitialPress =
+2 -1
View File
@@ -29,7 +29,8 @@ crCurrentEquipment = IM.filter (isJust . (^? itLocation . ilEquipSite . _Just))
strFromHeldItem :: Creature -> Int strFromHeldItem :: Creature -> Int
strFromHeldItem cr strFromHeldItem cr
--x--- | _posture (_crStance cr) == Aiming || crIsReloading cr = negate $ fromMaybe 0 $ do --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 i <- cr ^? crManipulation . manObject . imRootSelectedItem
cr ^? crInv . ix i . itUse . heldAim . aimWeight cr ^? crInv . ix i . itUse . heldAim . aimWeight
| otherwise = 0 | otherwise = 0
+3 -1
View File
@@ -54,7 +54,9 @@ crCanSeeCr tcr (w, cr) = hasLOS (_crPos cr) (_crPos tcr) w
-- return $ hasLOS (_crPos cr) (_crPos tcr) w -- return $ hasLOS (_crPos cr) (_crPos tcr) w
crIsAiming :: Creature -> Bool crIsAiming :: Creature -> Bool
crIsAiming cr = _posture (_crStance cr) == Aiming crIsAiming cr = case _posture (_crStance cr) of
Aiming {} -> True
_ -> False
crHasTarget :: Creature -> Bool crHasTarget :: Creature -> Bool
crHasTarget cr = isJust $ cr ^? crIntention . targetCr . _Just crHasTarget cr = isJust $ cr ^? crIntention . targetCr . _Just
+1 -1
View File
@@ -13,7 +13,7 @@ import Geometry
holsterWeapon, drawWeapon :: Action holsterWeapon, drawWeapon :: Action
holsterWeapon = DoImpulses [ChangePosture AtEase, MakeSound whiteNoiseFadeOutS] holsterWeapon = DoImpulses [ChangePosture AtEase, MakeSound whiteNoiseFadeOutS]
drawWeapon = DoImpulses [ChangePosture Aiming, MakeSound whiteNoiseFadeInS] drawWeapon = DoImpulses [ChangePosture (Aiming 0), MakeSound whiteNoiseFadeInS]
shootTillEmpty :: Action shootTillEmpty :: Action
--shootTillEmpty = (crCanShoot `DoActionWhile` DoImpulses [UseItem]) --shootTillEmpty = (crCanShoot `DoActionWhile` DoImpulses [UseItem])
+49 -17
View File
@@ -28,7 +28,8 @@ yourControl _ w
, f x = , f x =
w w
& cWorld . lWorld . creatures . ix 0 & cWorld . lWorld . creatures . ix 0
%~ (wasdWithAiming w . setCrPosture pkeys) -- %~ (wasdWithAiming w . setCrPosture pkeys)
%~ wasdWithAiming w
& tryClickUse pkeys & tryClickUse pkeys
& handleHotkeys & handleHotkeys
| otherwise = | otherwise =
@@ -115,7 +116,8 @@ wasdWithAiming ::
World -> World ->
Creature -> Creature ->
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 where
speed = _mvSpeed $ _crMvType cr speed = _mvSpeed $ _crMvType cr
inp = w ^. input inp = w ^. input
@@ -123,30 +125,60 @@ wasdWithAiming w cr = wasdAim inp cam . wasdTwist $ wasdMovement inp cam speed c
wasdAim :: Input -> Camera -> Creature -> Creature wasdAim :: Input -> Camera -> Creature -> Creature
wasdAim inp cam cr 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 | SDL.ButtonRight `M.member` _mouseButtons inp = aimTurn mouseDir cr
| otherwise = creatureTurnTowardDir (_crMvAim cr) 0.2 cr | otherwise = creatureTurnTowardDir (_crMvAim cr) 0.2 cr
where where
mouseDir = argV $ mouseWorldPos inp cam - (cr ^. crPos) mouseDir = argV $ mouseWorldPos inp cam - (cr ^. crPos)
-- aim with the root item ---- aim with the root item
wasdTwist :: Creature -> Creature ---- when initiating aim with a two handed weapon, change the creature direction
wasdTwist cr ---- to be closer to where the two handed weapon was pointing
| _posture (_crStance cr) == Aiming = fromMaybe cr $ do --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 itRef <- cr ^? crManipulation . manObject . imRootSelectedItem
astance <- cr ^? crInv . ix itRef . itUse . heldAim . aimStance astance <- cr ^? crInv . ix itRef . itUse . heldAim . aimStance
case (astance, cr ^. crTwist) of case astance of
(TwoHandUnder, 0) -> TwoHandUnder ->
return $ cr & crTwist .~ twistamount * pi & crDir -~ twistamount * pi return $ cr & crStance . posture .~ Aiming (twistamount * pi)
(TwoHandOver, 0) -> & crDir -~ (twistamount * pi)
return $ cr & crTwist .~ twistamount * pi & crDir -~ twistamount * pi TwoHandOver ->
_ -> Nothing return $ cr & crStance . posture .~ Aiming (twistamount * pi)
| otherwise = & crDir -~ (twistamount * pi)
cr _ -> return $ cr & crStance . posture .~ Aiming 0
& crDir +~ _crTwist cr
& crTwist .~ 0 --remove twistk
where where
twistamount :: Float
twistamount = 1.6 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 :: Input -> Camera -> Float -> Creature -> Creature
wasdMovement inp cam speed = theMovement . setMvAim wasdMovement inp cam speed = theMovement . setMvAim
where where
@@ -171,7 +203,7 @@ aimTurn a cr = creatureTurnTowardDir a (x * 0.2) cr
-} -}
setCrPosture :: M.Map SDL.MouseButton Int -> Creature -> Creature setCrPosture :: M.Map SDL.MouseButton Int -> Creature -> Creature
setCrPosture pkeys setCrPosture pkeys
| SDL.ButtonRight `M.member` pkeys = crStance . posture .~ Aiming | SDL.ButtonRight `M.member` pkeys = crStance . posture .~ Aiming 0
| otherwise = crStance . posture .~ AtEase | otherwise = crStance . posture .~ AtEase
tryClickUse :: M.Map SDL.MouseButton Int -> World -> World tryClickUse :: M.Map SDL.MouseButton Int -> World -> World
+1 -1
View File
@@ -38,7 +38,7 @@ data Creature = Creature
, _crOldDir :: Float , _crOldDir :: Float
, _crMvDir :: Float , _crMvDir :: Float
, _crMvAim :: Float , _crMvAim :: Float
, _crTwist :: Float -- , _crTwist :: Float
, _crType :: CreatureType , _crType :: CreatureType
, _crID :: Int , _crID :: Int
, _crRad :: Float , _crRad :: Float
+1 -1
View File
@@ -36,7 +36,7 @@ data FootForward
deriving (Eq, Ord, Show, Read) --Generic, Flat) deriving (Eq, Ord, Show, Read) --Generic, Flat)
data Posture data Posture
= Aiming = Aiming {_aimTwist :: Float}
| AtEase | AtEase
deriving (Eq, Ord, Show, Read) --Generic, Flat) deriving (Eq, Ord, Show, Read) --Generic, Flat)
+1 -1
View File
@@ -18,7 +18,7 @@ defaultCreature =
, _crOldDir = 0 , _crOldDir = 0
, _crMvDir = 0 , _crMvDir = 0
, _crMvAim = 0 , _crMvAim = 0
, _crTwist = 0 -- , _crTwist = 0
, _crID = 1 , _crID = 1
, _crType = defaultCreatureSkin , _crType = defaultCreatureSkin
, _crRad = 10 , _crRad = 10
+1 -1
View File
@@ -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 :: Item -> Creature -> (Point3, Q.Quaternion Float) -> (Point3, Q.Quaternion Float)
heldItemRelativeOrient itm cr (p,q) heldItemRelativeOrient itm cr (p,q)
| _posture (_crStance cr) == Aiming = | Aiming {} <- _posture (_crStance cr) =
(p + aimingWeaponZeroPos cr itm `v2z` shoulderHeight, Q.qID * q) (p + aimingWeaponZeroPos cr itm `v2z` shoulderHeight, Q.qID * q)
| isTwoHandFlat = | isTwoHandFlat =
( V3 (_crRad cr) 0 handD ( V3 (_crRad cr) 0 handD
+7 -6
View File
@@ -57,7 +57,7 @@ fpsText x = color col . text $ "ms/frame " ++ show x
drawMenuOrHUD :: Configuration -> Universe -> Picture drawMenuOrHUD :: Configuration -> Universe -> Picture
drawMenuOrHUD cfig u = case u ^. uvScreenLayers of drawMenuOrHUD cfig u = case u ^. uvScreenLayers of
[] -> drawHUD (u ^. uvConfig) (u ^. uvWorld) [] -> 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 :: Universe -> Picture
drawConcurrentMessage u = drawConcurrentMessage u =
@@ -239,12 +239,13 @@ drawGapPlus x =
aimDelaySweep :: World -> Picture aimDelaySweep :: World -> Picture
aimDelaySweep w = fold $ do aimDelaySweep w = fold $ do
cr <- w ^? cWorld . lWorld . creatures . ix 0 cr <- w ^? cWorld . lWorld . creatures . ix 0
aimstatus <- cr ^? crStance . posture -- aimstatus <- cr ^? crStance . posture
guard (aimstatus == Aiming) -- guard (aimstatus == Aiming)
return $ drawSweep cr w Aiming {} <- cr ^? crStance . posture
return $ drawAimSweep cr w
drawSweep :: Creature -> World -> Picture drawAimSweep :: Creature -> World -> Picture
drawSweep cr w = fromMaybe mempty $ do drawAimSweep cr w = fold $ do
a <- safeArgV (mwp -.- p) a <- safeArgV (mwp -.- p)
let a' let a'
| a - cdir > pi = cdir + 2 * pi | a - cdir > pi = cdir + 2 * pi
-1
View File
@@ -87,7 +87,6 @@ extraPics cfig u =
<> foldMap drawTractorBeam (_tractorBeams lw) <> foldMap drawTractorBeam (_tractorBeams lw)
<> foldMap drawLinearShockwave (_linearShockwaves lw) <> foldMap drawLinearShockwave (_linearShockwaves lw)
<> foldMap drawShockwave (_shockwaves lw) <> foldMap drawShockwave (_shockwaves lw)
-- <> foldMap drawLaser (_lasersToDraw lw)
<> foldMap drawTeslaArc (_teslaArcs lw) <> foldMap drawTeslaArc (_teslaArcs lw)
<> foldMap drawRadarSweep (_radarSweeps lw) <> foldMap drawRadarSweep (_radarSweeps lw)
<> foldMap drawFlame (_flames lw) <> foldMap drawFlame (_flames lw)
+3 -2
View File
@@ -26,8 +26,9 @@ import qualified IntMapHelp as IM
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
testStringInit :: Universe -> [String] testStringInit :: Universe -> [String]
testStringInit u = prettyShort testStringInit u = []
$ u ^.. uvWorld . cWorld . lWorld . teslaArcs . ix 0 . taArcSteps . each . asObject -- 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 --testStringInit u = foldMap prettyShort $ u ^. uvWorld . cWorld . lWorld . projectiles
-- (map (show . _ebPos) $ u ^. uvWorld . cWorld . lWorld . energyBalls) -- (map (show . _ebPos) $ u ^. uvWorld . cWorld . lWorld . energyBalls)
-- <> -- <>
+228 -221
View File
File diff suppressed because it is too large Load Diff