Use constructed laser as targeting scope
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
module Dodge.Item.Grammar (
|
||||
invLDT,
|
||||
invTrees,
|
||||
invIndentIM,
|
||||
invAdj,
|
||||
invRootMap,
|
||||
invRootTrees,
|
||||
@@ -89,7 +88,7 @@ pciToCI (x,y,_) = CItem x y
|
||||
|
||||
basePCI :: Item -> PartiallyComposedItem
|
||||
basePCI itm = case _itType itm of
|
||||
HELD LASGUN -> (itm, WeaponScopeSF, laserLinkTest itm)
|
||||
HELD LASER -> (itm, WeaponTargetingSF, laserLinkTest itm)
|
||||
_ -> (itm, itemToFunction itm, uncurry useBreakL $ itemToBreakLists itm)
|
||||
|
||||
laserLinkTest :: Item -> LinkTest
|
||||
@@ -181,13 +180,6 @@ invAdj im = do
|
||||
Right
|
||||
$ itm ^? itLocation . ilInvID
|
||||
|
||||
invIndentIM :: IM.IntMap Item -> IM.IntMap (Item, Int, LabelDoubleTreeNodeType ComposeLinkType)
|
||||
invIndentIM =
|
||||
IM.fromDistinctAscList . zip [0 ..] . reverse . map (over _1 (^. _1))
|
||||
. concatMap ldtToIndentList
|
||||
. map (bimap _iatType (\(x, y, _) -> (x, y)))
|
||||
. invLDT
|
||||
|
||||
-- returns an intmap with trees for all items
|
||||
invTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ComposeLinkType Item)
|
||||
invTrees = fmap (first _iatType) . invTrees'
|
||||
@@ -200,23 +192,17 @@ invTrees' = IM.unions . map (ldtToIM getindex . fmap (^. _1)) . map (fmap (\(x,
|
||||
fromMaybe (error "in invTrees try to get non-inventory item tree") $
|
||||
i ^? itLocation . ilInvID
|
||||
|
||||
-- returns an intmap with trees for all items
|
||||
--invTrees'' :: IM.IntMap Item -> [LocationLDT ItemLink ComposedItem]
|
||||
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 x ldt = (.) (IM.insert (ldt ^?! locLDT . ldtValue . cItem . itLocation . ilInvID) (x,ldt))
|
||||
--invTrees'' = IM.unions . map (f . LocLDT TopLDT) . IM.elems . invRootTrees
|
||||
-- where
|
||||
-- f t = cldtPropagateFold h h g 0 t mempty
|
||||
-- h x _ _ _ = x + 1
|
||||
-- g x ldt = IM.insert (ldt ^?! locLDT . ldtValue . cItem . itLocation . ilInvID) (x,ldt)
|
||||
|
||||
-- returns an intmap with trees for root items, indexed by inventory position
|
||||
invRootTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ItemLink ComposedItem)
|
||||
invRootTrees = IM.fromDistinctAscList . reverse . map (getid . fmap (\(x, y, _) -> CItem x y)) . invLDT
|
||||
where
|
||||
getid :: LabelDoubleTree ItemLink ComposedItem -> (Int,LabelDoubleTree ItemLink ComposedItem)
|
||||
getid t = (t ^?! ldtValue . cItem . itLocation . ilInvID, t)
|
||||
|
||||
-- returns an intmap with indents and locations for all items
|
||||
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 x ldt = (.) (IM.insert (ldt ^?! locLDT . ldtValue . cItem . itLocation . ilInvID) (x,ldt))
|
||||
|
||||
Reference in New Issue
Block a user