Remove ComposedItem, to be replaced with PartiallyComposedItem
This commit is contained in:
@@ -27,7 +27,7 @@ combineList = map f . combineItemListYouX
|
|||||||
, _siHeight = itInvHeight itm
|
, _siHeight = itInvHeight itm
|
||||||
, _siWidth = 15
|
, _siWidth = 15
|
||||||
, _siIsSelectable = True
|
, _siIsSelectable = True
|
||||||
, _siColor = itemInvColor . pciToCI $ basePCI itm
|
, _siColor = itemInvColor $ basePCI itm
|
||||||
, _siOffX = 0
|
, _siOffX = 0
|
||||||
, _siPayload = CombinableItem is itm
|
, _siPayload = CombinableItem is itm
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,17 +27,19 @@ useRootItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMaybe w
|
|||||||
cr <- w ^? cWorld . lWorld . creatures . ix crid
|
cr <- w ^? cWorld . lWorld . creatures . ix crid
|
||||||
itRef <- cr ^? crManipulation . manObject . imRootSelectedItem
|
itRef <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||||
itmtree <- invRootTrees (_crInv cr) ^? ix itRef
|
itmtree <- invRootTrees (_crInv cr) ^? ix itRef
|
||||||
let itm = itmtree ^. ldtValue . cItem
|
let itm = itmtree ^. ldtValue . _1
|
||||||
case itmtree ^. ldtValue . cItemFunction of
|
case itmtree ^. ldtValue . _2 of
|
||||||
WeaponPlatformSF ->
|
WeaponPlatformSF ->
|
||||||
return $
|
return $
|
||||||
heldEffect (bimap _iatType _cItem itmtree) cr w
|
heldEffect (bimap _iatType fst3 itmtree) cr w
|
||||||
& pointerToItem itm . itUse . heldHammer .~ HammerDown
|
& pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||||
EquipmentPlatformSF -> do
|
EquipmentPlatformSF -> do
|
||||||
guard (_crHammerPosition cr == HammerUp)
|
guard (_crHammerPosition cr == HammerUp)
|
||||||
invid <- itm ^? itLocation . ilInvID
|
invid <- itm ^? itLocation . ilInvID
|
||||||
return $ toggleEquipmentAt invid cr w
|
return $ toggleEquipmentAt invid cr w
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
where
|
||||||
|
fst3 (x,_,_) = x
|
||||||
|
|
||||||
-- where
|
-- where
|
||||||
-- UseHotkey{} -> doequipmentchange
|
-- UseHotkey{} -> doequipmentchange
|
||||||
|
|||||||
@@ -140,5 +140,5 @@ shoulderSH = translateSHz 20
|
|||||||
drawEquipment :: Creature -> SPic
|
drawEquipment :: Creature -> SPic
|
||||||
{-# INLINE drawEquipment #-}
|
{-# INLINE drawEquipment #-}
|
||||||
drawEquipment cr = foldMap
|
drawEquipment cr = foldMap
|
||||||
(itemEquipPict cr . fmap (\(a, b, _) -> CItem a b))
|
(itemEquipPict cr)
|
||||||
(invLDT $ _crInv cr)
|
(invLDT $ _crInv cr)
|
||||||
|
|||||||
+28
-22
@@ -237,23 +237,23 @@ updateHeldRootItem cr = fromMaybe id $ do
|
|||||||
itmtree <- invRootTrees (_crInv cr) ^? ix invid
|
itmtree <- invRootTrees (_crInv cr) ^? ix invid
|
||||||
return $ updateAttachedItems itmtree cr
|
return $ updateAttachedItems itmtree cr
|
||||||
|
|
||||||
updateAttachedItems :: LabelDoubleTree ItemLink ComposedItem -> Creature -> World -> World
|
updateAttachedItems :: LabelDoubleTree ItemLink PartiallyComposedItem -> Creature -> World -> World
|
||||||
updateAttachedItems itmtree cr =
|
updateAttachedItems itmtree cr =
|
||||||
cldtPropagateFold
|
cldtPropagateFold
|
||||||
chainLinkOrientation
|
chainLinkOrientation
|
||||||
chainLinkOrientation
|
chainLinkOrientation
|
||||||
(updateItemWithOrientation cr)
|
(updateItemWithOrientation cr)
|
||||||
(heldItemRelativeOrient (_cItem $ _ldtValue itmtree) cr (0, Q.qID))
|
(heldItemRelativeOrient (itmtree ^. ldtValue . _1) cr (0, Q.qID))
|
||||||
(LocLDT TopLDT itmtree)
|
(LocLDT TopLDT itmtree)
|
||||||
|
|
||||||
-- need to check rotation
|
-- need to check rotation
|
||||||
chainLinkOrientation ::
|
chainLinkOrientation ::
|
||||||
(Point3, Q.Quaternion Float) ->
|
(Point3, Q.Quaternion Float) ->
|
||||||
ComposedItem ->
|
PartiallyComposedItem ->
|
||||||
ItemLink ->
|
ItemLink ->
|
||||||
ComposedItem ->
|
PartiallyComposedItem ->
|
||||||
(Point3, Q.Quaternion Float)
|
(Point3, Q.Quaternion Float)
|
||||||
chainLinkOrientation mo (CItem par _) (ILink lt f) (CItem child _) =
|
chainLinkOrientation mo (par, _, _) (ILink lt f) (child, _, _) =
|
||||||
(p + Q.rotate q p1, q * q1)
|
(p + Q.rotate q p1, q * q1)
|
||||||
where
|
where
|
||||||
(p, q) = mo
|
(p, q) = mo
|
||||||
@@ -262,36 +262,37 @@ chainLinkOrientation mo (CItem par _) (ILink lt f) (CItem child _) =
|
|||||||
updateItemWithOrientation ::
|
updateItemWithOrientation ::
|
||||||
Creature ->
|
Creature ->
|
||||||
(Point3, Q.Quaternion Float) ->
|
(Point3, Q.Quaternion Float) ->
|
||||||
LocationLDT ItemLink ComposedItem ->
|
LocationLDT ItemLink PartiallyComposedItem ->
|
||||||
World ->
|
World ->
|
||||||
World
|
World
|
||||||
updateItemWithOrientation cr m loc@(LocLDT _ itmtree) = case (ci ^. cItem . itType, ci ^. cItemFunction) of
|
updateItemWithOrientation cr m loc@(LocLDT _ itmtree) =
|
||||||
(HELD TORCH, _) -> shineTorch cr itmtree m
|
case (ci ^. _1 . itType, ci ^. _2) of
|
||||||
(HELD LASER, WeaponTargetingSF) -> shineTargetLaser cr itmtree m
|
(HELD TORCH, _) -> shineTorch cr itmtree m
|
||||||
(TARGETING tt, _) -> updateItemTargeting tt cr itm
|
(HELD LASER, WeaponTargetingSF) -> shineTargetLaser cr itmtree m
|
||||||
(ATTACH AUGMENTEDHUD, _) -> drawAugmentedHUD loc
|
(TARGETING tt, _) -> updateItemTargeting tt cr itm
|
||||||
_ -> id
|
(ATTACH AUGMENTEDHUD, _) -> drawAugmentedHUD loc
|
||||||
|
_ -> id
|
||||||
where
|
where
|
||||||
ci = itmtree ^. ldtValue
|
ci = itmtree ^. ldtValue
|
||||||
itm = ci ^. cItem
|
itm = ci ^. _1
|
||||||
|
|
||||||
drawAugmentedHUD :: LocationLDT ItemLink ComposedItem -> World -> World
|
drawAugmentedHUD :: LocationLDT ItemLink PartiallyComposedItem -> World -> World
|
||||||
drawAugmentedHUD (LocLDT con _) w = fromMaybe w $ do
|
drawAugmentedHUD (LocLDT con _) w = fromMaybe w $ do
|
||||||
itm <- con ^? cldtParent . cItem
|
itm <- con ^? cldtParent . _1
|
||||||
return $ w & cWorld . lWorld . flares <>~ drawTargeting itm w
|
return $ w & cWorld . lWorld . flares <>~ drawTargeting itm w
|
||||||
|
|
||||||
shineTargetLaser ::
|
shineTargetLaser ::
|
||||||
Creature ->
|
Creature ->
|
||||||
LabelDoubleTree ItemLink ComposedItem ->
|
LabelDoubleTree ItemLink PartiallyComposedItem ->
|
||||||
(Point3, Q.Quaternion Float) ->
|
(Point3, Q.Quaternion Float) ->
|
||||||
World ->
|
World ->
|
||||||
World
|
World
|
||||||
shineTargetLaser cr itmtree (p, q) w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
|
shineTargetLaser cr itmtree (p, q) w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
|
||||||
guard (crIsAiming cr)
|
guard (crIsAiming cr)
|
||||||
(_, mag) <- find (isammolink . _iatType . fst) (itmtree ^. ldtLeft)
|
(_, mag) <- find (isammolink . _iatType . fst) (itmtree ^. ldtLeft)
|
||||||
i <- mag ^? ldtValue . cItem . itUse . amagLoadStatus . iaLoaded
|
i <- mag ^? ldtValue . _1 . itUse . amagLoadStatus . iaLoaded
|
||||||
guard $ i >= x
|
guard $ i >= x
|
||||||
maginvid <- mag ^? ldtValue . cItem . itLocation . ilInvID
|
maginvid <- mag ^? ldtValue . _1 . itLocation . ilInvID
|
||||||
return $
|
return $
|
||||||
w
|
w
|
||||||
& worldEventFlags . at InventoryChange ?~ ()
|
& worldEventFlags . at InventoryChange ?~ ()
|
||||||
@@ -316,19 +317,24 @@ shineTargetLaser cr itmtree (p, q) w = fromMaybe (w & pointittarg . itTgPos .~ N
|
|||||||
isammolink _ = False
|
isammolink _ = False
|
||||||
pos = _crPos cr + xyV3 (rotate3 cdir (p + V3 5 0 0))
|
pos = _crPos cr + xyV3 (rotate3 cdir (p + V3 5 0 0))
|
||||||
cdir = _crDir cr
|
cdir = _crDir cr
|
||||||
itm = itmtree ^. ldtValue . cItem
|
itm = itmtree ^. ldtValue . _1
|
||||||
pointittarg = cWorld . lWorld . creatures . ix cid . crInv . ix invid . itTargeting
|
pointittarg = cWorld . lWorld . creatures . ix cid . crInv . ix invid . itTargeting
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
invid = _ilInvID $ _itLocation itm
|
invid = _ilInvID $ _itLocation itm
|
||||||
col = blue -- mixColors reloadFrac (1-reloadFrac) blue red
|
col = blue -- mixColors reloadFrac (1-reloadFrac) blue red
|
||||||
|
|
||||||
shineTorch :: Creature -> LabelDoubleTree ItemLink ComposedItem -> (Point3, Q.Quaternion Float) -> World -> World
|
shineTorch ::
|
||||||
|
Creature ->
|
||||||
|
LabelDoubleTree ItemLink PartiallyComposedItem ->
|
||||||
|
(Point3, Q.Quaternion Float) ->
|
||||||
|
World ->
|
||||||
|
World
|
||||||
shineTorch cr itmtree (p, q) = fromMaybe id $ do
|
shineTorch cr itmtree (p, q) = fromMaybe id $ do
|
||||||
(_, mag) <- find (isammolink . _iatType . fst) (itmtree ^. ldtLeft)
|
(_, mag) <- find (isammolink . _iatType . fst) (itmtree ^. ldtLeft)
|
||||||
i <- mag ^? ldtValue . cItem . itUse . amagLoadStatus . iaLoaded
|
i <- mag ^? ldtValue . _1 . itUse . amagLoadStatus . iaLoaded
|
||||||
guard $ crIsAiming cr
|
guard $ crIsAiming cr
|
||||||
guard $ i >= x
|
guard $ i >= x
|
||||||
invid <- mag ^? ldtValue . cItem . itLocation . ilInvID
|
invid <- mag ^? ldtValue . _1 . itLocation . ilInvID
|
||||||
return $
|
return $
|
||||||
--(cWorld . lWorld . tempLightSources .:~ tlsTimeRadColPos 1 250 0.7 pos'')
|
--(cWorld . lWorld . tempLightSources .:~ tlsTimeRadColPos 1 250 0.7 pos'')
|
||||||
(cWorld . lWorld . lights .:~ LSParam pos'' 250 0.7)
|
(cWorld . lWorld . lights .:~ LSParam pos'' 250 0.7)
|
||||||
|
|||||||
@@ -44,10 +44,10 @@ data ItemStructuralFunction
|
|||||||
|
|
||||||
type PartiallyComposedItem = (Item, ItemStructuralFunction, LinkTest)
|
type PartiallyComposedItem = (Item, ItemStructuralFunction, LinkTest)
|
||||||
|
|
||||||
data ComposedItem = CItem
|
--data ComposedItem = CItem
|
||||||
{ _cItem :: Item
|
-- { _cItem :: Item
|
||||||
, _cItemFunction :: ItemStructuralFunction
|
-- , _cItemFunction :: ItemStructuralFunction
|
||||||
}
|
-- }
|
||||||
|
|
||||||
data ItemLink = ILink
|
data ItemLink = ILink
|
||||||
{ _iatType :: ComposeLinkType
|
{ _iatType :: ComposeLinkType
|
||||||
@@ -65,10 +65,10 @@ data LinkUpdate = LUpdate
|
|||||||
, _luChildUpdate :: PartiallyComposedItem -> PartiallyComposedItem
|
, _luChildUpdate :: PartiallyComposedItem -> PartiallyComposedItem
|
||||||
}
|
}
|
||||||
|
|
||||||
makeLenses ''ComposedItem
|
--makeLenses ''ComposedItem
|
||||||
makeLenses ''ItemLink
|
makeLenses ''ItemLink
|
||||||
makeLenses ''LinkTest
|
makeLenses ''LinkTest
|
||||||
makeLenses ''LinkUpdate
|
makeLenses ''LinkUpdate
|
||||||
deriveJSON defaultOptions ''ItemStructuralFunction
|
deriveJSON defaultOptions ''ItemStructuralFunction
|
||||||
deriveJSON defaultOptions ''ComposedItem
|
--deriveJSON defaultOptions ''ComposedItem
|
||||||
deriveJSON defaultOptions ''ComposeLinkType
|
deriveJSON defaultOptions ''ComposeLinkType
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ import NewInt
|
|||||||
import Padding
|
import Padding
|
||||||
import Picture.Base
|
import Picture.Base
|
||||||
|
|
||||||
invSelectionItem :: Int -> Creature -> Int -> ComposedItem -> SelectionItem ()
|
invSelectionItem :: Int -> Creature -> Int -> PartiallyComposedItem -> SelectionItem ()
|
||||||
invSelectionItem indent cr i ci =
|
invSelectionItem indent cr i ci =
|
||||||
SelectionItem
|
SelectionItem
|
||||||
{ _siPictures = pics & ix 0 %~ (++ anyequippos ++ anyhotkey)
|
{ _siPictures = pics & ix 0 %~ (++ anyequippos ++ anyhotkey)
|
||||||
, _siHeight = itInvHeight $ _cItem ci
|
, _siHeight = itInvHeight $ ci ^. _1
|
||||||
, _siWidth = 15
|
, _siWidth = 15
|
||||||
, _siIsSelectable = True
|
, _siIsSelectable = True
|
||||||
, _siColor = col
|
, _siColor = col
|
||||||
@@ -82,6 +82,6 @@ closeButtonToSelectionItem w i = do
|
|||||||
|
|
||||||
closeItemToTextPictures :: FloorItem -> ([String], Color)
|
closeItemToTextPictures :: FloorItem -> ([String], Color)
|
||||||
closeItemToTextPictures flit =
|
closeItemToTextPictures flit =
|
||||||
(basicItemDisplay it, itemInvColor . pciToCI $ basePCI it)
|
(basicItemDisplay it, itemInvColor $ basePCI it)
|
||||||
where
|
where
|
||||||
it = _flIt flit
|
it = _flIt flit
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ import Dodge.Data.Creature
|
|||||||
import LensHelp
|
import LensHelp
|
||||||
import Padding
|
import Padding
|
||||||
|
|
||||||
itemDisplay :: Creature -> ComposedItem -> [String]
|
itemDisplay :: Creature -> PartiallyComposedItem -> [String]
|
||||||
itemDisplay cr ci =
|
itemDisplay cr ci =
|
||||||
zipWithDefaults id (leftPad 15 ' ') itemDisplayPad (basicItemDisplay itm) (itemNumberDisplay cr ci)
|
zipWithDefaults id (leftPad 15 ' ') itemDisplayPad (basicItemDisplay itm) (itemNumberDisplay cr ci)
|
||||||
where
|
where
|
||||||
itm = _cItem ci
|
itm = ci ^. _1
|
||||||
|
|
||||||
zipWithDefaults :: (a -> c) -> (b -> c) -> (a -> b -> c) -> [a] -> [b] -> [c]
|
zipWithDefaults :: (a -> c) -> (b -> c) -> (a -> b -> c) -> [a] -> [b] -> [c]
|
||||||
zipWithDefaults f g h = go
|
zipWithDefaults f g h = go
|
||||||
@@ -93,8 +93,8 @@ showAutoRechargeProgress lc = case lc of
|
|||||||
-- where
|
-- where
|
||||||
-- ic = (itm ^?! itUse . heldConsumption . laSource)
|
-- ic = (itm ^?! itUse . heldConsumption . laSource)
|
||||||
|
|
||||||
itemNumberDisplay :: Creature -> ComposedItem -> [String]
|
itemNumberDisplay :: Creature -> PartiallyComposedItem -> [String]
|
||||||
itemNumberDisplay cr ci = case (ci ^. cItemFunction, itm ^?! itUse) of
|
itemNumberDisplay cr ci = case (ci ^. _2, itm ^?! itUse) of
|
||||||
(WeaponTargetingSF,_)
|
(WeaponTargetingSF,_)
|
||||||
-> [maybe "" (const "!TARG!") (itm ^? itTargeting . itTgPos . _Just)]
|
-> [maybe "" (const "!TARG!") (itm ^? itTargeting . itTgPos . _Just)]
|
||||||
(_,UseHeld{}) -> []
|
(_,UseHeld{}) -> []
|
||||||
@@ -108,7 +108,7 @@ itemNumberDisplay cr ci = case (ci ^. cItemFunction, itm ^?! itUse) of
|
|||||||
(_,UseScope OpticScope {_opticZoom = x}) -> [shortShow x]
|
(_,UseScope OpticScope {_opticZoom = x}) -> [shortShow x]
|
||||||
(_,UseBulletMod {}) -> mempty
|
(_,UseBulletMod {}) -> mempty
|
||||||
where
|
where
|
||||||
itm = ci ^. cItem
|
itm = ci ^. _1
|
||||||
|
|
||||||
showEquipmentNumber :: Creature -> Item -> [String]
|
showEquipmentNumber :: Creature -> Item -> [String]
|
||||||
showEquipmentNumber _ itm = case _eeUse ee of
|
showEquipmentNumber _ itm = case _eeUse ee of
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import Dodge.Item.Draw.SPic
|
|||||||
import Dodge.Item.HeldOffset
|
import Dodge.Item.HeldOffset
|
||||||
import ShapePicture
|
import ShapePicture
|
||||||
|
|
||||||
itemEquipPict :: Creature -> LabelDoubleTree ItemLink ComposedItem -> SPic
|
itemEquipPict :: Creature -> LabelDoubleTree ItemLink PartiallyComposedItem -> SPic
|
||||||
itemEquipPict cr itmtree = case itm ^. itUse of
|
itemEquipPict cr itmtree = case itm ^. itUse of
|
||||||
UseHeld{} | itm ^? itLocation . ilIsRoot == Just True
|
UseHeld{} | itm ^? itLocation . ilIsRoot == Just True
|
||||||
&& itm ^? itLocation . ilInvID == cr ^? crManipulation . manObject . imRootSelectedItem
|
&& itm ^? itLocation . ilInvID == cr ^? crManipulation . manObject . imRootSelectedItem
|
||||||
@@ -25,7 +25,7 @@ itemEquipPict cr itmtree = case itm ^. itUse of
|
|||||||
epos <- cr ^? crInvEquipped . ix i
|
epos <- cr ^? crInvEquipped . ix i
|
||||||
return $ equipPosition epos cr attachpos (itemSPic itm)
|
return $ equipPosition epos cr attachpos (itemSPic itm)
|
||||||
where
|
where
|
||||||
itm = itmtree ^. ldtValue . cItem
|
itm = itmtree ^. ldtValue . _1
|
||||||
|
|
||||||
equipPosition :: EquipPosition -> Creature -> Point3 -> SPic -> SPic
|
equipPosition :: EquipPosition -> Creature -> Point3 -> SPic -> SPic
|
||||||
equipPosition epos cr p sh = case epos of
|
equipPosition epos cr p sh = case epos of
|
||||||
|
|||||||
@@ -19,16 +19,17 @@ import Picture
|
|||||||
import Shape
|
import Shape
|
||||||
import ShapePicture
|
import ShapePicture
|
||||||
|
|
||||||
itemTreeSPic :: LabelDoubleTree ItemLink ComposedItem -> SPic
|
itemTreeSPic :: LabelDoubleTree ItemLink PartiallyComposedItem -> SPic
|
||||||
itemTreeSPic (LDT (CItem itm _) l r) =
|
itemTreeSPic (LDT (itm,_,_) l r) =
|
||||||
itemSPic itm
|
itemSPic itm
|
||||||
<> foldMap (itemRotTreeSPic itm) (l <> r)
|
<> foldMap (itemRotTreeSPic itm) (l <> r)
|
||||||
|
|
||||||
itemRotTreeSPic :: Item -> (ItemLink, LabelDoubleTree ItemLink ComposedItem) -> SPic
|
itemRotTreeSPic :: Item -> (ItemLink, LabelDoubleTree ItemLink PartiallyComposedItem)
|
||||||
|
-> SPic
|
||||||
itemRotTreeSPic par (il, t) = translateSP p . overPosSP (Q.rotate q) $ itemTreeSPic t
|
itemRotTreeSPic par (il, t) = translateSP p . overPosSP (Q.rotate q) $ itemTreeSPic t
|
||||||
where
|
where
|
||||||
(p, q) = _iatOrient il par (_iatType il) itm
|
(p, q) = _iatOrient il par (_iatType il) itm
|
||||||
itm = t ^. ldtValue . cItem
|
itm = t ^. ldtValue . _1
|
||||||
|
|
||||||
itemSPic :: Item -> SPic
|
itemSPic :: Item -> SPic
|
||||||
itemSPic it = case it ^. itType of
|
itemSPic it = case it ^. itType of
|
||||||
|
|||||||
+20
-19
@@ -4,7 +4,6 @@ module Dodge.Item.Grammar (
|
|||||||
invAdj,
|
invAdj,
|
||||||
invRootMap,
|
invRootMap,
|
||||||
invRootTrees,
|
invRootTrees,
|
||||||
pciToCI,
|
|
||||||
basePCI,
|
basePCI,
|
||||||
allInvLocs,
|
allInvLocs,
|
||||||
) where
|
) where
|
||||||
@@ -51,9 +50,10 @@ useBreakListsLinkTest llist rlist = LTest ltest rtest
|
|||||||
return $ LUpdate linktype (set _3 (useBreakListsLinkTest llist (tail xs))) id
|
return $ LUpdate linktype (set _3 (useBreakListsLinkTest llist (tail xs))) id
|
||||||
|
|
||||||
itemToBreakLists ::
|
itemToBreakLists ::
|
||||||
ComposedItem ->
|
Item ->
|
||||||
|
ItemStructuralFunction ->
|
||||||
([(ItemStructuralFunction, ComposeLinkType)], [(ItemStructuralFunction, ComposeLinkType)])
|
([(ItemStructuralFunction, ComposeLinkType)], [(ItemStructuralFunction, ComposeLinkType)])
|
||||||
itemToBreakLists ci = case (itm ^. itType, ci ^. cItemFunction) of
|
itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
|
||||||
(HELD TORCH, _) -> (getAmmoLinks itm, [])
|
(HELD TORCH, _) -> (getAmmoLinks itm, [])
|
||||||
(_, WeaponPlatformSF) ->
|
(_, WeaponPlatformSF) ->
|
||||||
( getAmmoLinks itm
|
( getAmmoLinks itm
|
||||||
@@ -75,8 +75,6 @@ itemToBreakLists ci = case (itm ^. itType, ci ^. cItemFunction) of
|
|||||||
(ATTACH BULLETSYNTH, _)
|
(ATTACH BULLETSYNTH, _)
|
||||||
-> ([(AmmoMagSF ElectricalAmmo, AmmoInLink 0 ElectricalAmmo)],[])
|
-> ([(AmmoMagSF ElectricalAmmo, AmmoInLink 0 ElectricalAmmo)],[])
|
||||||
_ -> ([], [])
|
_ -> ([], [])
|
||||||
where
|
|
||||||
itm = ci ^. cItem
|
|
||||||
|
|
||||||
getAmmoLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
|
getAmmoLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
|
||||||
getAmmoLinks itm =
|
getAmmoLinks itm =
|
||||||
@@ -102,9 +100,6 @@ itemToFunction itm = case itm ^. itType of
|
|||||||
EQUIP{} -> EquipmentPlatformSF
|
EQUIP{} -> EquipmentPlatformSF
|
||||||
_ -> UncomposableIsolateSF
|
_ -> UncomposableIsolateSF
|
||||||
|
|
||||||
pciToCI :: PartiallyComposedItem -> ComposedItem
|
|
||||||
pciToCI (x, y, _) = CItem x y
|
|
||||||
|
|
||||||
basePCI :: Item -> PartiallyComposedItem
|
basePCI :: Item -> PartiallyComposedItem
|
||||||
basePCI itm = case _itType itm of
|
basePCI itm = case _itType itm of
|
||||||
_ -> (itm, itemToFunction itm, itemBaseConnections itm)
|
_ -> (itm, itemToFunction itm, itemBaseConnections itm)
|
||||||
@@ -112,7 +107,7 @@ basePCI itm = case _itType itm of
|
|||||||
itemBaseConnections :: Item -> LinkTest
|
itemBaseConnections :: Item -> LinkTest
|
||||||
itemBaseConnections itm = case _itType itm of
|
itemBaseConnections itm = case _itType itm of
|
||||||
HELD LASER -> laserLinkTest itm
|
HELD LASER -> laserLinkTest itm
|
||||||
_ -> uncurry useBreakL $ itemToBreakLists (CItem itm (itemToFunction itm))
|
_ -> uncurry useBreakL $ itemToBreakLists itm (itemToFunction itm)
|
||||||
|
|
||||||
laserLinkTest :: Item -> LinkTest
|
laserLinkTest :: Item -> LinkTest
|
||||||
laserLinkTest itm = LTest (llleft itm) (llright itm)
|
laserLinkTest itm = LTest (llleft itm) (llright itm)
|
||||||
@@ -121,19 +116,18 @@ llleft :: Item -> PartiallyComposedItem -> Maybe LinkUpdate
|
|||||||
llleft itm =
|
llleft itm =
|
||||||
_tryLeftLink
|
_tryLeftLink
|
||||||
. uncurry useBreakL
|
. uncurry useBreakL
|
||||||
. itemToBreakLists
|
$ itemToBreakLists itm WeaponTargetingSF
|
||||||
$ CItem itm WeaponTargetingSF
|
|
||||||
|
|
||||||
llright :: Item -> PartiallyComposedItem -> Maybe LinkUpdate
|
llright :: Item -> PartiallyComposedItem -> Maybe LinkUpdate
|
||||||
llright itm pci = case pci ^. _1 . itType of
|
llright itm pci = case pci ^. _1 . itType of
|
||||||
CRAFT TRANSFORMER -> Just (toLasgunUpdate itm)
|
CRAFT TRANSFORMER -> Just (toLasgunUpdate itm)
|
||||||
_ -> _tryRightLink (uncurry useBreakL $ itemToBreakLists (CItem itm WeaponTargetingSF)) pci
|
_ -> _tryRightLink (uncurry useBreakL $ itemToBreakLists itm WeaponTargetingSF) pci
|
||||||
|
|
||||||
toLasgunUpdate :: Item -> LinkUpdate
|
toLasgunUpdate :: Item -> LinkUpdate
|
||||||
toLasgunUpdate itm =
|
toLasgunUpdate itm =
|
||||||
LUpdate
|
LUpdate
|
||||||
(ILink FunctionChangeLink orientAttachment)
|
(ILink FunctionChangeLink orientAttachment)
|
||||||
(\(par, _, _) -> (par, WeaponPlatformSF, uncurry useBreakL $ itemToBreakLists (CItem itm WeaponPlatformSF)))
|
(\(par, _, _) -> (par, WeaponPlatformSF, uncurry useBreakL $ itemToBreakLists itm WeaponPlatformSF))
|
||||||
(\(chi, _, up) -> (chi, FunctionChangeSF, up))
|
(\(chi, _, up) -> (chi, FunctionChangeSF, up))
|
||||||
|
|
||||||
--itemLinkTestLeft :: Item -> PartiallyComposedItem -> Maybe LinkUpdate
|
--itemLinkTestLeft :: Item -> PartiallyComposedItem -> Maybe LinkUpdate
|
||||||
@@ -221,16 +215,23 @@ invTrees' = IM.unions . map (ldtToIM getindex . fmap (^. _1)) . map (fmap (\(x,
|
|||||||
i ^? itLocation . ilInvID
|
i ^? itLocation . ilInvID
|
||||||
|
|
||||||
-- returns an intmap with trees for (only!) root items, indexed by inventory position
|
-- returns an intmap with trees for (only!) root items, indexed by inventory position
|
||||||
invRootTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ItemLink ComposedItem)
|
invRootTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ItemLink PartiallyComposedItem)
|
||||||
invRootTrees = IM.fromDistinctAscList . reverse . map (getid . fmap (\(x, y, _) -> CItem x y)) . invLDT
|
invRootTrees = IM.fromDistinctAscList . reverse . map (getid) . invLDT
|
||||||
where
|
where
|
||||||
getid :: LabelDoubleTree ItemLink ComposedItem -> (Int, LabelDoubleTree ItemLink ComposedItem)
|
getid :: LabelDoubleTree ItemLink PartiallyComposedItem
|
||||||
getid t = (t ^?! ldtValue . cItem . itLocation . ilInvID, t)
|
-> (Int, LabelDoubleTree ItemLink PartiallyComposedItem)
|
||||||
|
getid t = (t ^?! ldtValue . _1 . itLocation . ilInvID, t)
|
||||||
|
|
||||||
-- returns an intmap with indents and locations for all items
|
-- returns an intmap with indents and locations for all items
|
||||||
allInvLocs :: IM.IntMap Item -> IM.IntMap (Int, LocationLDT ItemLink ComposedItem)
|
allInvLocs :: IM.IntMap Item -> IM.IntMap (Int, LocationLDT ItemLink PartiallyComposedItem)
|
||||||
allInvLocs inv = foldMap (f . LocLDT TopLDT) (IM.elems (invRootTrees inv)) mempty
|
allInvLocs inv = foldMap (f . LocLDT TopLDT) (IM.elems (invRootTrees inv)) mempty
|
||||||
where
|
where
|
||||||
f t = cldtPropagateFold h h g 0 t id
|
f t = cldtPropagateFold h h g 0 t id
|
||||||
h x _ _ _ = x + 1
|
h x _ _ _ = x + 1
|
||||||
g x ldt = (.) (IM.insert (ldt ^?! locLDT . ldtValue . cItem . itLocation . ilInvID) (x, ldt))
|
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 x ldt = (.) (IM.insert (ldt ^?! locLDT . ldtValue . _1 . itLocation . ilInvID)
|
||||||
|
(x, ldt))
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import Color
|
|||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Dodge.Data.ComposedItem
|
import Dodge.Data.ComposedItem
|
||||||
|
|
||||||
itemInvColor :: ComposedItem -> Color
|
itemInvColor :: PartiallyComposedItem -> Color
|
||||||
itemInvColor ci = case ci ^. cItemFunction of
|
itemInvColor ci = case ci ^. _2 of
|
||||||
WeaponPlatformSF -> white
|
WeaponPlatformSF -> white
|
||||||
EquipmentPlatformSF -> yellow
|
EquipmentPlatformSF -> yellow
|
||||||
WeaponScopeSF -> chartreuse
|
WeaponScopeSF -> chartreuse
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ getRootItemBounds i inv = do
|
|||||||
let ia = allInvLocs inv
|
let ia = allInvLocs inv
|
||||||
itm <- ia ^? ix i . _2
|
itm <- ia ^? ix i . _2
|
||||||
let root = locToTop itm
|
let root = locToTop itm
|
||||||
x <- locRightmost root ^? locLDT . ldtValue . cItem . itLocation . ilInvID
|
x <- locRightmost root ^? locLDT . ldtValue . _1 . itLocation . ilInvID
|
||||||
y <- locLeftmost root ^? locLDT . ldtValue . cItem . itLocation . ilInvID
|
y <- locLeftmost root ^? locLDT . ldtValue . _1 . itLocation . ilInvID
|
||||||
return (x, y)
|
return (x, y)
|
||||||
|
|
||||||
drawMouseOver :: Configuration -> World -> Picture
|
drawMouseOver :: Configuration -> World -> Picture
|
||||||
|
|||||||
Reference in New Issue
Block a user