|
|
|
@@ -29,14 +29,14 @@ import LensHelp
|
|
|
|
|
import ListHelp
|
|
|
|
|
|
|
|
|
|
tryAttachItems ::
|
|
|
|
|
LabelDoubleTree ItemLink ComposedItem ->
|
|
|
|
|
LabelDoubleTree ItemLink ComposedItem ->
|
|
|
|
|
Maybe (LabelDoubleTree ItemLink ComposedItem)
|
|
|
|
|
LabelDoubleTree ItemLink CItem ->
|
|
|
|
|
LabelDoubleTree ItemLink CItem ->
|
|
|
|
|
Maybe (LabelDoubleTree ItemLink CItem)
|
|
|
|
|
tryAttachItems = leftRightCombine leftIsParentCombine rightIsParentCombine
|
|
|
|
|
|
|
|
|
|
useBreakL ::
|
|
|
|
|
[(ItemStructuralFunction, ComposeLinkType)] ->
|
|
|
|
|
[(ItemStructuralFunction, ComposeLinkType)] ->
|
|
|
|
|
[(ItemStructuralFunction, CLinkType)] ->
|
|
|
|
|
[(ItemStructuralFunction, CLinkType)] ->
|
|
|
|
|
LinkTest
|
|
|
|
|
useBreakL x y = useBreakListsLinkTest (map (uncurry noa) x) (map (uncurry noa) y)
|
|
|
|
|
where
|
|
|
|
@@ -68,7 +68,7 @@ useBreakListsLinkTest llist rlist = LTest ltest rtest
|
|
|
|
|
itemToBreakLists ::
|
|
|
|
|
Item ->
|
|
|
|
|
ItemStructuralFunction ->
|
|
|
|
|
([(ItemStructuralFunction, ComposeLinkType)], [(ItemStructuralFunction, ComposeLinkType)])
|
|
|
|
|
([(ItemStructuralFunction, CLinkType)], [(ItemStructuralFunction, CLinkType)])
|
|
|
|
|
itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
|
|
|
|
|
(HELD TORCH, _) -> (getAmmoLinks itm, [])
|
|
|
|
|
(ATTACH UNDERBARRELSLOT, _) -> ([(UnderBarrelPlatformSF, UnderBarrelPlatformLink)], [])
|
|
|
|
@@ -118,12 +118,12 @@ itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
|
|
|
|
|
([(AmmoMagSF ElectricalAmmo, AmmoInLink 0 ElectricalAmmo)], [])
|
|
|
|
|
_ -> ([], [])
|
|
|
|
|
|
|
|
|
|
getAutoSpringLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
|
|
|
|
|
getAutoSpringLinks :: Item -> [(ItemStructuralFunction, CLinkType)]
|
|
|
|
|
getAutoSpringLinks itm = case baseTriggerType itm of
|
|
|
|
|
HammerTrigger -> [(MakeAutoSF, MakeAutoLink)]
|
|
|
|
|
_ -> []
|
|
|
|
|
|
|
|
|
|
extraWeaponLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
|
|
|
|
|
extraWeaponLinks :: Item -> [(ItemStructuralFunction, CLinkType)]
|
|
|
|
|
extraWeaponLinks itm = case itm ^. itType of
|
|
|
|
|
HELD GLAUNCHER -> launcherlinks <> [(GrenadeHitEffectSF,GrenadeHitEffectLink)]
|
|
|
|
|
HELD RLAUNCHER -> launcherlinks
|
|
|
|
@@ -132,14 +132,14 @@ extraWeaponLinks itm = case itm ^. itType of
|
|
|
|
|
where
|
|
|
|
|
launcherlinks = [(ProjectileStabiliserSF,ProjectileStabiliserLink)]
|
|
|
|
|
|
|
|
|
|
extraWeaponLinksBelow :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
|
|
|
|
|
extraWeaponLinksBelow :: Item -> [(ItemStructuralFunction, CLinkType)]
|
|
|
|
|
extraWeaponLinksBelow itm
|
|
|
|
|
-- | Just TwoHandUnder <- itm ^? itUse . heldAim . aimStance
|
|
|
|
|
| TwoHandUnder <- aStance itm
|
|
|
|
|
= [(UnderBarrelSlotSF,UnderBarrelSlotLink)]
|
|
|
|
|
| otherwise = []
|
|
|
|
|
|
|
|
|
|
getAmmoLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
|
|
|
|
|
getAmmoLinks :: Item -> [(ItemStructuralFunction, CLinkType)]
|
|
|
|
|
getAmmoLinks itm =
|
|
|
|
|
map
|
|
|
|
|
(\(i, a) -> (AmmoMagSF a, AmmoInLink i a))
|
|
|
|
@@ -181,7 +181,7 @@ itemToFunction itm = case itm ^. itType of
|
|
|
|
|
_ -> NoSF
|
|
|
|
|
|
|
|
|
|
structureToPotentialFunction ::
|
|
|
|
|
LabelDoubleTree ItemLink ComposedItem ->
|
|
|
|
|
LabelDoubleTree ItemLink CItem ->
|
|
|
|
|
S.Set ItemStructuralFunction
|
|
|
|
|
structureToPotentialFunction ldt = case ldt ^. ldtValue . _1 . itType of
|
|
|
|
|
STICKYMOD -> S.singleton GrenadeHitEffectSF
|
|
|
|
@@ -190,7 +190,7 @@ structureToPotentialFunction ldt = case ldt ^. ldtValue . _1 . itType of
|
|
|
|
|
HELD GLAUNCHER -> S.singleton UnderBarrelPlatformSF
|
|
|
|
|
_ -> S.singleton (ldt ^. ldtValue . _2)
|
|
|
|
|
|
|
|
|
|
baseCI :: Item -> ComposedItem
|
|
|
|
|
baseCI :: Item -> CItem
|
|
|
|
|
baseCI itm = (itm, itemToFunction itm, itemBaseConnections itm)
|
|
|
|
|
|
|
|
|
|
itemBaseConnections :: Item -> LinkTest
|
|
|
|
@@ -202,13 +202,13 @@ itemBaseConnections itm = case _itType itm of
|
|
|
|
|
laserLinkTest :: Item -> LinkTest
|
|
|
|
|
laserLinkTest itm = LTest (llleft itm) (llright itm)
|
|
|
|
|
|
|
|
|
|
llleft :: Item -> LabelDoubleTree ItemLink ComposedItem -> Maybe LinkUpdate
|
|
|
|
|
llleft :: Item -> LabelDoubleTree ItemLink CItem -> Maybe LinkUpdate
|
|
|
|
|
llleft itm =
|
|
|
|
|
_tryLeftLink
|
|
|
|
|
. uncurry useBreakL
|
|
|
|
|
$ itemToBreakLists itm WeaponTargetingSF
|
|
|
|
|
|
|
|
|
|
llright :: Item -> LabelDoubleTree ItemLink ComposedItem -> Maybe LinkUpdate
|
|
|
|
|
llright :: Item -> LabelDoubleTree ItemLink CItem -> Maybe LinkUpdate
|
|
|
|
|
llright itm pci = case pci ^. ldtValue . _1 . itType of
|
|
|
|
|
CRAFT TRANSFORMER -> Just (toLasgunUpdate itm)
|
|
|
|
|
_ -> _tryRightLink (uncurry useBreakL $ itemToBreakLists itm WeaponTargetingSF) pci
|
|
|
|
@@ -232,20 +232,20 @@ springLinkTest = LTest (const Nothing) $
|
|
|
|
|
)
|
|
|
|
|
_ -> Nothing
|
|
|
|
|
|
|
|
|
|
--itemLinkTestLeft :: Item -> PartiallyComposedItem -> Maybe LinkUpdate
|
|
|
|
|
--itemLinkTestLeft :: Item -> PartiallyCItem -> Maybe LinkUpdate
|
|
|
|
|
--itemLinkTestLeft itm = _tryLeftLink $
|
|
|
|
|
-- uncurry useBreakL $ itemToBreakLists itm
|
|
|
|
|
|
|
|
|
|
type LDTComb a b = LabelDoubleTree b a -> LabelDoubleTree b a -> Maybe (LabelDoubleTree b a)
|
|
|
|
|
|
|
|
|
|
leftIsParentCombine :: LDTComb ComposedItem ItemLink
|
|
|
|
|
leftIsParentCombine :: LDTComb CItem ItemLink
|
|
|
|
|
leftIsParentCombine ltree rtree = do
|
|
|
|
|
lu <- (ltree ^. ldtValue . _3 . tryRightLink) rtree --(rtree ^. ldtValue)
|
|
|
|
|
return $
|
|
|
|
|
ltree & ldtValue %~ (lu ^. luParentUpdate)
|
|
|
|
|
& ldtRight %~ (++ [(lu ^. luLinkType, rtree & ldtValue %~ (lu ^. luChildUpdate))])
|
|
|
|
|
|
|
|
|
|
rightIsParentCombine :: LDTComb ComposedItem ItemLink
|
|
|
|
|
rightIsParentCombine :: LDTComb CItem ItemLink
|
|
|
|
|
rightIsParentCombine ltree rtree = do
|
|
|
|
|
lu <- (rtree ^. ldtValue . _3 . tryLeftLink) ltree -- (ltree ^. ldtValue)
|
|
|
|
|
return $
|
|
|
|
@@ -276,7 +276,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 ComposedItem]
|
|
|
|
|
invLDT :: IM.IntMap Item -> [LabelDoubleTree ItemLink CItem]
|
|
|
|
|
invLDT =
|
|
|
|
|
joinItemsInList tryAttachItems . IM.elems
|
|
|
|
|
. fmap (singleLDT . baseCI)
|
|
|
|
@@ -306,28 +306,28 @@ invAdj = IM.unions . map g . invLDT
|
|
|
|
|
$ itm ^? itLocation . ilInvID
|
|
|
|
|
|
|
|
|
|
-- 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 CItem)
|
|
|
|
|
invRootTrees = IM.fromDistinctAscList . reverse . map getid . invLDT
|
|
|
|
|
where
|
|
|
|
|
getid ::
|
|
|
|
|
LabelDoubleTree ItemLink ComposedItem ->
|
|
|
|
|
(Int, LabelDoubleTree ItemLink ComposedItem)
|
|
|
|
|
LabelDoubleTree ItemLink CItem ->
|
|
|
|
|
(Int, LabelDoubleTree ItemLink CItem)
|
|
|
|
|
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 ComposedItem)
|
|
|
|
|
allInvLocs :: IM.IntMap Item -> IM.IntMap (Int, LocationLDT ItemLink CItem)
|
|
|
|
|
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 ComposedItem ->
|
|
|
|
|
( IM.IntMap (Int, LocationLDT ItemLink ComposedItem) ->
|
|
|
|
|
IM.IntMap (Int, LocationLDT ItemLink ComposedItem)
|
|
|
|
|
LocationLDT ItemLink CItem ->
|
|
|
|
|
( IM.IntMap (Int, LocationLDT ItemLink CItem) ->
|
|
|
|
|
IM.IntMap (Int, LocationLDT ItemLink CItem)
|
|
|
|
|
) ->
|
|
|
|
|
IM.IntMap (Int, LocationLDT ItemLink ComposedItem) ->
|
|
|
|
|
IM.IntMap (Int, LocationLDT ItemLink ComposedItem)
|
|
|
|
|
IM.IntMap (Int, LocationLDT ItemLink CItem) ->
|
|
|
|
|
IM.IntMap (Int, LocationLDT ItemLink CItem)
|
|
|
|
|
g x ldt =
|
|
|
|
|
(.)
|
|
|
|
|
( IM.insert
|
|
|
|
|