Files
loop/src/Dodge/Item/Draw.hs
T

49 lines
1.5 KiB
Haskell

{-# LANGUAGE LambdaCase #-}
module Dodge.Item.Draw (
itemSPic,
itemEquipPict,
) where
import Dodge.Data.Equipment.Misc
import Dodge.Data.ComposedItem
import Dodge.Data.DoubleTree
import Geometry.Data
import Control.Lens
import Dodge.Creature.HandPos
import Dodge.Data.Creature
import Dodge.Item.Draw.SPic
import Dodge.Item.HeldOffset
import ShapePicture
itemEquipPict :: Creature -> LabelDoubleTree ItemLink CItem -> SPic
itemEquipPict cr itmtree
| Just i <- itm ^? itLocation . ilInvID
, Just esite <- cr ^? crInv . ix i . itLocation . ilEquipSite . _Just
, Just attachpos <- equipAttachPos <$> itm ^? itType . ibtEquip
= equipPosition esite cr attachpos (itemSPic itm)
| itm ^? itLocation . ilInvID == cr ^? crManipulation . manObject . imRootSelectedItem
= overPosSP (heldItemOffset itm cr) (itemTreeSPic itmtree)
| otherwise = mempty
where
itm = itmtree ^. ldtValue . _1
equipAttachPos :: EquipItemType -> Point3
equipAttachPos = \case
BATTERYPACK -> V3 (-8) 0 10
FUELPACK -> V3 (-9) 0 10
BULLETBELTPACK -> V3 (-9) 0 10
BULLETBELTBRACER -> V3 (-9) 0 10
_ -> 0
equipPosition :: EquipSite -> Creature -> Point3 -> SPic -> SPic
equipPosition epos cr p sh = case epos of
OnLeftWrist -> translateToLeftWrist cr sh
OnRightWrist -> translateToRightWrist cr sh
OnLegs ->
translateToLeftLeg cr sh
<> translateToRightLeg cr sh-- (mirrorSPxz sh)
OnHead -> translateToHead cr sh
OnChest -> translateToChest cr sh
OnBack -> translateToBack cr p sh
OnSpecial -> sh