module Dodge.Item.HeldOffset where import Dodge.Data import Dodge.Creature.HandPos import Geometry import LensHelp import Data.Maybe heldItemOffset :: Item -> Creature -> Point3 -> Point3 heldItemOffset itm cr | isSelected && _posture (_crStance cr) == Aiming = (+.+.+ V3 (aimingWeaponZeroPos cr itm) 0 shoulderD) | isSelected && isTwoHandFlat = (+.+.+ V3 (_crRad cr) 0 handD) . rotate3 (twoFlatHRot cr) . transToHandle | isSelected && isOneHand = (+.+.+ V3 0 0 handD) . (+.+.+ V3 (_crRad cr * 0.7 + handPos) (_crRad cr * negate 0.7) 0) . (+.+.+ V3 (-2) 0 0) . transToHandle | isSelected = (+.+.+ V3 0 0 handD) . (+.+.+ V3 (_crRad cr) 0 0) . rotate3 (strideRot cr + 1.2) . (+.+.+ V3 (-5) 0 0) -- . (+.+.+ V3 (-5) 0 0) . transToHandle | otherwise = id where transToHandle = fromMaybe id $ do x <- itm ^? itUse . useAim . aimHandlePos return (-.-.- V3 x 0 0) shoulderD = 18 handD = 15 isSelected = _itIsHeld itm handPos = case cr^? crStance . carriage of Just (Walking x LeftForward) -> f x * 50 _ -> 0 theIt = itm isOneHand = theIt ^? itUseAimStance == Just OneHand || isNothing (theIt ^? itUseAimStance) isTwoHandFlat = theIt ^? itUseAimStance == Just TwoHandFlat itUseAimStance = itUse . useAim . aimStance f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen sLen = _strideLength $ _crStance cr 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 * fromIntegral (sLen - i) / fromIntegral sLen sLen = _strideLength $ _crStance cr twoFlatHRot :: Creature -> Float twoFlatHRot cr = 2*strideRot cr