83 lines
2.7 KiB
Haskell
83 lines
2.7 KiB
Haskell
module Dodge.Item.Draw
|
|
( pictureWeaponOnAim
|
|
, pictureWeaponAim
|
|
, twoFlatHRot
|
|
, itemSPic
|
|
, itemEquipPict
|
|
, heldItemOffset
|
|
) where
|
|
import Dodge.Data
|
|
import Dodge.Item.HeldOffset
|
|
import ShapePicture
|
|
import Dodge.Item.Equipment.Shape
|
|
import Dodge.Item.Draw.SPic
|
|
|
|
import qualified Data.IntMap.Strict as IM
|
|
import Control.Lens
|
|
|
|
itemEquipPict :: Creature -> Item -> SPic
|
|
itemEquipPict cr it = case it ^?! itUse of
|
|
RightUse {} -> pictureWeaponOnAim cr it
|
|
ituse -> case ituse ^? eqEq of
|
|
Just _ -> pictureOnEquip (itemSPic it) cr it
|
|
Nothing -> mempty
|
|
|
|
pictureWeaponOnAim
|
|
:: Creature
|
|
-> Item
|
|
-> SPic
|
|
pictureWeaponOnAim = pictureWeaponAim itemSPic
|
|
|
|
pictureWeaponAim
|
|
:: (Item -> SPic)
|
|
-> Creature
|
|
-> Item
|
|
-> SPic
|
|
pictureWeaponAim f cr itm = case _itPos itm of
|
|
InInv _ i -> pictureWeaponOnAimItem (f itm) cr i
|
|
_ -> mempty
|
|
|
|
{- | Places an item picture onto a creature when the item is selected. -}
|
|
pictureWeaponOnAimItem
|
|
:: SPic
|
|
-> Creature
|
|
-> Int -- ^ Position of item in inventory
|
|
-> SPic
|
|
pictureWeaponOnAimItem p' cr posInInv
|
|
| _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
|
|
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
|
|
|
|
|