Use item function in determining attachments
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
All good (597 modules, at 16:02:38)
|
||||
All good (597 modules, at 16:43:58)
|
||||
|
||||
+16
-12
@@ -9,11 +9,11 @@ module Dodge.Item.Grammar (
|
||||
allInvLocs,
|
||||
) where
|
||||
|
||||
import Dodge.Data.ComposedItem
|
||||
import Control.Applicative
|
||||
import Data.Bifunctor
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Data.Maybe
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.Data.DoubleTree
|
||||
import Dodge.Data.Item
|
||||
import Dodge.DoubleTree
|
||||
@@ -41,15 +41,17 @@ useBreakListsLinkTest llist rlist = LTest ltest rtest
|
||||
(_, linktype) <- safeHead xs
|
||||
return $ LUpdate linktype (set _3 (useBreakListsLinkTest llist (tail xs))) id
|
||||
|
||||
itemToBreakLists :: Item
|
||||
itemToBreakLists
|
||||
:: ComposedItem
|
||||
-> ([(ItemStructuralFunction, ComposeLinkType)] , [(ItemStructuralFunction, ComposeLinkType)])
|
||||
itemToBreakLists itm = case itm ^. itType of
|
||||
HELD TORCH -> (getAmmoLinks itm,[])
|
||||
HELD {} ->
|
||||
itemToBreakLists ci = case (itm ^. itType,ci ^. cItemFunction) of
|
||||
-- HELD TORCH -> (getAmmoLinks itm,[])
|
||||
(_,WeaponPlatformSF) ->
|
||||
( getAmmoLinks itm
|
||||
, [(WeaponTargetingSF,WeaponTargetingLink), (WeaponScopeSF,WeaponScopeLink)]
|
||||
)
|
||||
AMMOMAG {} -> fromMaybe ([],[]) $ do
|
||||
-- AMMOMAG {} -> fromMaybe ([],[]) $ do
|
||||
(_,AmmoMagSF {}) -> fromMaybe ([],[]) $ do
|
||||
atype <- itm ^? itUse . amagType
|
||||
return
|
||||
([ (AmmoModifierSF atype, AmmoModLink)
|
||||
@@ -58,9 +60,11 @@ itemToBreakLists itm = case itm ^. itType of
|
||||
, (AmmoEffectSF atype, AmmoEffectLink)
|
||||
, (RemoteScreenSF, RemoteScreenLink)
|
||||
],[])
|
||||
TARGETING TARGETLASER -> (getAmmoLinks itm ++ [(AugmentedHUDSF,AugmentedHUDLink)],[])
|
||||
TARGETING{} -> ([(AugmentedHUDSF,AugmentedHUDLink)],[])
|
||||
(_,WeaponTargetingSF) -> (getAmmoLinks itm ++ [(AugmentedHUDSF,AugmentedHUDLink)],[])
|
||||
-- TARGETING{} -> ([(AugmentedHUDSF,AugmentedHUDLink)],[])
|
||||
_ -> ([],[])
|
||||
where
|
||||
itm = ci ^. cItem
|
||||
|
||||
getAmmoLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
|
||||
getAmmoLinks itm = map
|
||||
@@ -89,22 +93,22 @@ pciToCI (x,y,_) = CItem x y
|
||||
basePCI :: Item -> PartiallyComposedItem
|
||||
basePCI itm = case _itType itm of
|
||||
HELD LASER -> (itm, WeaponTargetingSF, laserLinkTest itm)
|
||||
_ -> (itm, itemToFunction itm, uncurry useBreakL $ itemToBreakLists itm)
|
||||
_ -> (itm, itemToFunction itm, uncurry useBreakL $ itemToBreakLists (CItem itm (itemToFunction itm)))
|
||||
|
||||
laserLinkTest :: Item -> LinkTest
|
||||
laserLinkTest itm = LTest (llleft itm) (llright itm)
|
||||
|
||||
llleft :: Item -> PartiallyComposedItem -> Maybe LinkUpdate
|
||||
llleft itm pci = _tryLeftLink (uncurry useBreakL $ itemToBreakLists itm) pci
|
||||
llleft itm pci = _tryLeftLink (uncurry useBreakL $ itemToBreakLists (CItem itm (itemToFunction itm))) pci
|
||||
|
||||
llright :: Item -> PartiallyComposedItem -> Maybe LinkUpdate
|
||||
llright itm pci = case pci ^. _1 . itType of
|
||||
CRAFT TRANSFORMER -> Just (toLasgunUpdate itm)
|
||||
_ -> _tryRightLink (uncurry useBreakL $ itemToBreakLists itm) pci
|
||||
_ -> _tryRightLink (uncurry useBreakL $ itemToBreakLists (CItem itm (itemToFunction itm))) pci
|
||||
|
||||
toLasgunUpdate :: Item -> LinkUpdate
|
||||
toLasgunUpdate itm = LUpdate (ILink FunctionChangeLink orientAttachment)
|
||||
(\(par,_,_) -> (par,WeaponPlatformSF,uncurry useBreakL $ itemToBreakLists itm))
|
||||
(\(par,_,_) -> (par,WeaponPlatformSF,uncurry useBreakL $ itemToBreakLists (CItem itm WeaponPlatformSF)))
|
||||
(\(chi,_,up) -> (chi,FunctionChangeSF,up))
|
||||
|
||||
--itemLinkTestLeft :: Item -> PartiallyComposedItem -> Maybe LinkUpdate
|
||||
|
||||
Reference in New Issue
Block a user