Fix rb scrolling

This commit is contained in:
2022-12-31 22:29:12 +00:00
parent beac123dd2
commit 0dc9a09723
11 changed files with 44 additions and 37 deletions
+7 -5
View File
@@ -30,7 +30,7 @@ useItem cr' w = fromMaybe (f w) $ do
itemEffect :: Creature -> Item -> World -> World
itemEffect cr it w = case it ^. itUse of
HeldUse{_heldUse = eff, _heldMods = usemods} ->
hammerTest $ tryReload cr it w $ foldl' (&) (useHeld eff) (useMod usemods) it cr
hammerTest $ tryReload cr it (_input w) $ foldl' (&) (useHeld eff) (useMod usemods) it cr
--hammerTest $ tryReload cr it w $ foldl' (&) (useHeld eff) (reverse $ useMod usemods) it cr
LeftUse{} -> doequipmentchange
EquipUse{} -> doequipmentchange
@@ -49,13 +49,15 @@ itemEffect cr it w = case it ^. itUse of
. activateEquipmentAt (_rbOptions w) cr
)
tryReload :: Creature -> Item -> World -> (World -> World) -> World -> World
tryReload cr it w f
| _crID cr == 0 && itNeedsLoading it && _mouseButtons (_input w) M.!? SDL.ButtonLeft == Just False =
crToggleReloading cr
tryReload :: Creature -> Item -> Input -> (World -> World) -> World -> World
tryReload cr it theinput f
| cid == 0 && itNeedsLoading it && _mouseButtons theinput M.!? SDL.ButtonLeft == Just False =
cWorld . lWorld . creatures . ix cid %~ crToggleReloading
| otherwise =
(runIdentity . pointerToItemLocation (_itLocation it) (return . (itUse . heldHammer .~ HammerDown)))
. f
where
cid = _crID cr
itNeedsLoading :: Item -> Bool
itNeedsLoading it = _laLoaded ic == 0 || not (_laPrimed ic)