Cleanup, hlints

This commit is contained in:
2025-07-12 21:35:35 +01:00
parent 5544e891c5
commit dc631263da
9 changed files with 58 additions and 74 deletions
+4 -4
View File
@@ -19,7 +19,7 @@ useItem :: Int -> PressType -> World -> Maybe World
useItem invid pt w = fmap (worldEventFlags . at InventoryChange ?~ ()) $ do useItem invid pt w = fmap (worldEventFlags . at InventoryChange ?~ ()) $ do
cr <- w ^? cWorld . lWorld . creatures . ix 0 cr <- w ^? cWorld . lWorld . creatures . ix 0
itmloc <- invIndents (_crInv cr) ^? ix invid . _2 itmloc <- invIndents (_crInv cr) ^? ix invid . _2
useItemLoc cr (itmloc) pt w useItemLoc cr itmloc pt w
useItemLoc :: Creature -> LocationDT OItem -> PressType -> World -> Maybe World useItemLoc :: Creature -> LocationDT OItem -> PressType -> World -> Maybe World
useItemLoc cr loc pt w useItemLoc cr loc pt w
@@ -30,13 +30,13 @@ useItemLoc cr loc pt w
| LaserWeaponSF <- sf | LaserWeaponSF <- sf
, fromMaybe False $ loc ^? locDT . dtValue . _1 . itLocation . ilIsAttached , fromMaybe False $ loc ^? locDT . dtValue . _1 . itLocation . ilIsAttached
, Aiming{} <- cr ^. crStance . posture = , Aiming{} <- cr ^. crStance . posture =
return $ gadgetEffect pt (loc) cr w return $ gadgetEffect pt loc cr w
| GadgetPlatformSF <- sf = | GadgetPlatformSF <- sf =
return $ gadgetEffect pt (loc) cr w return $ gadgetEffect pt loc cr w
| UnderBarrelPlatformSF <- sf | UnderBarrelPlatformSF <- sf
, fromMaybe False $ loc ^? locDT . dtValue . _1 . itLocation . ilIsAttached , fromMaybe False $ loc ^? locDT . dtValue . _1 . itLocation . ilIsAttached
, Aiming{} <- cr ^. crStance . posture = , Aiming{} <- cr ^. crStance . posture =
return $ gadgetEffect pt (loc) cr w return $ gadgetEffect pt loc cr w
| RemoteDetonatorSF <- sf | RemoteDetonatorSF <- sf
, pt == InitialPress = , pt == InitialPress =
return $ activateDetonator ldt w return $ activateDetonator ldt w
+5 -6
View File
@@ -153,7 +153,7 @@ invRootItemEffs cr =
invItemLocUpdate :: Creature -> LocationDT OItem -> World -> World invItemLocUpdate :: Creature -> LocationDT OItem -> World -> World
invItemLocUpdate cr loc w = doAnyEquipmentEffect loc cr $ case itm ^. itType of invItemLocUpdate cr loc w = doAnyEquipmentEffect loc cr $ case itm ^. itType of
ATTACH BULLETSYNTH -> trySynthBullet loc w ATTACH BULLETSYNTH -> trySynthBullet loc w
EQUIP WRIST_ECG | haspulse -> tryUseParent (loc) w EQUIP WRIST_ECG | haspulse -> tryUseParent loc w
COPIER _ -> copierItemUpdate itm cr w COPIER _ -> copierItemUpdate itm cr w
HELD FLATSHIELD -> rootNotrootEff createShieldWall removeShieldWall itm cr w HELD FLATSHIELD -> rootNotrootEff createShieldWall removeShieldWall itm cr w
HELD MINIGUNX{} -> coolMinigun itm w HELD MINIGUNX{} -> coolMinigun itm w
@@ -293,8 +293,7 @@ drawARHUD (LocDT con _) w = fromMaybe w $ do
shineTargetLaser :: Creature -> LocationDT OItem -> World -> World shineTargetLaser :: Creature -> LocationDT OItem -> World -> World
shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
guard (crIsAiming cr) guard (crIsAiming cr)
-- (_, mag) <- find (isammolink . fst) (itmtree ^. ldtLeft) mag <- find (isammolink . (^. dtValue . _2)) (itmtree ^. dtLeft)
( mag) <- find (isammolink . (^. dtValue . _2)) (itmtree ^. dtLeft)
i <- mag ^. dtValue . _1 . itConsumables i <- mag ^. dtValue . _1 . itConsumables
guard $ i >= x guard $ i >= x
maginvid <- mag ^? dtValue . _1 . itLocation . ilInvID maginvid <- mag ^? dtValue . _1 . itLocation . ilInvID
@@ -316,7 +315,7 @@ shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ d
, _lpType = TargetingLaser (_itID itm) , _lpType = TargetingLaser (_itID itm)
} }
where where
o = locOrient (loc) cr o = locOrient loc cr
itmtree = loc ^. locDT itmtree = loc ^. locDT
(p, q) = o `Q.comp` (V3 5 0 0, Q.qID) (p, q) = o `Q.comp` (V3 5 0 0, Q.qID)
x = 1 x = 1
@@ -332,7 +331,7 @@ shineTargetLaser cr loc w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ d
shineTorch :: Creature -> LocationDT OItem -> World -> World shineTorch :: Creature -> LocationDT OItem -> World -> World
shineTorch cr loc = fromMaybe id $ do shineTorch cr loc = fromMaybe id $ do
( mag) <- find (isammolink . (^. dtValue . _2)) (itmtree ^. dtLeft) mag <- find (isammolink . (^. dtValue . _2)) (itmtree ^. dtLeft)
i <- mag ^. dtValue . _1 . itConsumables i <- mag ^. dtValue . _1 . itConsumables
guard $ crIsAiming cr guard $ crIsAiming cr
guard $ i >= x guard $ i >= x
@@ -342,7 +341,7 @@ shineTorch cr loc = fromMaybe id $ do
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itConsumables . _Just -~ x) . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itConsumables . _Just -~ x)
where where
itmtree = loc ^. locDT itmtree = loc ^. locDT
(p, q) = locOrient (loc) cr (p, q) = locOrient loc cr
x = 10 x = 10
isammolink AmmoMagSF{} = True isammolink AmmoMagSF{} = True
isammolink _ = False isammolink _ = False
+1 -1
View File
@@ -97,7 +97,7 @@ crInAimStance as cr = crIsAiming cr && mitstance == Just as
i <- cr ^? crManipulation . manObject . imRootSelectedItem i <- cr ^? crManipulation . manObject . imRootSelectedItem
--itm <- invRootTrees' (cr ^. crInv) ^? ix i --itm <- invRootTrees' (cr ^. crInv) ^? ix i
itm <- fmap (fmap (\(a,b,_) -> (a,b))) $ invIMDT (cr ^. crInv) ^? ix i itm <- fmap (fmap (\(a,b,_) -> (a,b))) $ invIMDT (cr ^. crInv) ^? ix i
return $ aimStance $ itm return $ aimStance itm
--cr ^? crInv . ix i . itUse . heldAim . aimStance --cr ^? crInv . ix i . itUse . heldAim . aimStance
oneH :: Creature -> Bool oneH :: Creature -> Bool
+8 -8
View File
@@ -113,7 +113,7 @@ makeLenses ''ContextDT
instance Functor (LocationLDT b) where instance Functor (LocationLDT b) where
fmap f (LocLDT c t) = LocLDT (fmap f c) (fmap f t) fmap f (LocLDT c t) = LocLDT (fmap f c) (fmap f t)
instance Functor (LocationDT) where instance Functor LocationDT where
fmap f (LocDT c t) = LocDT (fmap f c) (fmap f t) fmap f (LocDT c t) = LocDT (fmap f c) (fmap f t)
instance Functor (ContextLDT b) where instance Functor (ContextLDT b) where
@@ -133,20 +133,20 @@ instance Functor (ContextLDT b) where
l l
(fmap (fmap (fmap f)) cr) (fmap (fmap (fmap f)) cr)
instance Functor (ContextDT) where instance Functor ContextDT where
fmap f = \case fmap f = \case
TopDT -> TopDT TopDT -> TopDT
LeftwardDT u cl p cr fr -> LeftwardDT LeftwardDT u cl p cr fr -> LeftwardDT
(fmap f u) (fmap f u)
(fmap (fmap ( f)) cl) (fmap (fmap f) cl)
(f p) (f p)
(fmap (fmap ( f)) cr) (fmap (fmap f) cr)
(fmap (fmap ( f)) fr) (fmap (fmap f) fr)
RightwardDT u fl cl p cr -> RightwardDT (fmap f u) RightwardDT u fl cl p cr -> RightwardDT (fmap f u)
(fmap (fmap ( f)) fl) (fmap (fmap f) fl)
(fmap (fmap ( f)) cl) (fmap (fmap f) cl)
(f p) (f p)
(fmap (fmap ( f)) cr) (fmap (fmap f) cr)
--deriveJSON defaultOptions ''DoubleTree --deriveJSON defaultOptions ''DoubleTree
--deriveJSON defaultOptions ''LabelDoubleTree --deriveJSON defaultOptions ''LabelDoubleTree
+9 -10
View File
@@ -37,16 +37,15 @@ conLDTToConDT = \case
dtStartPropagate :: (a -> c) -> (c -> a -> c) -> DTree a -> DTree c dtStartPropagate :: (a -> c) -> (c -> a -> c) -> DTree a -> DTree c
dtStartPropagate g f (DT x l r) = DT z dtStartPropagate g f (DT x l r) = DT z
(fmap (\(t) -> (dtPropagate' z f t)) l) (fmap (dtPropagate' f z) l)
(fmap (\(t) -> (dtPropagate' z f t)) r) (fmap (dtPropagate' f z) r)
where where
z = g x z = g x
dtPropagate' :: c -> (c -> a -> c) -> DTree a -> DTree c dtPropagate' :: (c -> a -> c) -> c -> DTree a -> DTree c
dtPropagate' x f (DT y l r) = DT z dtPropagate' f x (DT y l r) = DT z
(fmap (\(t) -> (dtPropagate' z f t)) l) (fmap (dtPropagate' f z) l)
(fmap (\(t) -> (dtPropagate' z f t)) r) (fmap (dtPropagate' f z) r)
where where
z = f x y z = f x y
@@ -291,12 +290,12 @@ locUp' (LocDT c@LeftwardDT{} t) =
Just $ Just $
LocDT LocDT
(_cdtUp c) (_cdtUp c)
(DT (_cdtParent c) (_cdtCloseLeft c ++ (( t) : _cdtCloseRight c)) (_cdtFarRight c)) (DT (_cdtParent c) (_cdtCloseLeft c ++ ( t : _cdtCloseRight c)) (_cdtFarRight c))
locUp' (LocDT c@RightwardDT{} t) = locUp' (LocDT c@RightwardDT{} t) =
Just $ Just $
LocDT LocDT
(_cdtUp c) (_cdtUp c)
(DT (_cdtParent c) (_cdtFarLeft c) (_cdtCloseLeft c ++ (( t) : _cdtCloseRight c))) (DT (_cdtParent c) (_cdtFarLeft c) (_cdtCloseLeft c ++ ( t : _cdtCloseRight c)))
locToTop' :: LocationDT a -> LocationDT a locToTop' :: LocationDT a -> LocationDT a
locToTop' loc = maybe loc locToTop' $ locUp' loc locToTop' loc = maybe loc locToTop' $ locUp' loc
@@ -333,7 +332,7 @@ locDTGoLeft (LocDT c (DT v l r)) =
-- should probably do tests for these -- should probably do tests for these
locDTGoRight :: LocationDT a -> [LocationDT a] locDTGoRight :: LocationDT a -> [LocationDT a]
locDTGoRight (LocDT c (DT v l r)) = locDTGoRight (LocDT c (DT v l r)) =
[LocDT (RightwardDT c l closel v closer) t | (closel, ( t), closer) <- locDTGoHelp id r] [LocDT (RightwardDT c l closel v closer) t | (closel, t, closer) <- locDTGoHelp id r]
-- this seems like it might be very inefficient for large lists -- this seems like it might be very inefficient for large lists
-- difference lists? -- difference lists?
+21 -21
View File
@@ -69,19 +69,19 @@ hammerCheck ::
World World
hammerCheck f pt loc cr w = case itemTriggerType loc of hammerCheck f pt loc cr w = case itemTriggerType loc of
WarmUpNoDelay wm WarmUpNoDelay wm
| _wTime (_itParams $ it) < wm -> | _wTime (_itParams it) < wm ->
w & setwarming w & setwarming
& soundContinue (CrWeaponSound cid 0) (_crPos cr) (warmupSound $ it ^. itType) (Just 2) & soundContinue (CrWeaponSound cid 0) (_crPos cr) (warmupSound $ it ^. itType) (Just 2)
& cWorld . lWorld . creatures . ix cid . crInv . ix invid . itParams . wTime +~ 1 & cWorld . lWorld . creatures . ix cid . crInv . ix invid . itParams . wTime +~ 1
WarmUpNoDelay{} -> f loc cr w & setwarming WarmUpNoDelay{} -> f loc cr w & setwarming
WarmUpCoolDown ws _ _ WarmUpCoolDown ws _ _
-- UNSAFE: -- UNSAFE:
| _wTime (_itParams $ it) < ws -> | _wTime (_itParams it) < ws ->
w & setwarming w & setwarming
& soundContinue (CrWeaponSound cid 0) (_crPos cr) (warmupSound $ it ^. itType) (Just 2) & soundContinue (CrWeaponSound cid 0) (_crPos cr) (warmupSound $ it ^. itType) (Just 2)
& cWorld . lWorld . creatures . ix cid . crInv . ix invid . itParams . wTime +~ 1 & cWorld . lWorld . creatures . ix cid . crInv . ix invid . itParams . wTime +~ 1
WarmUpCoolDown _ cs _ WarmUpCoolDown _ cs _
| _wTime (_itParams $ it) < cs -> | _wTime (_itParams it) < cs ->
f loc cr w & setwarming f loc cr w & setwarming
& cWorld . lWorld . creatures . ix cid . crInv . ix invid . itParams . wTime +~ 1 & cWorld . lWorld . creatures . ix cid . crInv . ix invid . itParams . wTime +~ 1
WarmUpCoolDown{} -> w & setwarming WarmUpCoolDown{} -> w & setwarming
@@ -671,7 +671,7 @@ loadMuzzle ::
loadMuzzle t@(DT _ l _) mz = fromMaybe (t, Nothing) $ do loadMuzzle t@(DT _ l _) mz = fromMaybe (t, Nothing) $ do
let as = _mzAmmoSlot mz let as = _mzAmmoSlot mz
amamount = _mzAmmoPerShot mz amamount = _mzAmmoPerShot mz
(i, ( mag)) <- findWithIx (isAmmoIntLink as . (^. dtValue . _2)) l (i, mag) <- findWithIx (isAmmoIntLink as . (^. dtValue . _2)) l
availableammo <- mag ^. dtValue . _1 . itConsumables availableammo <- mag ^. dtValue . _1 . itConsumables
let usedammo = case amamount of let usedammo = case amamount of
UseUpTo x -> min x availableammo UseUpTo x -> min x availableammo
@@ -681,7 +681,7 @@ loadMuzzle t@(DT _ l _) mz = fromMaybe (t, Nothing) $ do
guard $ usedammo > 0 guard $ usedammo > 0
return return
( t & dtLeft . ix i . dtValue . _1 . itConsumables . _Just -~ usedammo ( t & dtLeft . ix i . dtValue . _1 . itConsumables . _Just -~ usedammo
, Just (mz, usedammo, (mag)) , Just (mz, usedammo, mag)
) )
makeMuzzleFlare :: Muzzle -> LocationDT OItem -> Creature -> World -> World makeMuzzleFlare :: Muzzle -> LocationDT OItem -> Creature -> World -> World
@@ -771,9 +771,9 @@ useLoadedAmmo loc cr (_, w) (Just (mz, x, magtree)) = (,) True $
MuzzleGLauncher -> MuzzleGLauncher ->
createProjectile createProjectile
(itmtree ^. dtValue . _3) (itmtree ^. dtValue . _3)
(Grenade (getGrenadeHitEffect $ itmtree)) (Grenade (getGrenadeHitEffect itmtree))
magtree magtree
(getPJStabiliser $ itmtree) (getPJStabiliser itmtree)
mz mz
cr cr
w w
@@ -933,14 +933,14 @@ getBulletType magtree =
bpayload = fromMaybe (BulPlain 100) $ do bpayload = fromMaybe (BulPlain 100) $ do
attree <- find ispayload (magtree ^. dtLeft) attree <- find ispayload (magtree ^. dtLeft)
attree ^? dtValue . _1 . itUse . ubMod . bmPayload attree ^? dtValue . _1 . itUse . ubMod . bmPayload
ispayload :: (DTree OItem) -> Bool ispayload :: DTree OItem -> Bool
ispayload y = case y ^. dtValue . _2 of ispayload y = case y ^. dtValue . _2 of
AmmoPayloadSF {} -> True AmmoPayloadSF {} -> True
_ -> False _ -> False
beffect = fromMaybe DestroyBullet $ do beffect = fromMaybe DestroyBullet $ do
attree <- find isammoeffect (magtree ^. dtLeft) attree <- find isammoeffect (magtree ^. dtLeft)
attree ^? dtValue . _1 . itUse . ubMod . bmEffect attree ^? dtValue . _1 . itUse . ubMod . bmEffect
isammoeffect :: (DTree OItem) -> Bool isammoeffect :: DTree OItem -> Bool
isammoeffect y = case y ^. dtValue . _2 of isammoeffect y = case y ^. dtValue . _2 of
AmmoEffectSF {} -> True AmmoEffectSF {} -> True
_ -> False _ -> False
@@ -984,7 +984,7 @@ shootBullets ::
World -> World ->
World World
shootBullets loc cr (mz, x, magtree) w = fromMaybe w $ do shootBullets loc cr (mz, x, magtree) w = fromMaybe w $ do
thebullet <- getBulletType $ magtree thebullet <- getBulletType magtree
return $ foldl' (&) w (replicate x (shootBullet thebullet loc cr mz)) return $ foldl' (&) w (replicate x (shootBullet thebullet loc cr mz))
shootBullet :: Bullet -> LocationDT OItem -> Creature -> Muzzle -> World -> World shootBullet :: Bullet -> LocationDT OItem -> Creature -> Muzzle -> World -> World
@@ -1246,19 +1246,19 @@ determineProjectileTracking magtree itmtree =
_ <- find isammotargeting (magtree ^. dtLeft) _ <- find isammotargeting (magtree ^. dtLeft)
targetingtree <- find isweapontargeting (itmtree ^. dtRight) targetingtree <- find isweapontargeting (itmtree ^. dtRight)
return $ HomeUsingTargeting (targetingtree ^. dtValue . _1 . itID) return $ HomeUsingTargeting (targetingtree ^. dtValue . _1 . itID)
isremscreen :: (DTree OItem) -> Bool isremscreen :: DTree OItem -> Bool
isremscreen x = case x ^. dtValue . _2 of isremscreen x = case x ^. dtValue . _2 of
RemoteScreenSF {} -> True RemoteScreenSF {} -> True
_ -> False _ -> False
isjoystick :: (DTree OItem) -> Bool isjoystick :: DTree OItem -> Bool
isjoystick x = case x ^. dtValue . _2 of isjoystick x = case x ^. dtValue . _2 of
JoystickSF {} -> True JoystickSF {} -> True
_ -> False _ -> False
isammotargeting :: (DTree OItem) -> Bool isammotargeting :: DTree OItem -> Bool
isammotargeting x = case x ^. dtValue . _2 of isammotargeting x = case x ^. dtValue . _2 of
AmmoTargetingSF {} -> True AmmoTargetingSF {} -> True
_ -> False _ -> False
isweapontargeting :: (DTree OItem) -> Bool isweapontargeting :: DTree OItem -> Bool
isweapontargeting x = case x ^. dtValue . _2 of isweapontargeting x = case x ^. dtValue . _2 of
WeaponTargetingSF {} -> True WeaponTargetingSF {} -> True
_ -> False _ -> False
@@ -1274,7 +1274,7 @@ createProjectileR loc magtree =
createProjectile createProjectile
(loc ^. locDT . dtValue . _3) (loc ^. locDT . dtValue . _3)
( Rocket ( Rocket
(determineProjectileTracking ( magtree) $ itmtree) (determineProjectileTracking magtree itmtree)
smoke smoke
) )
magtree magtree
@@ -1284,7 +1284,7 @@ createProjectileR loc magtree =
smoke smoke
| isJust $ find issmokereducer (magtree ^. dtLeft) = Just ReducedRocketSmoke | isJust $ find issmokereducer (magtree ^. dtLeft) = Just ReducedRocketSmoke
| otherwise = Nothing | otherwise = Nothing
issmokereducer :: (DTree OItem) -> Bool issmokereducer :: DTree OItem -> Bool
issmokereducer y = case y ^. dtValue . _2 of issmokereducer y = case y ^. dtValue . _2 of
SmokeReducerSF {} -> True SmokeReducerSF {} -> True
_ -> False _ -> False
@@ -1297,7 +1297,7 @@ getPJStabiliser ldt = case find isprojstab (ldt ^. dtRight) of
_ -> Nothing _ -> Nothing
_ -> Nothing _ -> Nothing
where where
isprojstab :: (DTree OItem) -> Bool isprojstab :: DTree OItem -> Bool
isprojstab y = case y ^.dtValue . _2 of isprojstab y = case y ^.dtValue . _2 of
ProjectileStabiliserSF {} -> True ProjectileStabiliserSF {} -> True
_ -> False _ -> False
@@ -1309,7 +1309,7 @@ getGrenadeHitEffect t = case find isghiteff (t ^. dtRight) of
_ -> GBounce 2 _ -> GBounce 2
_ -> GBounce 2 _ -> GBounce 2
where where
isghiteff :: (DTree OItem) -> Bool isghiteff :: DTree OItem -> Bool
isghiteff y = case y ^. dtValue . _2 of isghiteff y = case y ^. dtValue . _2 of
GrenadeHitEffectSF {} -> True GrenadeHitEffectSF {} -> True
_ -> False _ -> False
@@ -1340,15 +1340,15 @@ createProjectile x pjtype magtree stab muz cr = fromMaybe failsound $ do
createShell x rdetonate rscreen stab pjtype aparams muz cr createShell x rdetonate rscreen stab pjtype aparams muz cr
. startthesound . startthesound
where where
isrdet :: (DTree OItem) -> Bool isrdet :: DTree OItem -> Bool
isrdet y = case y ^. dtValue . _2 of isrdet y = case y ^. dtValue . _2 of
RemoteDetonatorSF {} -> True RemoteDetonatorSF {} -> True
_ -> False _ -> False
isrscreen :: (DTree OItem) -> Bool isrscreen :: DTree OItem -> Bool
isrscreen y = case y ^. dtValue . _2 of isrscreen y = case y ^. dtValue . _2 of
RemoteScreenSF {} -> True RemoteScreenSF {} -> True
_ -> False _ -> False
isampay :: (DTree OItem) -> Bool isampay :: DTree OItem -> Bool
isampay y = case y ^. dtValue . _2 of isampay y = case y ^. dtValue . _2 of
AmmoPayloadSF {} -> True AmmoPayloadSF {} -> True
_ -> False _ -> False
+1 -1
View File
@@ -23,7 +23,7 @@ itemEquipPict cr itmtree
, Just attachpos <- equipAttachPos <$> itm ^? itType . ibtEquip , Just attachpos <- equipAttachPos <$> itm ^? itType . ibtEquip
= equipPosition esite cr attachpos (itemSPic itm) = equipPosition esite cr attachpos (itemSPic itm)
| itm ^? itLocation . ilInvID == cr ^? crManipulation . manObject . imRootSelectedItem | itm ^? itLocation . ilInvID == cr ^? crManipulation . manObject . imRootSelectedItem
= overPosSP (Q.prePos $ handHandleOrient (loc) cr) (itemTreeSPic $ itmtree) = overPosSP (Q.prePos $ handHandleOrient loc cr) (itemTreeSPic itmtree)
| otherwise = mempty | otherwise = mempty
where where
itm = itmtree ^. dtValue . _1 itm = itmtree ^. dtValue . _1
+8 -22
View File
@@ -1,15 +1,12 @@
{-# LANGUAGE TupleSections #-} {-# LANGUAGE TupleSections #-}
module Dodge.Item.Grammar ( module Dodge.Item.Grammar (
invDT, invDT,
-- invLDT,
invDT', invDT',
invAdj, invAdj,
invRootMap, invRootMap,
-- invRootTrees,
invIMDT, invIMDT,
baseCI, baseCI,
invIndents, invIndents,
-- allInvLocs,
) where ) where
import Dodge.Item.Orientation import Dodge.Item.Orientation
@@ -52,15 +49,6 @@ tryAttachItems = leftRightCombine leftIsParentCombine rightIsParentCombine
-- [(JoystickSF, JoystickLink)] -- [(JoystickSF, JoystickLink)]
-- _ -> [] -- _ -> []
--itemToBreakLists ::
-- Item ->
-- ItemStructuralFunction ->
-- ([(ItemStructuralFunction, ItemLink)], [(ItemStructuralFunction, ItemLink)])
--itemToBreakLists itm itmf = (fmap f l, fmap f r)
-- where
-- f x = (x, SFLink x)
-- (l,r) = itemToBreakLists' itm itmf
itemToBreakLists :: itemToBreakLists ::
Item -> Item ->
ItemStructuralFunction -> ItemStructuralFunction ->
@@ -71,7 +59,7 @@ itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
(_, HeldPlatformSF) -> (_, HeldPlatformSF) ->
( getAmmoLinks itm ( getAmmoLinks itm
<> extraWeaponLinksBelow itm <> extraWeaponLinksBelow itm
, [(WeaponTargetingSF), (WeaponScopeSF)] , [WeaponTargetingSF, WeaponScopeSF]
<> getAutoSpringLinks itm <> getAutoSpringLinks itm
<> extraWeaponLinks itm <> extraWeaponLinks itm
) )
@@ -79,23 +67,23 @@ itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
( getAmmoLinks itm,[]) ( getAmmoLinks itm,[])
(DETECTOR {}, _) -> (DETECTOR {}, _) ->
( getAmmoLinks itm ( getAmmoLinks itm
, [(ARHUDSF),(TriggerSF),(MapperSF)] , [ARHUDSF,TriggerSF,MapperSF]
) )
(CRAFT TRANSFORMER, _) -> ([],[(LaserWeaponSF)]) (CRAFT TRANSFORMER, _) -> ([],[LaserWeaponSF])
(MAPPER, _) -> (MAPPER, _) ->
( [] ( []
, [(ARHUDSF)] , [ARHUDSF]
) )
(_, GadgetPlatformSF) -> (_, GadgetPlatformSF) ->
( getAmmoLinks itm ( getAmmoLinks itm
, [(TriggerSF), (WeaponTargetingSF), (WeaponScopeSF)] , [TriggerSF, WeaponTargetingSF, WeaponScopeSF]
) )
(_, AmmoMagSF{}) -> fromMaybe ([], []) $ do (_, AmmoMagSF{}) -> fromMaybe ([], []) $ do
atype <- magAmmoType itm atype <- magAmmoType itm
let screenanddet = case atype of let screenanddet = case atype of
LauncherAmmo -> LauncherAmmo ->
[ (RemoteScreenSF) [ RemoteScreenSF
, (RemoteDetonatorSF) , RemoteDetonatorSF
] ]
_ -> [] _ -> []
return return
@@ -133,9 +121,7 @@ extraWeaponLinks itm = case itm ^. itType of
extraWeaponLinksBelow :: Item -> [(ItemStructuralFunction)] extraWeaponLinksBelow :: Item -> [(ItemStructuralFunction)]
extraWeaponLinksBelow itm extraWeaponLinksBelow itm
-- | Just TwoHandUnder <- itm ^? itUse . heldAim . aimStance | TwoHandUnder <- itemBaseStance itm = [(UnderBarrelSlotSF)]
| TwoHandUnder <- itemBaseStance itm
= [(UnderBarrelSlotSF)]
| otherwise = [] | otherwise = []
getAmmoLinks :: Item -> [(ItemStructuralFunction)] getAmmoLinks :: Item -> [(ItemStructuralFunction)]
+1 -1
View File
@@ -47,7 +47,7 @@ doWdWd we = case we of
cr <- w ^? cWorld . lWorld . creatures . ix cid cr <- w ^? cWorld . lWorld . creatures . ix cid
--itree <- allInvLocs (cr ^. crInv) ^? ix invid . _2 . locLDT --itree <- allInvLocs (cr ^. crInv) ^? ix invid . _2 . locLDT
loc <- invIndents (cr ^. crInv) ^? ix invid . _2 loc <- invIndents (cr ^. crInv) ^? ix invid . _2
return $ heldEffectMuzzles (loc) cr w return $ heldEffectMuzzles loc cr w
accessTerminal :: Maybe Int -> World -> World accessTerminal :: Maybe Int -> World -> World
accessTerminal mtmid w = fromMaybe w $ do accessTerminal mtmid w = fromMaybe w $ do