Move towards abstracting out held item positioning
This commit is contained in:
@@ -482,6 +482,7 @@ data ItemUse
|
||||
, _useMods :: [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
|
||||
, _useHammer :: HammerPosition
|
||||
, _useAim :: AimParams
|
||||
, _heldAttachPos :: Point3
|
||||
, _heldAttachment :: HeldAttachment
|
||||
, _heldScroll :: Float -> Creature -> Item -> Item
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import Dodge.Default.Item
|
||||
import Dodge.Default.AimParams
|
||||
--import Dodge.Item.Draw
|
||||
import Picture
|
||||
import Geometry.Data
|
||||
|
||||
import qualified Data.Map.Strict as M
|
||||
import Control.Lens
|
||||
@@ -65,6 +66,7 @@ defaultrUse = RightUse
|
||||
, _useMods = []
|
||||
, _useHammer = HammerUp
|
||||
, _useAim = defaultAimParams
|
||||
, _heldAttachPos = V3 0 (-10) 0
|
||||
, _heldAttachment = NoHeldAttachment
|
||||
, _heldScroll = \_ _ -> id
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user