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