Move towards abstracting out held item positioning

This commit is contained in:
2022-07-14 00:06:13 +01:00
parent d26470281c
commit 090408b438
4 changed files with 46 additions and 3 deletions
+39
View File
@@ -10,6 +10,7 @@ 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
@@ -77,6 +78,44 @@ 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
+4 -3
View File
@@ -112,9 +112,10 @@ torch = defaultWeapon
createHeldLight :: Creature -> Int -> World -> World
createHeldLight cr i w = w
removeHeldLight :: Creature -> Int -> World -> World
removeHeldLight cr i w = w
& tempLightSources .:~ tlsTimeRadColPos 1 200 0.7 p
where
p = addZ 20 $ _crPos cr
itm = cr ^?! crInv . ix i
flatShield :: Item
flatShield = defaultWeapon