Hack together correct positioning of grenades from attached items
This commit is contained in:
@@ -25,7 +25,7 @@ useItem invid pt w = fmap (worldEventFlags . at InventoryChange ?~ ()) $ do
|
||||
useItemLoc cr usedloc pt w
|
||||
|
||||
useItemLoc :: Creature ->
|
||||
LocationLDT ItemLink CItem ->
|
||||
LocationLDT ItemLink OItem ->
|
||||
PressType ->
|
||||
World ->
|
||||
Maybe World
|
||||
@@ -33,13 +33,13 @@ useItemLoc cr loc pt w
|
||||
| HeldPlatformSF <- sf
|
||||
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsRoot
|
||||
, Aiming {} <- cr ^. crStance . posture =
|
||||
return $ heldEffect pt (bimap id (^. _1) ldt) cr w
|
||||
return $ heldEffect pt (bimap id id ldt) cr w
|
||||
| GadgetPlatformSF <- sf =
|
||||
return $ gadgetEffect pt loc cr w
|
||||
| UnderBarrelPlatformSF <- sf
|
||||
, fromMaybe False $ loc ^? locLDT . ldtValue . _1 . itLocation . ilIsAttached
|
||||
, Aiming {} <- cr ^. crStance . posture =
|
||||
return $ heldEffect pt (bimap id (^. _1) ldt) cr w
|
||||
return $ heldEffect pt (bimap id id ldt) cr w
|
||||
| RemoteDetonatorSF <- sf
|
||||
, pt == InitialPress =
|
||||
return $ activateDetonator ldt w
|
||||
@@ -62,7 +62,7 @@ useItemLoc cr loc pt w
|
||||
ldt = loc ^. locLDT
|
||||
itm = ldt ^. ldtValue . _1
|
||||
|
||||
useLocation :: LocationLDT ItemLink CItem -> LocationLDT ItemLink CItem
|
||||
useLocation :: LocationLDT ItemLink OItem -> LocationLDT ItemLink OItem
|
||||
useLocation loc
|
||||
| isJust $ loc ^? locLDT . ldtValue . _1 . itType . ibtEquip = loc
|
||||
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uaParams . apProjectiles . ix 0 =
|
||||
@@ -80,7 +80,7 @@ structureUseAtLoc = \case
|
||||
MapperSF -> True
|
||||
_ -> False
|
||||
|
||||
activateDetonator :: LDTree ItemLink CItem -> World -> World
|
||||
activateDetonator :: LDTree ItemLink OItem -> World -> World
|
||||
activateDetonator det = fromMaybe id $ do
|
||||
pjid <- det ^? ldtValue . _1 . itUse . uaParams . apProjectiles . ix 0
|
||||
return $ cWorld . lWorld . projectiles . ix pjid . pjTimer .~ 0
|
||||
|
||||
@@ -151,9 +151,9 @@ invRootItemEffs cr =
|
||||
appEndo $
|
||||
foldMap
|
||||
(reduceLocLDT (Endo . invItemLocUpdate cr) . LocLDT TopLDT)
|
||||
(invLDT (_crInv cr))
|
||||
(invLDT' (_crInv cr))
|
||||
|
||||
invItemLocUpdate :: Creature -> LocationLDT ItemLink CItem -> World -> World
|
||||
invItemLocUpdate :: Creature -> LocationLDT ItemLink OItem -> World -> World
|
||||
invItemLocUpdate cr loc w = doAnyEquipmentEffect loc cr $ case itm ^. itType of
|
||||
ATTACH BULLETSYNTH -> trySynthBullet loc w
|
||||
EQUIP WRIST_ECG | haspulse -> tryUseParent loc w
|
||||
@@ -208,21 +208,21 @@ copierItemUpdate itm cr w = fromMaybe w $ do
|
||||
v <- getItemValue itm' w cr
|
||||
return $ w & pointerToItem itm . itUse . uValue .~ v
|
||||
|
||||
doAnyEquipmentEffect :: LocationLDT ItemLink CItem -> Creature -> World -> World
|
||||
doAnyEquipmentEffect :: LocationLDT ItemLink OItem -> Creature -> World -> World
|
||||
doAnyEquipmentEffect loc cr = case itm ^? itLocation . ilEquipSite . _Just of
|
||||
Just _ -> equipBackgroundEffect loc cr
|
||||
_ -> id
|
||||
where
|
||||
itm = loc ^. locLDT . ldtValue . _1
|
||||
|
||||
tryUseParent :: LocationLDT ItemLink CItem -> World -> World
|
||||
tryUseParent :: LocationLDT ItemLink OItem -> World -> World
|
||||
tryUseParent loc w = fromMaybe w $ do
|
||||
t <- locUp loc
|
||||
let t' = bimap id (^. _1) $ t ^. locLDT
|
||||
let t' = bimap id id $ t ^. locLDT
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
return $ heldEffectNoHammerCheck t' cr w
|
||||
|
||||
trySynthBullet :: LocationLDT ItemLink CItem -> World -> World
|
||||
trySynthBullet :: LocationLDT ItemLink OItem -> World -> World
|
||||
trySynthBullet loc w = fromMaybe w $ do
|
||||
i <- itm ^? itLocation . ilInvID
|
||||
x <- itm ^? itUse . uaParams . apInt
|
||||
@@ -278,7 +278,7 @@ trySynthBullet loc w = fromMaybe w $ do
|
||||
updateHeldRootItem :: Creature -> World -> World
|
||||
updateHeldRootItem cr = fromMaybe id $ do
|
||||
invid <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
itmtree <- invRootTrees (_crInv cr) ^? ix invid
|
||||
itmtree <- invRootTrees' (_crInv cr) ^? ix invid
|
||||
return $ updateAttachedItems itmtree cr
|
||||
|
||||
updateAttachedItems :: LDTree ItemLink CItem -> Creature -> World -> World
|
||||
|
||||
@@ -95,7 +95,7 @@ crInAimStance as cr = crIsAiming cr && mitstance == Just as
|
||||
where
|
||||
mitstance = do
|
||||
i <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
itm <- invRootTrees (cr ^. crInv) ^? ix i
|
||||
itm <- invRootTrees' (cr ^. crInv) ^? ix i
|
||||
return $ aimStance itm
|
||||
--cr ^? crInv . ix i . itUse . heldAim . aimStance
|
||||
|
||||
|
||||
Reference in New Issue
Block a user