Complete PartiallyComposedItem -> ComposedItem
This commit is contained in:
@@ -9,7 +9,6 @@ module Dodge.Creature.Picture (
|
||||
deadFeet,
|
||||
) where
|
||||
|
||||
import Dodge.Data.ComposedItem
|
||||
import Control.Lens
|
||||
import Dodge.Creature.HandPos (translateToLeftHand, translateToRightHand)
|
||||
import Dodge.Creature.Test
|
||||
|
||||
@@ -174,7 +174,7 @@ invRootItemEffs cr =
|
||||
(reduceLocLDT (Endo . invItemLocUpdate) . LocLDT TopLDT)
|
||||
(invLDT (_crInv cr))
|
||||
|
||||
invItemLocUpdate :: LocationLDT ItemLink PartiallyComposedItem -> World -> World
|
||||
invItemLocUpdate :: LocationLDT ItemLink ComposedItem -> World -> World
|
||||
invItemLocUpdate loc w = case itm ^. itType of
|
||||
ATTACH BULLETSYNTH -> fromMaybe w $ do
|
||||
i <- itm ^? itLocation . ilInvID
|
||||
@@ -237,7 +237,7 @@ updateHeldRootItem cr = fromMaybe id $ do
|
||||
itmtree <- invRootTrees (_crInv cr) ^? ix invid
|
||||
return $ updateAttachedItems itmtree cr
|
||||
|
||||
updateAttachedItems :: LabelDoubleTree ItemLink PartiallyComposedItem -> Creature -> World -> World
|
||||
updateAttachedItems :: LabelDoubleTree ItemLink ComposedItem -> Creature -> World -> World
|
||||
updateAttachedItems itmtree cr =
|
||||
cldtPropagateFold
|
||||
chainLinkOrientation
|
||||
@@ -249,9 +249,9 @@ updateAttachedItems itmtree cr =
|
||||
-- need to check rotation
|
||||
chainLinkOrientation ::
|
||||
(Point3, Q.Quaternion Float) ->
|
||||
PartiallyComposedItem ->
|
||||
ComposedItem ->
|
||||
ItemLink ->
|
||||
PartiallyComposedItem ->
|
||||
ComposedItem ->
|
||||
(Point3, Q.Quaternion Float)
|
||||
chainLinkOrientation mo (par, _, _) (ILink lt f) (child, _, _) =
|
||||
(p + Q.rotate q p1, q * q1)
|
||||
@@ -262,7 +262,7 @@ chainLinkOrientation mo (par, _, _) (ILink lt f) (child, _, _) =
|
||||
updateItemWithOrientation ::
|
||||
Creature ->
|
||||
(Point3, Q.Quaternion Float) ->
|
||||
LocationLDT ItemLink PartiallyComposedItem ->
|
||||
LocationLDT ItemLink ComposedItem ->
|
||||
World ->
|
||||
World
|
||||
updateItemWithOrientation cr m loc@(LocLDT _ itmtree) =
|
||||
@@ -276,14 +276,14 @@ updateItemWithOrientation cr m loc@(LocLDT _ itmtree) =
|
||||
ci = itmtree ^. ldtValue
|
||||
itm = ci ^. _1
|
||||
|
||||
drawAugmentedHUD :: LocationLDT ItemLink PartiallyComposedItem -> World -> World
|
||||
drawAugmentedHUD :: LocationLDT ItemLink ComposedItem -> World -> World
|
||||
drawAugmentedHUD (LocLDT con _) w = fromMaybe w $ do
|
||||
itm <- con ^? cldtParent . _1
|
||||
return $ w & cWorld . lWorld . flares <>~ drawTargeting itm w
|
||||
|
||||
shineTargetLaser ::
|
||||
Creature ->
|
||||
LabelDoubleTree ItemLink PartiallyComposedItem ->
|
||||
LabelDoubleTree ItemLink ComposedItem ->
|
||||
(Point3, Q.Quaternion Float) ->
|
||||
World ->
|
||||
World
|
||||
@@ -325,7 +325,7 @@ shineTargetLaser cr itmtree (p, q) w = fromMaybe (w & pointittarg . itTgPos .~ N
|
||||
|
||||
shineTorch ::
|
||||
Creature ->
|
||||
LabelDoubleTree ItemLink PartiallyComposedItem ->
|
||||
LabelDoubleTree ItemLink ComposedItem ->
|
||||
(Point3, Q.Quaternion Float) ->
|
||||
World ->
|
||||
World
|
||||
|
||||
@@ -8,7 +8,6 @@ module Dodge.Data.ComposedItem where
|
||||
import Control.Lens
|
||||
import Data.Aeson
|
||||
import Data.Aeson.TH
|
||||
-- it would be nice not to have to import the following...
|
||||
import Dodge.Data.Item
|
||||
import Geometry.Data
|
||||
import Linear.Quaternion (Quaternion (..))
|
||||
@@ -42,12 +41,7 @@ data ItemStructuralFunction
|
||||
| FunctionChangeSF
|
||||
deriving (Eq, Ord, Show, Read)
|
||||
|
||||
type PartiallyComposedItem = (Item, ItemStructuralFunction, LinkTest)
|
||||
|
||||
--data ComposedItem = CItem
|
||||
-- { _cItem :: Item
|
||||
-- , _cItemFunction :: ItemStructuralFunction
|
||||
-- }
|
||||
type ComposedItem = (Item, ItemStructuralFunction, LinkTest)
|
||||
|
||||
data ItemLink = ILink
|
||||
{ _iatType :: ComposeLinkType
|
||||
@@ -55,20 +49,18 @@ data ItemLink = ILink
|
||||
}
|
||||
|
||||
data LinkTest = LTest
|
||||
{ _tryLeftLink :: PartiallyComposedItem -> Maybe LinkUpdate
|
||||
, _tryRightLink :: PartiallyComposedItem -> Maybe LinkUpdate
|
||||
{ _tryLeftLink :: ComposedItem -> Maybe LinkUpdate
|
||||
, _tryRightLink :: ComposedItem -> Maybe LinkUpdate
|
||||
}
|
||||
|
||||
data LinkUpdate = LUpdate
|
||||
{ _luLinkType :: ItemLink
|
||||
, _luParentUpdate :: PartiallyComposedItem -> PartiallyComposedItem
|
||||
, _luChildUpdate :: PartiallyComposedItem -> PartiallyComposedItem
|
||||
, _luParentUpdate :: ComposedItem -> ComposedItem
|
||||
, _luChildUpdate :: ComposedItem -> ComposedItem
|
||||
}
|
||||
|
||||
--makeLenses ''ComposedItem
|
||||
makeLenses ''ItemLink
|
||||
makeLenses ''LinkTest
|
||||
makeLenses ''LinkUpdate
|
||||
deriveJSON defaultOptions ''ItemStructuralFunction
|
||||
--deriveJSON defaultOptions ''ComposedItem
|
||||
deriveJSON defaultOptions ''ComposeLinkType
|
||||
|
||||
@@ -19,7 +19,7 @@ import NewInt
|
||||
import Padding
|
||||
import Picture.Base
|
||||
|
||||
invSelectionItem :: Int -> Creature -> Int -> PartiallyComposedItem -> SelectionItem ()
|
||||
invSelectionItem :: Int -> Creature -> Int -> ComposedItem -> SelectionItem ()
|
||||
invSelectionItem indent cr i ci =
|
||||
SelectionItem
|
||||
{ _siPictures = pics & ix 0 %~ (++ anyequippos ++ anyhotkey)
|
||||
|
||||
@@ -13,7 +13,7 @@ import Dodge.Data.Creature
|
||||
import LensHelp
|
||||
import Padding
|
||||
|
||||
itemDisplay :: Creature -> PartiallyComposedItem -> [String]
|
||||
itemDisplay :: Creature -> ComposedItem -> [String]
|
||||
itemDisplay cr ci =
|
||||
zipWithDefaults id (leftPad 15 ' ') itemDisplayPad (basicItemDisplay itm) (itemNumberDisplay cr ci)
|
||||
where
|
||||
@@ -93,7 +93,7 @@ showAutoRechargeProgress lc = case lc of
|
||||
-- where
|
||||
-- ic = (itm ^?! itUse . heldConsumption . laSource)
|
||||
|
||||
itemNumberDisplay :: Creature -> PartiallyComposedItem -> [String]
|
||||
itemNumberDisplay :: Creature -> ComposedItem -> [String]
|
||||
itemNumberDisplay cr ci = case (ci ^. _2, itm ^?! itUse) of
|
||||
(WeaponTargetingSF,_)
|
||||
-> [maybe "" (const "!TARG!") (itm ^? itTargeting . itTgPos . _Just)]
|
||||
|
||||
@@ -14,7 +14,7 @@ import Dodge.Item.Draw.SPic
|
||||
import Dodge.Item.HeldOffset
|
||||
import ShapePicture
|
||||
|
||||
itemEquipPict :: Creature -> LabelDoubleTree ItemLink PartiallyComposedItem -> SPic
|
||||
itemEquipPict :: Creature -> LabelDoubleTree ItemLink ComposedItem -> SPic
|
||||
itemEquipPict cr itmtree = case itm ^. itUse of
|
||||
UseHeld{} | itm ^? itLocation . ilIsRoot == Just True
|
||||
&& itm ^? itLocation . ilInvID == cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
|
||||
@@ -19,12 +19,12 @@ import Picture
|
||||
import Shape
|
||||
import ShapePicture
|
||||
|
||||
itemTreeSPic :: LabelDoubleTree ItemLink PartiallyComposedItem -> SPic
|
||||
itemTreeSPic :: LabelDoubleTree ItemLink ComposedItem -> SPic
|
||||
itemTreeSPic (LDT (itm,_,_) l r) =
|
||||
itemSPic itm
|
||||
<> foldMap (itemRotTreeSPic itm) (l <> r)
|
||||
|
||||
itemRotTreeSPic :: Item -> (ItemLink, LabelDoubleTree ItemLink PartiallyComposedItem)
|
||||
itemRotTreeSPic :: Item -> (ItemLink, LabelDoubleTree ItemLink ComposedItem)
|
||||
-> SPic
|
||||
itemRotTreeSPic par (il, t) = translateSP p . overPosSP (Q.rotate q) $ itemTreeSPic t
|
||||
where
|
||||
|
||||
+18
-18
@@ -21,9 +21,9 @@ import LensHelp
|
||||
import ListHelp
|
||||
|
||||
tryAttachItems ::
|
||||
LabelDoubleTree ItemLink PartiallyComposedItem ->
|
||||
LabelDoubleTree ItemLink PartiallyComposedItem ->
|
||||
Maybe (LabelDoubleTree ItemLink PartiallyComposedItem)
|
||||
LabelDoubleTree ItemLink ComposedItem ->
|
||||
LabelDoubleTree ItemLink ComposedItem ->
|
||||
Maybe (LabelDoubleTree ItemLink ComposedItem)
|
||||
tryAttachItems = leftRightCombine leftIsParentCombine rightIsParentCombine
|
||||
|
||||
useBreakL ::
|
||||
@@ -100,7 +100,7 @@ itemToFunction itm = case itm ^. itType of
|
||||
EQUIP{} -> EquipmentPlatformSF
|
||||
_ -> UncomposableIsolateSF
|
||||
|
||||
basePCI :: Item -> PartiallyComposedItem
|
||||
basePCI :: Item -> ComposedItem
|
||||
basePCI itm = case _itType itm of
|
||||
_ -> (itm, itemToFunction itm, itemBaseConnections itm)
|
||||
|
||||
@@ -112,13 +112,13 @@ itemBaseConnections itm = case _itType itm of
|
||||
laserLinkTest :: Item -> LinkTest
|
||||
laserLinkTest itm = LTest (llleft itm) (llright itm)
|
||||
|
||||
llleft :: Item -> PartiallyComposedItem -> Maybe LinkUpdate
|
||||
llleft :: Item -> ComposedItem -> Maybe LinkUpdate
|
||||
llleft itm =
|
||||
_tryLeftLink
|
||||
. uncurry useBreakL
|
||||
$ itemToBreakLists itm WeaponTargetingSF
|
||||
|
||||
llright :: Item -> PartiallyComposedItem -> Maybe LinkUpdate
|
||||
llright :: Item -> ComposedItem -> Maybe LinkUpdate
|
||||
llright itm pci = case pci ^. _1 . itType of
|
||||
CRAFT TRANSFORMER -> Just (toLasgunUpdate itm)
|
||||
_ -> _tryRightLink (uncurry useBreakL $ itemToBreakLists itm WeaponTargetingSF) pci
|
||||
@@ -136,14 +136,14 @@ toLasgunUpdate itm =
|
||||
|
||||
type LDTComb a b = LabelDoubleTree b a -> LabelDoubleTree b a -> Maybe (LabelDoubleTree b a)
|
||||
|
||||
leftIsParentCombine :: LDTComb PartiallyComposedItem ItemLink
|
||||
leftIsParentCombine :: LDTComb ComposedItem ItemLink
|
||||
leftIsParentCombine ltree rtree = do
|
||||
lu <- (ltree ^. ldtValue . _3 . tryRightLink) (rtree ^. ldtValue)
|
||||
return $
|
||||
ltree & ldtValue %~ (lu ^. luParentUpdate)
|
||||
& ldtRight %~ (++ [(lu ^. luLinkType, rtree & ldtValue %~ (lu ^. luChildUpdate))])
|
||||
|
||||
rightIsParentCombine :: LDTComb PartiallyComposedItem ItemLink
|
||||
rightIsParentCombine :: LDTComb ComposedItem ItemLink
|
||||
rightIsParentCombine ltree rtree = do
|
||||
lu <- (rtree ^. ldtValue . _3 . tryLeftLink) (ltree ^. ldtValue)
|
||||
return $
|
||||
@@ -176,7 +176,7 @@ joinItemsInList f xs = snd $ h (xs, [])
|
||||
Just w -> h (w : ys, zs)
|
||||
|
||||
-- this puts the first elements in the intmap at the end of the list
|
||||
invLDT :: IM.IntMap Item -> [LabelDoubleTree ItemLink PartiallyComposedItem]
|
||||
invLDT :: IM.IntMap Item -> [LabelDoubleTree ItemLink ComposedItem]
|
||||
invLDT =
|
||||
joinItemsInList tryAttachItems . IM.elems
|
||||
. fmap (singleLDT . basePCI)
|
||||
@@ -215,23 +215,23 @@ invTrees' = IM.unions . map (ldtToIM getindex . fmap (^. _1)) . map (fmap (\(x,
|
||||
i ^? itLocation . ilInvID
|
||||
|
||||
-- returns an intmap with trees for (only!) root items, indexed by inventory position
|
||||
invRootTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ItemLink PartiallyComposedItem)
|
||||
invRootTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ItemLink ComposedItem)
|
||||
invRootTrees = IM.fromDistinctAscList . reverse . map (getid) . invLDT
|
||||
where
|
||||
getid :: LabelDoubleTree ItemLink PartiallyComposedItem
|
||||
-> (Int, LabelDoubleTree ItemLink PartiallyComposedItem)
|
||||
getid :: LabelDoubleTree ItemLink ComposedItem
|
||||
-> (Int, LabelDoubleTree ItemLink ComposedItem)
|
||||
getid t = (t ^?! ldtValue . _1 . itLocation . ilInvID, t)
|
||||
|
||||
-- returns an intmap with indents and locations for all items
|
||||
allInvLocs :: IM.IntMap Item -> IM.IntMap (Int, LocationLDT ItemLink PartiallyComposedItem)
|
||||
allInvLocs :: IM.IntMap Item -> IM.IntMap (Int, LocationLDT ItemLink ComposedItem)
|
||||
allInvLocs inv = foldMap (f . LocLDT TopLDT) (IM.elems (invRootTrees inv)) mempty
|
||||
where
|
||||
f t = cldtPropagateFold h h g 0 t id
|
||||
h x _ _ _ = x + 1
|
||||
g :: Int -> LocationLDT ItemLink PartiallyComposedItem
|
||||
-> (IM.IntMap (Int, LocationLDT ItemLink PartiallyComposedItem)
|
||||
-> IM.IntMap (Int, LocationLDT ItemLink PartiallyComposedItem))
|
||||
-> IM.IntMap (Int, LocationLDT ItemLink PartiallyComposedItem)
|
||||
-> IM.IntMap (Int, LocationLDT ItemLink PartiallyComposedItem)
|
||||
g :: Int -> LocationLDT ItemLink ComposedItem
|
||||
-> (IM.IntMap (Int, LocationLDT ItemLink ComposedItem)
|
||||
-> IM.IntMap (Int, LocationLDT ItemLink ComposedItem))
|
||||
-> IM.IntMap (Int, LocationLDT ItemLink ComposedItem)
|
||||
-> IM.IntMap (Int, LocationLDT ItemLink ComposedItem)
|
||||
g x ldt = (.) (IM.insert (ldt ^?! locLDT . ldtValue . _1 . itLocation . ilInvID)
|
||||
(x, ldt))
|
||||
|
||||
@@ -8,7 +8,7 @@ import Color
|
||||
import Control.Lens
|
||||
import Dodge.Data.ComposedItem
|
||||
|
||||
itemInvColor :: PartiallyComposedItem -> Color
|
||||
itemInvColor :: ComposedItem -> Color
|
||||
itemInvColor ci = case ci ^. _2 of
|
||||
WeaponPlatformSF -> white
|
||||
EquipmentPlatformSF -> yellow
|
||||
|
||||
@@ -19,7 +19,6 @@ import Dodge.Creature.Info
|
||||
import Dodge.Creature.Test
|
||||
import Dodge.Data.CardinalPoint
|
||||
import Dodge.Data.Combine
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.Data.Config
|
||||
import Dodge.Data.DoubleTree
|
||||
import Dodge.Data.SelectionList
|
||||
|
||||
Reference in New Issue
Block a user