41 lines
1.4 KiB
Haskell
41 lines
1.4 KiB
Haskell
module Dodge.Item.Draw (
|
|
itemSPic,
|
|
itemEquipPict,
|
|
) where
|
|
|
|
import Data.Foldable
|
|
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 PartiallyComposedItem -> SPic
|
|
itemEquipPict cr itmtree = case itm ^. itUse of
|
|
UseHeld{} | itm ^? itLocation . ilIsRoot == Just True
|
|
&& itm ^? itLocation . ilInvID == cr ^? crManipulation . manObject . imRootSelectedItem
|
|
-> overPosSP (heldItemOffset itm cr) (itemTreeSPic itmtree)
|
|
ituse -> fold $ do
|
|
attachpos <- ituse ^? uequipEffect . eeAttachPos
|
|
i <- itm ^? itLocation . ilInvID
|
|
epos <- cr ^? crInvEquipped . ix i
|
|
return $ equipPosition epos cr attachpos (itemSPic itm)
|
|
where
|
|
itm = itmtree ^. ldtValue . _1
|
|
|
|
equipPosition :: EquipPosition -> 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
|