126 lines
3.5 KiB
Haskell
126 lines
3.5 KiB
Haskell
{-# LANGUAGE LambdaCase #-}
|
|
|
|
module Dodge.Item.HeldOffset (
|
|
turretItemOffset,
|
|
twoFlatHRot,
|
|
locOrient,
|
|
handHandleOrient,
|
|
) where
|
|
|
|
import Dodge.Creature.HandPos
|
|
import Dodge.Data.AimStance
|
|
import Dodge.Data.ComposedItem
|
|
import Dodge.Data.Creature
|
|
import Dodge.Data.DoubleTree
|
|
import Dodge.Data.Machine
|
|
import Dodge.DoubleTree
|
|
import Dodge.Item.AimStance
|
|
import Geometry
|
|
import LensHelp
|
|
import qualified Quaternion as Q
|
|
|
|
turretItemOffset :: Item -> Turret -> Machine -> Point3 -> Point3
|
|
turretItemOffset it tu mc =
|
|
rotate3 (_tuDir tu - _mcDir mc) . (+.+.+ V3 0 0 shoulderHeight)
|
|
. transToHandle it
|
|
|
|
transToHandle :: Item -> Point3 -> Point3
|
|
transToHandle itm = (-.-.- V3 x y 0)
|
|
where
|
|
V2 x y = handlePos itm
|
|
|
|
handleOrient :: LocationDT CItem -> Point3Q
|
|
handleOrient loc = case loc ^. locDT . dtValue . _1 . itType of
|
|
HELD FLAMETHROWER -> (V3 (-1) 0 0, Q.qID)
|
|
_ -> (V3 (-3) 0 0, Q.qID)
|
|
|
|
-- note this is relative to the creature
|
|
-- the aimstance here should match any aimstance in Aiming
|
|
handOrient :: Creature -> AimStance -> Point3Q
|
|
handOrient cr = case cr ^. crStance . posture of
|
|
Aiming {} -> \case
|
|
TwoHandUnder -> (V3 (-3) 0 shoulderHeight, Q.qID)
|
|
TwoHandOver -> (V3 0 0 shoulderHeight, Q.qID)
|
|
OneHand -> (V3 13 (-2) shoulderHeight, Q.qID)
|
|
TwoHandFlat -> (V3 13 0 shoulderHeight, Q.qID)
|
|
AtEase -> \case
|
|
OneHand -> rightHandPQ cr
|
|
TwoHandFlat -> (V3 10 0 15, Q.axisAngle (V3 0 0 1) $ twoFlatHRot cr)
|
|
TwoHandUnder -> (V3 7 (-8) 15, Q.axisAngle (V3 0 0 1) (strideRot cr + 1.2))
|
|
TwoHandOver -> (V3 10 0 15, Q.axisAngle (V3 0 0 1) (strideRot cr + 1.2))
|
|
|
|
locOrient :: LocationDT OItem -> Creature -> Point3Q
|
|
locOrient loc cr =
|
|
handHandleOrient ((\(x, y, _) -> (x, y)) <$> locToTop loc) cr
|
|
`Q.comp` (loc ^. locDT . dtValue . _3)
|
|
|
|
handHandleOrient :: LocationDT CItem -> Creature -> Point3Q
|
|
handHandleOrient loc cr =
|
|
handOrient cr (itemAimStance (l ^. locDT)) `Q.comp` handleOrient l
|
|
where
|
|
l = locToTop loc
|
|
|
|
shoulderHeight :: Float
|
|
shoulderHeight = 18
|
|
|
|
strideRot :: Creature -> Float
|
|
strideRot cr = case cr ^? crStance . carriage of
|
|
Just (Walking x LeftForward) -> f x
|
|
Just (Walking x RightForward) -> - f x
|
|
_ -> 0
|
|
where
|
|
f i = 0.1 * (sLen - i) / sLen
|
|
sLen = _strideLength $ _crStance cr
|
|
|
|
twoFlatHRot :: Creature -> Float
|
|
twoFlatHRot = (2 *) . strideRot
|
|
|
|
handlePos :: Item -> Point2
|
|
handlePos itm = case itm ^. itType of
|
|
HELD hit -> heldHandlePos hit
|
|
LASER -> V2 3 0
|
|
_ -> 0
|
|
|
|
heldHandlePos :: HeldItemType -> Point2
|
|
heldHandlePos = \case
|
|
BANGSTICK{} -> V2 3 0
|
|
REWINDER -> V2 3 0
|
|
TIMESTOPPER -> V2 3 0
|
|
TIMESCROLLER -> V2 3 0
|
|
PISTOL -> V2 3 0
|
|
MACHINEPISTOL -> V2 3 0
|
|
AUTOPISTOL -> V2 3 0
|
|
SMG -> V2 3 0
|
|
BANGCONE -> V2 3 0
|
|
BLUNDERBUSS -> V2 3 0
|
|
GRAPECANNON{} -> V2 3 0
|
|
MINIGUNX{} -> V2 3 0
|
|
VOLLEYGUN{} -> V2 3 0
|
|
RIFLE -> V2 3 0
|
|
ALTERIFLE -> V2 3 0
|
|
AUTORIFLE -> V2 3 0
|
|
BURSTRIFLE -> V2 3 0
|
|
BANGROD -> V2 3 0
|
|
ELEPHANTGUN -> V2 3 0
|
|
AMR -> V2 3 0
|
|
AUTOAMR -> V2 3 0
|
|
SNIPERRIFLE -> V2 3 0
|
|
FLAMESPITTER -> V2 3 0
|
|
FLAMETHROWER -> V2 3 0
|
|
FLAMETORRENT -> V2 3 0
|
|
FLAMEWALL -> V2 3 0
|
|
BLOWTORCH -> V2 3 0
|
|
SPARKGUN -> V2 3 0
|
|
TESLAGUN -> V2 3 0
|
|
TRACTORGUN -> V2 3 0
|
|
RLAUNCHER -> V2 3 0
|
|
RLAUNCHERX{} -> V2 3 0
|
|
GLAUNCHER -> V2 3 0
|
|
POISONSPRAYER -> V2 3 0
|
|
SHATTERGUN -> V2 3 0
|
|
LED -> V2 3 0
|
|
FLATSHIELD -> V2 3 0
|
|
KEYCARD{} -> V2 3 0
|
|
BLINKER -> V2 3 0
|
|
BLINKERUNSAFE -> V2 3 0
|