Move towards removing functionality associated with ItemLinks
This commit is contained in:
@@ -293,7 +293,8 @@ drawARHUD (LocLDT con _) w = fromMaybe w $ do
|
||||
shineTargetLaser :: Creature -> LocationLDT ItemLink OItem -> World -> World
|
||||
shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
|
||||
guard (crIsAiming cr)
|
||||
(_, mag) <- find (isammolink . fst) (itmtree ^. ldtLeft)
|
||||
-- (_, mag) <- find (isammolink . fst) (itmtree ^. ldtLeft)
|
||||
(_, mag) <- find (isammolink . (^. _2 . ldtValue . _2)) (itmtree ^. ldtLeft)
|
||||
i <- mag ^. ldtValue . _1 . itConsumables
|
||||
guard $ i >= x
|
||||
maginvid <- mag ^? ldtValue . _1 . itLocation . ilInvID
|
||||
@@ -319,7 +320,7 @@ shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ d
|
||||
itmtree = loc ^. locLDT
|
||||
(p, q) = o `Q.comp` (V3 5 0 0, Q.qID)
|
||||
x = 1
|
||||
isammolink AmmoInLink{} = True
|
||||
isammolink AmmoMagSF{} = True
|
||||
isammolink _ = False
|
||||
pos = _crPos cr + xyV3 (rotate3 cdir p)
|
||||
cdir = _crDir cr
|
||||
@@ -331,7 +332,7 @@ shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ d
|
||||
|
||||
shineTorch :: Creature -> LocationLDT ItemLink OItem -> World -> World
|
||||
shineTorch cr loc = fromMaybe id $ do
|
||||
(_, mag) <- find (isammolink . fst) (itmtree ^. ldtLeft)
|
||||
(_, mag) <- find (isammolink . (^. _2 . ldtValue . _2)) (itmtree ^. ldtLeft)
|
||||
i <- mag ^. ldtValue . _1 . itConsumables
|
||||
guard $ crIsAiming cr
|
||||
guard $ i >= x
|
||||
@@ -343,7 +344,7 @@ shineTorch cr loc = fromMaybe id $ do
|
||||
itmtree = loc ^. locLDT
|
||||
(p, q) = locOrient (locLDTToLocDT loc) cr
|
||||
x = 10
|
||||
isammolink AmmoInLink{} = True
|
||||
isammolink AmmoMagSF{} = True
|
||||
isammolink _ = False
|
||||
pos = _crPos cr `v2z` 0 + rotate3 cdir (p + Q.rotate q (V3 8 0 1.5))
|
||||
cdir = _crDir cr
|
||||
|
||||
@@ -46,7 +46,7 @@ data ItemStructuralFunction
|
||||
| IntroScanSF
|
||||
| TriggerSF
|
||||
| ARHUDSF
|
||||
| AmmoMagSF AmmoType
|
||||
| AmmoMagSF Int AmmoType
|
||||
| RemoteScreenSF
|
||||
| JoystickSF
|
||||
| RemoteDetonatorSF
|
||||
|
||||
@@ -99,7 +99,7 @@ hammerCheck f pt loc cr w = case itemTriggerType loc of
|
||||
& randGen .~ gen
|
||||
HammerTrigger t
|
||||
| w ^. cWorld . lWorld . lClock - t > timelastused
|
||||
, isNothing $ lookup MakeAutoLink (tree ^. ldtRight)
|
||||
-- , isNothing $ lookup MakeAutoLink (tree ^. ldtRight)
|
||||
, pt == InitialPress ->
|
||||
f loc cr w
|
||||
AutoTrigger t
|
||||
@@ -675,7 +675,7 @@ loadMuzzle t@(LDT _ l _) mz = fromMaybe (t, Nothing) $ do
|
||||
-- guard $ mz ^? mzFrame == t ^? ldtValue . itUse . heldFrame
|
||||
let as = _mzAmmoSlot mz
|
||||
amamount = _mzAmmoPerShot mz
|
||||
(i, (_, mag)) <- findWithIx (isAmmoIntLink as . fst) l
|
||||
(i, (_, mag)) <- findWithIx (isAmmoIntLink as . (^. _2 . ldtValue . _2)) l
|
||||
availableammo <- mag ^. ldtValue . _1 . itConsumables
|
||||
let usedammo = case amamount of
|
||||
UseUpTo x -> min x availableammo
|
||||
@@ -754,8 +754,8 @@ basicMuzFlare pos dir =
|
||||
. muzFlareAt (V4 10 10 1 3) (pos `v2z` 20) dir
|
||||
. muzFlareAt (V4 10 10 1 3) (pos `v2z` 20) dir
|
||||
|
||||
isAmmoIntLink :: Int -> ItemLink -> Bool
|
||||
isAmmoIntLink i (AmmoInLink j _) = i == j
|
||||
isAmmoIntLink :: Int -> ItemStructuralFunction -> Bool
|
||||
isAmmoIntLink i (AmmoMagSF j _) = i == j
|
||||
isAmmoIntLink _ _ = False
|
||||
|
||||
useLoadedAmmo ::
|
||||
|
||||
+39
-28
@@ -57,13 +57,22 @@ itemToBreakLists ::
|
||||
Item ->
|
||||
ItemStructuralFunction ->
|
||||
([(ItemStructuralFunction, ItemLink)], [(ItemStructuralFunction, ItemLink)])
|
||||
itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
|
||||
itemToBreakLists itm itmf = (fmap f l, fmap f r)
|
||||
where
|
||||
f x = (x, SFLink x)
|
||||
(l,r) = itemToBreakLists' itm itmf
|
||||
|
||||
itemToBreakLists' ::
|
||||
Item ->
|
||||
ItemStructuralFunction ->
|
||||
([(ItemStructuralFunction)], [(ItemStructuralFunction)])
|
||||
itemToBreakLists' itm itmf = case (itm ^. itType, itmf) of
|
||||
(HELD TORCH, _) -> (getAmmoLinks itm, [])
|
||||
(ATTACH UNDERBARRELSLOT, _) -> ([(UnderBarrelPlatformSF, UnderBarrelPlatformLink)], [])
|
||||
(ATTACH UNDERBARRELSLOT, _) -> ([(UnderBarrelPlatformSF)], [])
|
||||
(_, HeldPlatformSF) ->
|
||||
( getAmmoLinks itm
|
||||
<> extraWeaponLinksBelow itm
|
||||
, [(WeaponTargetingSF, WeaponTargetingLink), (WeaponScopeSF, WeaponScopeLink)]
|
||||
, [(WeaponTargetingSF), (WeaponScopeSF)]
|
||||
<> getAutoSpringLinks itm
|
||||
<> extraWeaponLinks itm
|
||||
)
|
||||
@@ -71,69 +80,69 @@ itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
|
||||
( getAmmoLinks itm,[])
|
||||
(DETECTOR {}, _) ->
|
||||
( getAmmoLinks itm
|
||||
, [(ARHUDSF,SFLink ARHUDSF),(TriggerSF, TriggerLink),(MapperSF,SFLink MapperSF)]
|
||||
, [(ARHUDSF),(TriggerSF),(MapperSF)]
|
||||
)
|
||||
(CRAFT TRANSFORMER, _) -> ([],[(LaserWeaponSF,SFLink LaserWeaponSF)])
|
||||
(CRAFT TRANSFORMER, _) -> ([],[(LaserWeaponSF)])
|
||||
(MAPPER, _) ->
|
||||
( []
|
||||
, [(ARHUDSF,SFLink ARHUDSF)]
|
||||
, [(ARHUDSF)]
|
||||
)
|
||||
(_, GadgetPlatformSF) ->
|
||||
( getAmmoLinks itm
|
||||
, [(TriggerSF, TriggerLink), (WeaponTargetingSF, WeaponTargetingLink), (WeaponScopeSF, WeaponScopeLink)]
|
||||
, [(TriggerSF), (WeaponTargetingSF), (WeaponScopeSF)]
|
||||
)
|
||||
(_, AmmoMagSF{}) -> fromMaybe ([], []) $ do
|
||||
atype <- magAmmoType itm
|
||||
let screenanddet = case atype of
|
||||
LauncherAmmo ->
|
||||
[ (RemoteScreenSF, RemoteScreenLink)
|
||||
, (RemoteDetonatorSF, RemoteDetonatorLink)
|
||||
[ (RemoteScreenSF)
|
||||
, (RemoteDetonatorSF)
|
||||
]
|
||||
_ -> []
|
||||
return
|
||||
( [ (AmmoModifierSF atype, AmmoModLink)
|
||||
, (AmmoTargetingSF atype, AmmoTargetingLink)
|
||||
, (AmmoPayloadSF atype, AmmoPayloadLink)
|
||||
, (AmmoEffectSF atype, AmmoEffectLink)
|
||||
, (SmokeReducerSF, SmokeReducerLink)
|
||||
( [ (AmmoModifierSF atype)
|
||||
, (AmmoTargetingSF atype)
|
||||
, (AmmoPayloadSF atype)
|
||||
, (AmmoEffectSF atype)
|
||||
, (SmokeReducerSF)
|
||||
]
|
||||
<> screenanddet
|
||||
, []
|
||||
)
|
||||
(_, RemoteScreenSF) ->
|
||||
( [(JoystickSF, JoystickLink)]
|
||||
( [(JoystickSF)]
|
||||
, []
|
||||
)
|
||||
(_, WeaponTargetingSF) -> (getAmmoLinks itm ++ [(ARHUDSF, SFLink ARHUDSF)], [])
|
||||
(_, WeaponTargetingSF) -> (getAmmoLinks itm ++ [(ARHUDSF)], [])
|
||||
(ATTACH BULLETSYNTH, _) ->
|
||||
([(AmmoMagSF ElectricalAmmo, AmmoInLink 0 ElectricalAmmo)], [])
|
||||
([(AmmoMagSF 0 ElectricalAmmo)], [])
|
||||
_ -> ([], [])
|
||||
|
||||
getAutoSpringLinks :: Item -> [(ItemStructuralFunction, ItemLink)]
|
||||
getAutoSpringLinks :: Item -> [(ItemStructuralFunction)]
|
||||
getAutoSpringLinks itm = case baseItemTriggerType itm of
|
||||
HammerTrigger _ -> [(MakeAutoSF, MakeAutoLink)]
|
||||
HammerTrigger _ -> [(MakeAutoSF)]
|
||||
_ -> []
|
||||
|
||||
extraWeaponLinks :: Item -> [(ItemStructuralFunction, ItemLink)]
|
||||
extraWeaponLinks :: Item -> [(ItemStructuralFunction)]
|
||||
extraWeaponLinks itm = case itm ^. itType of
|
||||
HELD GLAUNCHER -> launcherlinks <> [(GrenadeHitEffectSF,GrenadeHitEffectLink)]
|
||||
HELD GLAUNCHER -> launcherlinks <> [(GrenadeHitEffectSF)]
|
||||
HELD RLAUNCHER -> launcherlinks
|
||||
HELD RLAUNCHERX{} -> launcherlinks
|
||||
_ -> []
|
||||
where
|
||||
launcherlinks = [(ProjectileStabiliserSF,ProjectileStabiliserLink)]
|
||||
launcherlinks = [(ProjectileStabiliserSF)]
|
||||
|
||||
extraWeaponLinksBelow :: Item -> [(ItemStructuralFunction, ItemLink)]
|
||||
extraWeaponLinksBelow :: Item -> [(ItemStructuralFunction)]
|
||||
extraWeaponLinksBelow itm
|
||||
-- | Just TwoHandUnder <- itm ^? itUse . heldAim . aimStance
|
||||
| TwoHandUnder <- itemBaseStance itm
|
||||
= [(UnderBarrelSlotSF,UnderBarrelSlotLink)]
|
||||
= [(UnderBarrelSlotSF)]
|
||||
| otherwise = []
|
||||
|
||||
getAmmoLinks :: Item -> [(ItemStructuralFunction, ItemLink)]
|
||||
getAmmoLinks :: Item -> [(ItemStructuralFunction)]
|
||||
getAmmoLinks itm =
|
||||
map
|
||||
(\(i, a) -> (AmmoMagSF a, AmmoInLink i a))
|
||||
(\(i, a) -> (AmmoMagSF i a))
|
||||
(IM.toList $ itemAmmoSlots itm)
|
||||
|
||||
itemToFunction :: Item -> ItemStructuralFunction
|
||||
@@ -149,8 +158,8 @@ itemToFunction itm = case itm ^. itType of
|
||||
_
|
||||
| Just amtype <- magAmmoType itm-- ^? itConsumables . magType
|
||||
, Just _ <- itm ^? itLocation . ilEquipSite . _Just ->
|
||||
AmmoMagSF amtype
|
||||
AMMOMAG{} -> maybe NoSF AmmoMagSF $ magAmmoType itm -- ^? itConsumables . magType
|
||||
AmmoMagSF 0 amtype
|
||||
AMMOMAG{} -> maybe NoSF (AmmoMagSF 0) $ magAmmoType itm -- ^? itConsumables . magType
|
||||
ATTACH REMOTESCREEN -> RemoteScreenSF
|
||||
ATTACH JOYSTICK -> JoystickSF
|
||||
ATTACH REMOTEDETONATOR -> RemoteDetonatorSF
|
||||
@@ -178,6 +187,8 @@ treeToPotentialFunction ldt = case ldt ^. ldtValue . _1 . itType of
|
||||
HELD GLAUNCHER -> S.singleton UnderBarrelPlatformSF
|
||||
HELD BURSTRIFLE -> S.singleton UnderBarrelPlatformSF
|
||||
HELD LASER -> S.fromList [WeaponTargetingSF,LaserWeaponSF]
|
||||
-- following limits items to ten ammo slots
|
||||
_ | AmmoMagSF _ x <- ldt ^. ldtValue . _2 -> S.fromList [AmmoMagSF i x | i <- [0..9]]
|
||||
_ -> S.singleton (ldt ^. ldtValue . _2)
|
||||
|
||||
baseCI :: Item -> CItem
|
||||
|
||||
Reference in New Issue
Block a user