Work on held item positioning
This commit is contained in:
+33
-30
@@ -4,6 +4,7 @@ module Dodge.Item.Draw
|
||||
, twoFlatHRot
|
||||
, itemSPic
|
||||
, itemEquipPict
|
||||
, heldItemOffset
|
||||
) where
|
||||
import Dodge.Data
|
||||
import ShapePicture
|
||||
@@ -45,38 +46,40 @@ pictureWeaponOnAimItem
|
||||
-> Int -- ^ Position of item in inventory
|
||||
-> SPic
|
||||
pictureWeaponOnAimItem p' cr posInInv
|
||||
| isSelected && _posture (_crStance cr) == Aiming =
|
||||
shoulderD $ translateSPf (aimingWeaponZeroPos cr theIt) 0 p'
|
||||
| isSelected && isTwoHandFlat
|
||||
= handD holsteredTwoFlat
|
||||
| isSelected && isOneHand
|
||||
= handD holsteredOneHandWep
|
||||
| isSelected
|
||||
= handD holsteredWep
|
||||
| _itIsHeld theIt = overPosSP (heldItemOffset theIt cr) p'
|
||||
| otherwise = mempty
|
||||
-- | isSelected && _posture (_crStance cr) == Aiming =
|
||||
-- shoulderD $ translateSPf (aimingWeaponZeroPos cr theIt) 0 p'
|
||||
-- | isSelected && isTwoHandFlat
|
||||
-- = handD holsteredTwoFlat
|
||||
-- | isSelected && isOneHand
|
||||
-- = handD holsteredOneHandWep
|
||||
-- | isSelected
|
||||
-- = handD holsteredWep
|
||||
-- | otherwise = mempty
|
||||
where
|
||||
shoulderD = translateSPz 18
|
||||
handD = translateSPz 15
|
||||
isSelected = crSel cr == posInInv
|
||||
twistWep = translateSPf (-5) 0 p
|
||||
holsteredWep = translateSPf (_crRad cr) 0
|
||||
(rotateSP (strideRot cr + 1.2) (translateSPf (-5) 0 twistWep))
|
||||
holsteredTwoFlat = translateSPf (_crRad cr) 0 (rotateSP (twoFlatHRot cr) p)
|
||||
holsteredOneHandWep = translateSPf (_crRad cr * 0.7 + handPos) (_crRad cr * negate 0.7)
|
||||
(translateSPf (-2) 0 p)
|
||||
handPos = case cr^? crStance . carriage of
|
||||
Just (Walking x LeftForward) -> f x * 50
|
||||
_ -> 0
|
||||
-- shoulderD = translateSPz 18
|
||||
-- handD = translateSPz 15
|
||||
-- isSelected = crSel cr == posInInv
|
||||
-- twistWep = translateSPf (-5) 0 p
|
||||
-- holsteredWep = translateSPf (_crRad cr) 0
|
||||
-- (rotateSP (strideRot cr + 1.2) (translateSPf (-5) 0 twistWep))
|
||||
-- holsteredTwoFlat = translateSPf (_crRad cr) 0 (rotateSP (twoFlatHRot cr) p)
|
||||
-- holsteredOneHandWep = translateSPf (_crRad cr * 0.7 + handPos) (_crRad cr * negate 0.7)
|
||||
-- (translateSPf (-2) 0 p)
|
||||
-- handPos = case cr^? crStance . carriage of
|
||||
-- Just (Walking x LeftForward) -> f x * 50
|
||||
-- _ -> 0
|
||||
theIt = _crInv cr IM.! posInInv
|
||||
p = fromMaybe p' $ do
|
||||
x <- theIt ^? itUse . useAim . aimHandlePos
|
||||
return $translateSPf (-x) 0 p'
|
||||
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
|
||||
-- p = fromMaybe p' $ do
|
||||
-- x <- theIt ^? itUse . useAim . aimHandlePos
|
||||
-- return $translateSPf (-x) 0 p'
|
||||
-- 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
|
||||
|
||||
heldItemOffset :: Item -> Creature -> Point3 -> Point3
|
||||
heldItemOffset itm cr
|
||||
@@ -96,7 +99,7 @@ heldItemOffset itm cr
|
||||
. (+.+.+ V3 (_crRad cr) 0 0)
|
||||
. rotate3 (strideRot cr + 1.2)
|
||||
. (+.+.+ V3 (-5) 0 0)
|
||||
. (+.+.+ V3 (-5) 0 0)
|
||||
-- . (+.+.+ V3 (-5) 0 0)
|
||||
. transToHandle
|
||||
| otherwise = id
|
||||
where
|
||||
|
||||
@@ -112,9 +112,10 @@ torch = defaultWeapon
|
||||
|
||||
createHeldLight :: Creature -> Int -> World -> World
|
||||
createHeldLight cr i w = w
|
||||
& tempLightSources .:~ tlsTimeRadColPos 1 200 0.7 p
|
||||
& tempLightSources .:~ tlsTimeRadColPos 1 200 0.7
|
||||
(p +.+.+ heldItemOffset itm cr (V3 0 20 0))
|
||||
where
|
||||
p = addZ 20 $ _crPos cr
|
||||
p = addZ 0 $ _crPos cr
|
||||
itm = cr ^?! crInv . ix i
|
||||
|
||||
flatShield :: Item
|
||||
|
||||
@@ -8,7 +8,6 @@ import Dodge.Base
|
||||
import Dodge.Particle.Bullet.Spawn
|
||||
import Dodge.Creature.HandPos
|
||||
import Dodge.Movement.Turn
|
||||
import Dodge.Default.AimParams
|
||||
import Geometry
|
||||
import LensHelp
|
||||
|
||||
|
||||
@@ -30,20 +30,7 @@ bangStickSoundChoice it
|
||||
|
||||
bangStick :: Int -> Item
|
||||
bangStick i = defaultBulletWeapon
|
||||
{ _itUse = defaultrUse
|
||||
& useDelay . rateMax .~ 8
|
||||
& useMods .~
|
||||
[ ammoHammerCheck
|
||||
, useTimeCheck
|
||||
, withSoundItemChoiceStart bangStickSoundChoice
|
||||
, useAllAmmo
|
||||
, withMuzFlareI
|
||||
, withTorqueAfter
|
||||
, spreadLoaded
|
||||
-- , applyInaccuracy
|
||||
, withRecoil
|
||||
]
|
||||
, _itParams = BulletShooter
|
||||
& itParams .~ BulletShooter
|
||||
{ _muzVel = 0.8
|
||||
, _rifling = 0.8
|
||||
, _bore = 2
|
||||
@@ -56,12 +43,23 @@ bangStick i = defaultBulletWeapon
|
||||
, _torqueAfter = 0.18 + 0.02 * fromIntegral i
|
||||
, _randomOffset = 0
|
||||
}
|
||||
, _itInvSize = fromIntegral i / 3
|
||||
, _itDimension = ItemDimension
|
||||
& itInvSize .~ fromIntegral i / 3
|
||||
& itDimension .~ ItemDimension
|
||||
{ _dimRad = 5
|
||||
, _dimCenter = V3 5 0 0
|
||||
}
|
||||
}
|
||||
& itUse . useDelay . rateMax .~ 8
|
||||
& itUse . useMods .~
|
||||
[ ammoHammerCheck
|
||||
, useTimeCheck
|
||||
, withSoundItemChoiceStart bangStickSoundChoice
|
||||
, useAllAmmo
|
||||
, withMuzFlareI
|
||||
, withTorqueAfter
|
||||
, spreadLoaded
|
||||
-- , applyInaccuracy
|
||||
, withRecoil
|
||||
]
|
||||
& itType . iyBase .~ HELD (BANGSTICK i)
|
||||
& itUse . useAim . aimHandlePos .~ 5
|
||||
& itUse . useAim . aimMuzPos .~ 10
|
||||
|
||||
@@ -41,6 +41,8 @@ module Picture.Base
|
||||
, setLayer
|
||||
, mirroryz
|
||||
, mirrorxz
|
||||
, overPos
|
||||
, picMap
|
||||
)
|
||||
where
|
||||
import Geometry
|
||||
@@ -62,6 +64,7 @@ picFormat :: [Verx] -> Picture
|
||||
picFormat = id
|
||||
|
||||
picMap :: (Verx -> Verx) -> Picture -> Picture
|
||||
{-# INLINE picMap #-}
|
||||
picMap = map
|
||||
|
||||
-- | Expects clockwise input.
|
||||
|
||||
@@ -12,6 +12,7 @@ module ShapePicture
|
||||
-- , _spPicture
|
||||
, mirrorSPyz
|
||||
, mirrorSPxz
|
||||
, overPosSP
|
||||
) where
|
||||
import Shape
|
||||
import Picture
|
||||
@@ -43,6 +44,10 @@ noShape = (mempty,)
|
||||
--emptyBlank :: SPic
|
||||
--emptyBlank = mempty
|
||||
|
||||
overPosSP :: (Point3 -> Point3) -> SPic -> SPic
|
||||
{-# INLINE overPosSP #-}
|
||||
overPosSP f = bimap (overPosSH f) (picMap $ overPos f)
|
||||
|
||||
translateSPf :: Float -> Float -> SPic -> SPic
|
||||
{-# INLINE translateSPf #-}
|
||||
translateSPf x y = bimap (translateSH (V3 x y 0)) (translate x y)
|
||||
|
||||
Reference in New Issue
Block a user