Working element buffer object

This commit is contained in:
2021-09-20 12:36:35 +01:00
parent c605ac74ff
commit 5cbcbec101
22 changed files with 242 additions and 212 deletions
+10 -16
View File
@@ -34,7 +34,7 @@ basicCrPict
-> Creature
-> World
-> SPic
basicCrPict col cr w = SPic (basicCrShape col cr) $ pictures $
basicCrPict col cr w = (,) (basicCrShape col cr) $ pictures $
targetingPic ++
[ creatureDisplayText w cr
, tr . rotdir $ _spPicture $ drawEquipment cr
@@ -125,6 +125,7 @@ damageModSH :: Creature -> Shape -> Shape
damageModSH _ = id
feet :: Creature -> Shape
{-# INLINE feet #-}
feet cr = case cr ^? crStance . carriage of
Just (Walking sa LeftForward) -> mconcat
[ translateSHf ( f sa) off aFoot
@@ -146,6 +147,7 @@ feet cr = case cr ^? crStance . carriage of
f i = 6 * fromIntegral (sLen - i) / fromIntegral sLen
arms :: Creature -> Shape
{-# INLINE arms #-}
arms cr
| oneH cr = shoulderSH . translateSHf 11 (-3) . rotateSH (-0.5) $ scaleSH (V3 1 1.5 1) aHand
| twists cr = shoulderSH . translateSHf 0 (0.5* crad) . rotateSH (-1) $ mconcat
@@ -165,6 +167,7 @@ arms cr
f i = negate 2 + negate 6 * fromIntegral (sLen - i) / fromIntegral sLen
scalp :: Creature -> Shape
{-# INLINE scalp #-}
scalp cr
| twists cr = translateSHf 0 (0.5*crad) . rotateSH (-1) $ translateSHf (negate 0.25 * crad) 0.25 fhead
| oneH cr = rotateSH 0.5 $ translateSHf (0.25 * crad) 0 fhead
@@ -184,6 +187,7 @@ twists cr = crIsAiming' cr && crIt ^? itAimStance == Just TwoHandTwist
crIt = _crInv cr IM.! _crInvSel cr
torso :: Creature -> Shape
{-# INLINE torso #-}
torso cr
| oneH cr = rotateSH 0.5 $ mconcat
[ translateSHf 0 3 . rotateSH (negate 0.2) $ aShoulder
@@ -203,27 +207,16 @@ torso cr
crad = _crRad cr
baseShoulder :: Shape
{-# INLINE baseShoulder #-}
baseShoulder = translateSHz (-10) . scaleSH (V3 0.5 1 1) . upperPrismPoly 10 $ polyCirc 3 1
upperBody :: Color -> Creature -> Shape
{-# INLINE upperBody #-}
upperBody col cr = colorSH (light4 col) $ mconcat
[ arms cr
, shoulderSH $ torso cr
]
--naked :: Color -> Creature -> Picture
--naked _ cr
-- | strikeMelee = shoulderH . color white $ circleSolid $ _crRad cr
-- | pdam > 200 = shoulderH . color red $ circleSolid $ _crRad cr
-- | pdam > 99 = shoulderH . color white $ circleSolid $ _crRad cr
-- | otherwise = []
-- where
-- strikeMelee = _crMeleeCooldown cr > 5
-- pdam = sum $ concatMap (map _dmAmount) pastDams
-- pastDams = _crPastDamage $ _crState cr
shoulderSH :: Shape -> Shape
shoulderSH = translateSHz 20
waistSH :: Shape -> Shape
@@ -244,6 +237,7 @@ light4 = light . light . light . light
drawEquipment
:: Creature
-> SPic
{-# INLINE drawEquipment #-}
drawEquipment cr = mconcat $ map f $ IM.toList (_crInv cr)
where
f (i,it) = case it ^? itEquipPict of
@@ -255,8 +249,8 @@ circLine x = line [V2 0 0,V2 x 0]
picAtCrPos :: Picture -> Creature -> World -> SPic
--{-# INLINE picAtCrPos #-}
picAtCrPos thePic cr _ = SPic emptySH $ tranRot (_crPos cr) (_crDir cr) thePic
picAtCrPos thePic cr _ = (,) emptySH $ tranRot (_crPos cr) (_crDir cr) thePic
picAtCrPosNoRot :: Picture -> Creature -> World -> SPic
--{-# INLINE picAtCrPos #-}
picAtCrPosNoRot thePic cr _ = SPic emptySH $ uncurryV translate (_crPos cr) thePic
picAtCrPosNoRot thePic cr _ = (,) emptySH $ uncurryV translate (_crPos cr) thePic