Cleanup, delete hotkeys when deleting item from inventory

This commit is contained in:
2025-01-01 14:04:25 +00:00
parent 0915e04b56
commit 7dd379d4bc
12 changed files with 497 additions and 492 deletions
+2 -9
View File
@@ -13,14 +13,12 @@ import Dodge.Data.World
import Dodge.DoubleTree
import Dodge.Euse
import Dodge.HeldUse
--import Dodge.Hotkey
import Dodge.Inventory
import Dodge.Item.Grammar
--import Dodge.Item.Location
import qualified IntMapHelp as IM
useItem :: Int -> PressType -> World -> World
useItem invid pt w = (worldEventFlags . at InventoryChange ?~ ()) . fromMaybe w $ do
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
let usedloc = useLocation itmloc
@@ -90,7 +88,6 @@ toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
& crpoint . crEquipment . at newp ?~ invid
& crpoint . crInv . ix invid . itLocation . ilEquipSite ?~ newp
& onequip itm cr
-- & cWorld . lWorld %~ assignNewHotkey invid
MoveEquipment{_allocNewPos = newp, _allocOldPos = oldp} ->
w
& crpoint . crEquipment . at newp ?~ invid
@@ -109,16 +106,12 @@ toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
& crpoint . crInv . ix rid . itLocation . ilEquipSite .~ Nothing
& onremove (itmat rid) cr
& onequip itm cr
-- & cWorld . lWorld %~ removeHotkey rid
-- & cWorld . lWorld %~ assignNewHotkey invid
RemoveEquipment{_allocOldPos = oldp} ->
w
& crpoint . crEquipment . at oldp .~ Nothing
& crpoint . crInv . ix invid . itLocation . ilEquipSite .~ Nothing
& onremove itm cr
where
-- & cWorld . lWorld %~ removeHotkey invid
crpoint = cWorld . lWorld . creatures . ix (_crID cr)
itmat i = _crInv cr IM.! i
itm = itmat itRef