Continue removing LDTs

This commit is contained in:
2025-07-12 14:01:44 +01:00
parent 8ff607675b
commit f47f99eac4
15 changed files with 359 additions and 257 deletions
+16 -16
View File
@@ -18,25 +18,25 @@ import qualified IntMapHelp as IM
useItem :: Int -> PressType -> World -> Maybe World
useItem invid pt w = fmap (worldEventFlags . at InventoryChange ?~ ()) $ do
cr <- w ^? cWorld . lWorld . creatures . ix 0
itmloc <- allInvLocs (_crInv cr) ^? ix invid . _2
useItemLoc cr itmloc pt w
itmloc <- invIndents (_crInv cr) ^? ix invid . _2
useItemLoc cr (itmloc) pt w
useItemLoc :: Creature -> LocationLDT ItemLink OItem -> PressType -> World -> Maybe World
useItemLoc :: Creature -> LocationDT OItem -> PressType -> World -> Maybe World
useItemLoc cr loc pt w
| HeldPlatformSF <- sf
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached
, fromMaybe False $ loc ^? locDT . dtValue . _1 . itLocation . ilIsAttached
, Aiming{} <- cr ^. crStance . posture =
return $ gadgetEffect pt (locLDTToLocDT loc) cr w
return $ gadgetEffect pt loc cr w
| LaserWeaponSF <- sf
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached
, fromMaybe False $ loc ^? locDT . dtValue . _1 . itLocation . ilIsAttached
, Aiming{} <- cr ^. crStance . posture =
return $ gadgetEffect pt (locLDTToLocDT loc) cr w
return $ gadgetEffect pt (loc) cr w
| GadgetPlatformSF <- sf =
return $ gadgetEffect pt (locLDTToLocDT loc) cr w
return $ gadgetEffect pt (loc) cr w
| UnderBarrelPlatformSF <- sf
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached
, fromMaybe False $ loc ^? locDT . dtValue . _1 . itLocation . ilIsAttached
, Aiming{} <- cr ^. crStance . posture =
return $ gadgetEffect pt (locLDTToLocDT loc) cr w
return $ gadgetEffect pt (loc) cr w
| RemoteDetonatorSF <- sf
, pt == InitialPress =
return $ activateDetonator ldt w
@@ -53,12 +53,12 @@ useItemLoc cr loc pt w
, pt == InitialPress
, Just invid' <- itm ^? itLocation . ilInvID =
return $ toggleEquipmentAt invid' cr w
| otherwise = (\loc' -> useItemLoc cr loc' pt w) =<< locUp loc
| otherwise = (\loc' -> useItemLoc cr loc' pt w) =<< locUp' loc
-- ie try location above
where
sf = loc ^. locLDT . ldtValue . _2
ldt = loc ^. locLDT
itm = ldt ^. ldtValue . _1
sf = loc ^. locDT . dtValue . _2
ldt = loc ^. locDT
itm = ldt ^. dtValue . _1
--chooseUseLocation :: LocationLDT ItemLink OItem -> LocationLDT ItemLink OItem
--chooseUseLocation loc
@@ -78,9 +78,9 @@ useItemLoc cr loc pt w
-- MapperSF -> True
-- _ -> False
activateDetonator :: LDTree ItemLink OItem -> World -> World
activateDetonator :: DTree OItem -> World -> World
activateDetonator det = fromMaybe id $ do
pjid <- det ^? ldtValue . _1 . itUse . uaParams . apProjectiles . ix 0
pjid <- det ^? dtValue . _1 . itUse . uaParams . apProjectiles . ix 0
return $ cWorld . lWorld . projectiles . ix pjid . pjTimer .~ 0
toggleEquipmentAt :: Int -> Creature -> World -> World