Remove more LDTs

This commit is contained in:
2025-07-11 00:49:36 +01:00
parent 05ff4651bd
commit 8ff607675b
3 changed files with 18 additions and 19 deletions
+4 -4
View File
@@ -26,17 +26,17 @@ useItemLoc cr loc pt w
| HeldPlatformSF <- sf | HeldPlatformSF <- sf
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached , fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached
, Aiming{} <- cr ^. crStance . posture = , Aiming{} <- cr ^. crStance . posture =
return $ gadgetEffect pt loc cr w return $ gadgetEffect pt (locLDTToLocDT loc) cr w
| LaserWeaponSF <- sf | LaserWeaponSF <- sf
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached , fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached
, Aiming{} <- cr ^. crStance . posture = , Aiming{} <- cr ^. crStance . posture =
return $ gadgetEffect pt loc cr w return $ gadgetEffect pt (locLDTToLocDT loc) cr w
| GadgetPlatformSF <- sf = | GadgetPlatformSF <- sf =
return $ gadgetEffect pt loc cr w return $ gadgetEffect pt (locLDTToLocDT loc) cr w
| UnderBarrelPlatformSF <- sf | UnderBarrelPlatformSF <- sf
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached , fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached
, Aiming{} <- cr ^. crStance . posture = , Aiming{} <- cr ^. crStance . posture =
return $ gadgetEffect pt loc cr w return $ gadgetEffect pt (locLDTToLocDT loc) cr w
| RemoteDetonatorSF <- sf | RemoteDetonatorSF <- sf
, pt == InitialPress = , pt == InitialPress =
return $ activateDetonator ldt w return $ activateDetonator ldt w
+3 -3
View File
@@ -153,7 +153,7 @@ invRootItemEffs cr =
invItemLocUpdate :: Creature -> LocationLDT ItemLink OItem -> World -> World invItemLocUpdate :: Creature -> LocationLDT ItemLink 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 (locLDTToLocDT 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
@@ -223,9 +223,9 @@ doAnyEquipmentEffect :: LocationLDT ItemLink OItem -> Creature -> World -> World
doAnyEquipmentEffect loc cr = maybe id (equipBackgroundEffect loc cr) doAnyEquipmentEffect loc cr = maybe id (equipBackgroundEffect loc cr)
$ loc ^? locLDT . ldtValue . _1 . itLocation . ilEquipSite . _Just $ loc ^? locLDT . ldtValue . _1 . itLocation . ilEquipSite . _Just
tryUseParent :: LocationLDT ItemLink OItem -> World -> World tryUseParent :: LocationDT OItem -> World -> World
tryUseParent loc w = fromMaybe w $ do tryUseParent loc w = fromMaybe w $ do
t <- locUp loc t <- locUp' loc
cr <- w ^? cWorld . lWorld . creatures . ix 0 cr <- w ^? cWorld . lWorld . creatures . ix 0
return $ gadgetEffect InitialPress t cr w return $ gadgetEffect InitialPress t cr w
+11 -12
View File
@@ -8,7 +8,6 @@ module Dodge.HeldUse (
heldEffectMuzzles, heldEffectMuzzles,
) where ) where
import Dodge.DoubleTree
import Color import Color
import Control.Applicative import Control.Applicative
import Control.Monad import Control.Monad
@@ -43,18 +42,18 @@ import RandomHelp
import qualified SDL import qualified SDL
import Sound.Data import Sound.Data
gadgetEffect :: PressType -> LocationLDT ItemLink OItem -> Creature -> World -> World gadgetEffect :: PressType -> LocationDT OItem -> Creature -> World -> World
gadgetEffect pt loc gadgetEffect pt loc
| UseHeld{} <- loc ^. locLDT . ldtValue . _1 . itUse = | UseHeld{} <- loc ^. locDT . dtValue . _1 . itUse =
heldEffect heldEffect
pt pt
(locLDTToLocDT loc) loc
| DROPPER x <- loc ^. locLDT . ldtValue . _1 . itType | DROPPER x <- loc ^. locDT . dtValue . _1 . itType
, Just i <- loc ^? locLDT . ldtValue . _1 . itUse . uInt , Just i <- loc ^? locDT . dtValue . _1 . itUse . uInt
, pt == InitialPress = , pt == InitialPress =
dropInventoryPath i x loc dropInventoryPath i x loc
| CLICKER x <- loc ^. locLDT . ldtValue . _1 . itType | CLICKER x <- loc ^. locDT . dtValue . _1 . itType
, Just i <- loc ^? locLDT . ldtValue . _1 . itUse . uInt = , Just i <- loc ^? locDT . dtValue . _1 . itUse . uInt =
useInventoryPath pt i x loc useInventoryPath pt i x loc
| otherwise = const id | otherwise = const id
@@ -1412,12 +1411,12 @@ useRewindGun i =
dropInventoryPath :: dropInventoryPath ::
Int -> Int ->
InventoryPathing -> InventoryPathing ->
LocationLDT ItemLink OItem -> LocationDT OItem ->
Creature -> Creature ->
World -> World ->
World World
dropInventoryPath i ip loc cr = fromMaybe id $ do dropInventoryPath i ip loc cr = fromMaybe id $ do
invid <- loc ^? locLDT . ldtValue . _1 . itLocation . ilInvID invid <- loc ^? locDT . dtValue . _1 . itLocation . ilInvID
j <- getInventoryPath i ip invid cr j <- getInventoryPath i ip invid cr
return $ dropItem cr j return $ dropItem cr j
@@ -1444,7 +1443,7 @@ useInventoryPath ::
PressType -> PressType ->
Int -> Int ->
InventoryPathing -> InventoryPathing ->
LocationLDT ItemLink OItem -> LocationDT OItem ->
Creature -> Creature ->
World -> World ->
World World
@@ -1459,7 +1458,7 @@ useInventoryPath pt i ip loc cr w = case ip of
w w
& cWorld . lWorld . delayedEvents .:~ (1, UseInvItem (i + j) pt) & cWorld . lWorld . delayedEvents .:~ (1, UseInvItem (i + j) pt)
RELITEM -> fromMaybe w $ do RELITEM -> fromMaybe w $ do
j <- loc ^? locLDT . ldtValue . _1 . itLocation . ilInvID j <- loc ^? locDT . dtValue . _1 . itLocation . ilInvID
guard $ (i + j) `IM.member` (cr ^. crInv) guard $ (i + j) `IM.member` (cr ^. crInv)
return $ return $
w w