diff --git a/src/Dodge/Creature/State.hs b/src/Dodge/Creature/State.hs index 6a45d01f9..4cc5907de 100644 --- a/src/Dodge/Creature/State.hs +++ b/src/Dodge/Creature/State.hs @@ -220,11 +220,8 @@ copierItemUpdate itm cr w = fromMaybe w $ do return $ w & pointerToItem itm . itUse . uValue .~ v 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 +doAnyEquipmentEffect loc cr = maybe id (equipBackgroundEffect loc cr) + $ loc ^? locLDT . ldtValue . _1 . itLocation . ilEquipSite . _Just tryUseParent :: LocationLDT ItemLink OItem -> World -> World tryUseParent loc w = fromMaybe w $ do diff --git a/src/Dodge/Euse.hs b/src/Dodge/Euse.hs index 292aaa347..143dc2d72 100644 --- a/src/Dodge/Euse.hs +++ b/src/Dodge/Euse.hs @@ -12,12 +12,13 @@ import Dodge.Wall.Move import Geometry import LensHelp -equipBackgroundEffect :: LocationLDT ItemLink OItem -> Creature -> World -> World +equipBackgroundEffect :: LocationLDT ItemLink OItem -> Creature -> EquipSite + -> World -> World equipBackgroundEffect loc cr = case eo of - EQUIP (MAGSHIELD mt) -> useMagShield mt itm cr + EQUIP (MAGSHIELD mt) -> const $ useMagShield mt itm cr EQUIP WRISTARMOUR -> setWristShieldPos itm cr - EQUIP HEADLAMP -> createHeadLamp itm cr - _ -> id + EQUIP HEADLAMP -> const $ createHeadLamp itm cr + _ -> const id where itm = loc ^. locLDT . ldtValue . _1 eo = itm ^. itType @@ -31,14 +32,13 @@ useMagShield mt _ cr w = , _mgField = mt } -setWristShieldPos :: Item -> Creature -> World -> World -setWristShieldPos itm cr w = w & moveWallIDUnsafe i wlline +setWristShieldPos :: Item -> Creature -> EquipSite -> World -> World +setWristShieldPos itm cr x = moveWallIDUnsafe i wlline where i = _itParamID $ _itParams itm wlline = (f (V3 (-10) 7 0), f (V3 10 7 0)) - invid = _ilInvID (_itLocation itm) - handtrans = case cr ^? crInv . ix invid . itLocation . ilEquipSite . _Just of - Just OnLeftWrist -> \cr' -> translatePointToLeftHand cr' . g + handtrans = case x of + OnLeftWrist -> \cr' -> translatePointToLeftHand cr' . g _ -> translatePointToRightHand g | twists cr = (+.+.+ V3 (-5) 10 0)