Refactor, try to limit dependencies

This commit is contained in:
2022-07-28 00:59:56 +01:00
parent 8aa5c17ab9
commit 160560af5f
418 changed files with 15104 additions and 13342 deletions
+58 -57
View File
@@ -1,82 +1,83 @@
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
module Dodge.Item.Draw (
pictureWeaponOnAim,
pictureWeaponAim,
twoFlatHRot,
itemSPic,
itemEquipPict,
heldItemOffset,
) where
import qualified IntMapHelp as IM
import Control.Lens
import Dodge.Data.Creature
import Dodge.Item.Draw.SPic
import Dodge.Item.Equipment.Shape
import Dodge.Item.HeldOffset
import qualified IntMapHelp as IM
import ShapePicture
itemEquipPict :: Creature -> Item -> SPic
itemEquipPict cr it = case it ^?! itUse of
RightUse {} -> pictureWeaponOnAim cr it
ituse -> case ituse ^? eqEq of
HeldUse{} -> pictureWeaponOnAim cr it
ituse -> case ituse ^? equipEffect of
Just _ -> pictureOnEquip (itemSPic it) cr it
Nothing -> mempty
pictureWeaponOnAim
:: Creature
-> Item
-> SPic
pictureWeaponOnAim ::
Creature ->
Item ->
SPic
pictureWeaponOnAim = pictureWeaponAim itemSPic
pictureWeaponAim
:: (Item -> SPic)
-> Creature
-> Item
-> SPic
pictureWeaponAim ::
(Item -> SPic) ->
Creature ->
Item ->
SPic
pictureWeaponAim f cr itm = case _itLocation 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
-- | Places an item picture onto a creature when the item is selected.
pictureWeaponOnAimItem ::
SPic ->
Creature ->
-- | Position of item in inventory
Int ->
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
where
-- | 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
-- 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
-- itUseAimStance = itUse . useAim . aimStance
-- f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
-- sLen = _strideLength $ _crStance cr