Enable duct taping torches to rifles

This commit is contained in:
2022-07-14 11:32:32 +01:00
parent 2cfa3ca3a7
commit 79791d0df2
18 changed files with 109 additions and 154 deletions
+1 -52
View File
@@ -7,15 +7,13 @@ module Dodge.Item.Draw
, heldItemOffset
) where
import Dodge.Data
import Dodge.Item.HeldOffset
import ShapePicture
import Dodge.Creature.HandPos
import Dodge.Item.Equipment.Shape
import Dodge.Item.Draw.SPic
import Geometry
import qualified Data.IntMap.Strict as IM
import Control.Lens
import Data.Maybe
itemEquipPict :: Creature -> Item -> SPic
itemEquipPict cr it = case it ^?! itUse of
@@ -81,53 +79,4 @@ pictureWeaponOnAimItem p' cr posInInv
-- f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
-- sLen = _strideLength $ _crStance cr
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