Cleanup, delete hotkeys when deleting item from inventory
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
--{-# LANGUAGE TupleSections #-}
|
||||
module Dodge.Inventory (
|
||||
checkInvSlotsYou,
|
||||
rmInvItem,
|
||||
rmInvItem,
|
||||
destroyInvItem,
|
||||
updateCloseObjects,
|
||||
changeSwapSel,
|
||||
@@ -46,10 +45,17 @@ destroyInvItem ::
|
||||
World ->
|
||||
World
|
||||
destroyInvItem cid invid w = rmInvItem cid invid w & removeitloc
|
||||
& removeithotkey
|
||||
where
|
||||
removeitloc = fromMaybe id $ do
|
||||
itid <- w ^? cWorld . lWorld . creatures . ix cid . crInv . ix invid . itID . unNInt
|
||||
return $ cWorld . lWorld . itemLocations . at itid .~ Nothing
|
||||
removeithotkey = fromMaybe id $ do
|
||||
itid <- w ^? cWorld . lWorld . creatures . ix cid . crInv . ix invid . itID . unNInt
|
||||
hk <- w ^? cWorld . lWorld . imHotkeys . unNIntMap . ix itid
|
||||
return $
|
||||
(cWorld . lWorld . imHotkeys . unNIntMap . at itid .~ Nothing)
|
||||
. ( cWorld . lWorld . hotkeys . at hk .~ Nothing)
|
||||
|
||||
-- | after this the item at the inventory position will no longer exist
|
||||
rmInvItem ::
|
||||
|
||||
Reference in New Issue
Block a user